Fires Intent with four option for sending email - android

I write a code that fires an Intent for sending an email.
Intent intent = new Intent(android.content.Intent.ACTION_SEND);
intent.setType("image/png");
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
intent.putExtra(Intent.EXTRA_STREAM, imageUri);
startActivity(Intent.createChooser(intent, getResources().getString(R.string.share_title_text)));
However, when this Intent is fired, I see many items on the list like Bluetooth, Gmail app, Facebook app and so on.
How can I filter this list and only show these four items:
Gmail, EverNote, Twitter and Facebook.

you can't control the application list, in fact every application that register for Intent android.content.Intent.ACTION_SEND will be shown in this list

Related

Android Intents: Sending message through email or sms, using the built-in app picker

GOAL: When user taps the Send to... button, I want android to open a list of apps that can send messages (email, sms, etc.). The user picks one. That apps opens with text message already fed in.
Here is the code I use to try to achieve that:
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT, outputTextView.getText());
if (intent.resolveActivity(getPackageManager()) != null) {
startActivity(intent);
PROBLEM: When running it, a list of available apps is correctly displayed (Gmail, Hangouts, Messenger, Keep, Translate, etc.). If I pick GMail, it works fine. BUT: If I pick Hangout, Keep, Translate or any of the other suggested apps, my text is not displayed in those.
What am I missing?
Try this code
Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND);
shareIntent.setType("text/plain");
shareIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Try this code for Sharing!");
shareIntent.putExtra(android.content.Intent.EXTRA_TEXT, "I'm trying to share data....");
Intent chooserIntent = Intent.createChooser(shareIntent, "Share with");
chooserIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(chooserIntent);

Android intent chooser does not display list if earlier intent is not finished

With the code below I share some text from my app via an intent chooser. My problem is that if I for example choose to share the text as a message and when in the message app I just hit the home button and bring my app back to front. Then when I try to start a new intent chooser it immediately sends me back to the unfinished message app. I would rather that it forgot all about that and presented me with the list of choices again.
Is there a way to make it forget the old choice?
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT, text);
startActivity(Intent.createChooser(intent, "Share text as..."));
Add the following
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);

Don't display Facebook app in Android Intent

Hi I have the following code:
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT, message);
Now I can choose among a lot of applications: Gmail, Twitter, Facebook, SMS
But I don't want to display the Facebook option. Is this possible?
Or is it possible to add custom code when I click on the Facebook item? Like displaying an alertDialog etc
Try send the url like this:
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setData(Uri.parse("http://www.google.com"));
intent.putExtra(Intent.EXTRA_TEXT, message);
You can
use the PackageManager to resolve the intent,
get the list of candidate applications,
exclude Facebook from that list
create the activity picker yourself with this updated list
This would be the exact opposite of Android Intent for Twitter application

Showing only email apps in chooser when starting an activity with ACTION_SEND intent

when starting an activity with ACTION_SEND intent I get a menu with gmail, facebook, bluetooth... How can I get only email apps in this menu?
Thanks
Intent intent = new Intent(android.content.Intent.ACTION_SEND);
intent .putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{email});
intent.setType("text/plain");
startActivity(intent);
have you tried action ACTION_SENDTO and setting your email as a data? http://developer.android.com/reference/android/content/Intent.html#ACTION_SENDTO
You always also can use explicit call of needed activity.
Use
ACTION_SENDTO instead of ACTION_SEND

how to show activity chooser menu when dialing in android?

I am trying to show activity chooser menu when dialing a number. Following code works for me when sending an email (from real phone,doesn't work in emulator):
/* Create the Intent */
final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
/* Fill it with Data */
emailIntent.setType("plain/text");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{"to#email.com"});
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Subject");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "Text");
/* Send it off to the Activity-Chooser */
this.startActivity(Intent.createChooser(emailIntent, "Send mail..."));
But when I change the code as:
Intent call = new Intent(android.content.Intent.ACTION_CALL);
call.setData(Uri.parse("tel:" + phoneNo));
this.startActivity(Intent.createChooser(call, "Hello there..."));
No activity chooser menu is shown, just straight dial. I also want to list skype in that menu. Do you have any idea?
As someone else answered in one of your previous questions, you really do need to read up on Intents and Filters. I'll give you a quick explanation though. An Intent is a type of message that Android applications can register to handle. If Skype is not installed, then it won't be able to register for that Intent and so won't show up in that menu. If it is installed and still doesn't show up, that means it's not registered for that Intent. I don't know the Android Skype app, but judging from the picture you linked in the other question, it seems that it does register for that Intent and will show up when installed.

Categories

Resources