• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Intent Questions

Hello. I followed a YouTube video about creating a WebView and from that I created an Intent button with a Share Function, everything worked normally but after that I was trying to create a Call button with Intent which is working also, but now the share buttons have two functions, call and share.
How can I remove the call function from Share?

case R.id.myMenuFour:
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setType("text/plain");
shareIntent.putExtra(Intent.EXTRA_TEXT, myCurrentUrl);
shareIntent.putExtra(Intent.EXTRA_SUBJECT, "Copied URL");
startActivity(Intent.createChooser(shareIntent, "Share URL"));

case R.id.myMenuFive:
Intent callintent = new Intent(Intent.ACTION_DIAL);
callintent.setData(Uri.parse("tel:phonenumberhere"));
startActivity(callintent);

Thank you,
Raul.


----

FIXED! I forgot to add break;
Noob here :( sorry.
 
First thing that is obviously wrong with your code is that the case statements are missing a break statement.
Normally in Java, a switch block has the following syntax:

Code:
switch(expression) {
  case x:
    // code block
    break;
  case y:
    // code block
    break;
  default:
    // code block
}

The 'breaks' are necessary, because otherwise the execution falls right through to the next case block, even if it matched the previous one.
 
First thing that is obviously wrong with your code is that the case statements are missing a break statement.
Normally in Java, a switch block has the following syntax:

Code:
switch(expression) {
  case x:
    // code block
    break;
  case y:
    // code block
    break;
  default:
    // code block
}

The 'breaks' are necessary, because otherwise the execution falls right through to the next case block, even if it matched the previous one.
Hello LV426, I figured it out after I posted here, thanks for the heads up!
 
Back
Top Bottom