1

In my app i am sending WAV file as attachment in email.while showing the email chooser the Indent.createChooser intent will list the email,gmail,facebook,skype,bluetooth and other unnecessary option it. i want to show only the Email and Gmail option. i do not know how to do that? Before you its possibly duplicate question i saw the following link and its does not help me.

  1. How to send recorded voice in email?
  2. Android Intent Chooser to only show E-mail option

As told in the above links i have tried sendIntent.setType("audio/rfc822");. Again it is display the same.

my code sample:

    Intent sendIntent = new Intent(Intent.ACTION_SEND);
    sendIntent.putExtra(Intent.EXTRA_SUBJECT, "xxxxxxxxxxxx");
    sendIntent.putExtra(Intent.EXTRA_STREAM,Uri.parse("file://" + f.getAbsolutePath())); 
    sendIntent.setType("audio/wav");
    startActivity(Intent.createChooser(sendIntent, "Email file"));

Updated Question:

i have implemented a sample with listing installed app and click item on the list view i will launch the Gmail / Email app: it is says "No Application can perform this operation".

To list the app in the list view:

-----------------
List<PackageInfo> packs = packageManager.getInstalledPackages(0);
  for(int i = 0; i < packs.size(); i++) {
     PackageInfo p = packs.get(i);
     ApplicationInfo a = p.applicationInfo;
     if ((includeSysApps) && ((a.flags & ApplicationInfo.FLAG_SYSTEM) == 1)) {
        continue;
     }
     App app = new App();
     app.setTitle(p.applicationInfo.loadLabel(packageManager).toString());
     app.setPackageName(p.packageName);
     app.setVersionName(p.versionName);
     app.setVersionCode(p.versionCode);
     app.setInstallDir(p.applicationInfo.sourceDir);
     app.setInstallSize(calculateSize(app.getInstallDir()));
     CharSequence description = p.applicationInfo.loadDescription(packageManager);
     app.setDescription(description != null ? description.toString() : "");
     apps.add(app);
     -----------

and in the onclick item event is:

                Intent sendIntent = new Intent(getPackageManager().getLaunchIntentForPackage(app.getPackageName()));
                sendIntent.putExtra(Intent.EXTRA_SUBJECT, "xxxxxxxxxxxx");
                sendIntent.putExtra(Intent.EXTRA_STREAM,Uri.parse("file://" + Environment.getExternalStorageDirectory().getPath()+"/Music/SalsaFav.mp3")); 
                sendIntent.setType("audio/wav");
                startActivity(Intent.createChooser(sendIntent, "Email file"));

please help me.

Community
  • 1
  • 1
M.A.Murali
  • 9,988
  • 36
  • 105
  • 182
  • I have already answered this question. Check it out here. http://stackoverflow.com/questions/6255915/android-intent-chooser-to-only-show-e-mail-option – Pedro Varela Dec 05 '16 at 19:53

2 Answers2

0

You probably need to create your own pop-up activity and send the intent to that activity. Now in that pop-up activity You need to list the communication channels you prefer. On the click to any of the communication channel you pop-up activity should start the relevant activity. Other thing you can look at is this post which will show you some light on how to get your work done :)

Community
  • 1
  • 1
Saurabh
  • 7,894
  • 2
  • 23
  • 31
0

You have two choices :

  • Use the PackageManager with queryIntentActivities function, filter from that and display you own Dialog

Here you get the applications which can actually handle your Intent :

Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_SUBJECT, "xxxxxxxxxxxx");
sendIntent.putExtra(Intent.EXTRA_STREAM,Uri.parse("file://" + f.getAbsolutePath())); 
sendIntent.setType("audio/wav");

// Get the Activities which can handle the Intent
List<ResolveInfo> resolveInfos = getPackageManager().queryIntentActivities(sendIntent, 0);

// Loop on your Activities, filter and construct your own list here
if (!resolveInfos.isEmpty()){
  for (ResolveInfo resolveInfo : resolveInfos) {
  // Filter here !

  }
}
  • Query yourself the PackageManager with a list of known package name with getApplicationInfo and build you Dialog according to the existing applications

I think the first solution best matchs your needs

Plumillon Forge
  • 1,659
  • 1
  • 16
  • 31
  • please see my updated question. I have implemented a sample app with list all installed apps on listview and click the app it open the app. but i get "No application can perform this action" please help me. – M.A.Murali Sep 03 '12 at 13:44
  • Try to set the type to "****/****", the application you're clicking on doesn't seems to handle the "audio/wav" – Plumillon Forge Sep 03 '12 at 14:56
  • You're planning to do that in the wrong side. Android got a beautifull system which is Intent, when you startActivty with an Intent, you basically tell him "Get all the apps which can handle this". In your example, you do the inverse, you tell an app to handle an Intent which you don't know if it can. So you have to grab the apps which actually can and filter this list after, I'll update my answerto show you – Plumillon Forge Sep 06 '12 at 09:10