Results 1 to 5 of 5

Thread: Intent & action

  1. #1
    johnsonjp34 is offline Member
    Join Date
    Sep 2012
    Posts
    11
    Rep Power
    0

    Default Intent & action

    Having an issue with getting these buttons to work. When I push them nothing happens.

    package com.direction.investor.habit.cost;

    import android.app.Activity;


    import android.content.Intent;
    import android.net.Uri;
    import android.os.Bundle;

    import android.view.View;

    public class Helpme extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
    setContentView(R.layout.help);

    super.onCreate(savedInstanceState);
    }

    public void processClicks(View display){
    Intent action;
    int id = display.getId();
    switch (id) {
    case (R.id.button10):

    action = new Intent(Intent.ACTION_DIAL,
    Uri.parse("tel:800-662-4357"));
    startActivity(action);
    break;

    case (R.id.button11):

    action = new Intent(Intent.ACTION_DIAL,
    Uri.parse("tel:800-662-2255"));
    startActivity(action);
    break;

    case (R.id.button14):

    action = new Intent(Intent.ACTION_VIEW,
    Uri.parse("http://drugabuse.gov"));
    startActivity(action);
    break;

    case (R.id.button13):

    action = new Intent(Intent.ACTION_VIEW,
    Uri.parse("http://www.thesobervillage.com/toplist/"));
    startActivity(action);
    break;

    default:
    break;
    }

    }
    }

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,015
    Rep Power
    20

    Default Re: Intent & action

    Moving to the Android forum.

    Please use [code] tags [/code] when posting code.
    Many people won't bother reading code that is not formatted.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  3. #3
    johnsonjp34 is offline Member
    Join Date
    Sep 2012
    Posts
    11
    Rep Power
    0

    Default Re: Intent & action

    Thanks for the advice. Hopefully I did this right.

    Anyways to clarify, I have four cases and a different action to occur when the corresponding button in the xml file is pushed. When I push the buttons, nothing happens.

    Java Code:
    package com.direction.investor.habit.cost;
    
    import android.app.Activity;
    
    
    import android.content.Intent;
    import android.net.Uri;
    import android.os.Bundle;
    
    import android.view.View;
    
    public class Helpme extends Activity {
    
    @Override
    protected void onCreate(Bundle savedInstanceState) {
    setContentView(R.layout.help);
    
    super.onCreate(savedInstanceState);
    }
    
    public void processClicks(View display){
    Intent action;
    int id = display.getId();
    switch (id) {
    case (R.id.button10):
    
    action = new Intent(Intent.ACTION_DIAL,
    Uri.parse("tel:800-662-4357"));
    startActivity(action);
    break;
    
    case (R.id.button11):
    
    action = new Intent(Intent.ACTION_DIAL,
    Uri.parse("tel:800-662-2255"));
    startActivity(action);
    break;
    
    case (R.id.button14):
    
    action = new Intent(Intent.ACTION_VIEW,
    Uri.parse("http://drugabuse.gov"));
    startActivity(action);
    break;
    
    case (R.id.button13):
    
    action = new Intent(Intent.ACTION_VIEW,
    Uri.parse("http://www.thesobervillage.com/toplist/"));
    startActivity(action);
    break;
    
    default:
    break;
    }
    
    }
    }

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is online now Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,247
    Rep Power
    19

    Default Re: Intent & action

    Do you really write code that is all left aligned, without any indenting at all?

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  5. #5
    johnsonjp34 is offline Member
    Join Date
    Sep 2012
    Posts
    11
    Rep Power
    0

    Default Re: Intent & action

    No, not usually. I figured the problem out. I forget to activate the processClicks on my button. Thanks guys.

Similar Threads

  1. form.action
    By garyking in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 08-11-2011, 02:49 PM
  2. Replies: 1
    Last Post: 06-30-2011, 09:49 AM
  3. Format of box changes after first action
    By tnixon22 in forum New To Java
    Replies: 3
    Last Post: 02-21-2011, 03:09 AM
  4. Replies: 3
    Last Post: 08-19-2010, 08:27 AM
  5. Jsp to Action class
    By Sujatha.G in forum JavaServer Pages (JSP) and JSTL
    Replies: 2
    Last Post: 01-05-2010, 10:59 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •