我使用下面的代码来分享其他应用程序的照片并打印他们的包名:
Intent sharingIntent = new Intent(Intent.ACTION_SEND);
sharingIntent.setType("image/jpeg");
sharingIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(FilePath));
PackageManager packageManager = this.getPackageManager();
List<ResolveInfo> resolveInfo = packageManager.queryIntentActivities(sharingIntent, PackageManager.MATCH_DEFAULT_ONLY);
int i = 0;
while(i < resolveInfo.size()) {
System.out.println(i + " " + resolveInfo.get(i).activityInfo.packageName);
i++;
}
startActivity(Intent.createChooser(sharingIntent, "Share");
并获得以下9个可以分享照片的包名:
06-19 16:55:22.460: I/System.out(13020): 0 com.amazon.kindle
06-19 16:55:22.460: I/System.out(13020): 1 com.android.bluetooth
06-19 16:55:22.460: I/System.out(13020): 2 com.google.android.apps.uploader
06-19 16:55:22.460: I/System.out(13020): 3 com.ecareme.asuswebstorage
06-19 16:55:22.460: I/System.out(13020): 4 com.google.android.talk
06-19 16:55:22.460: I/System.out(13020): 5 com.google.android.gm
06-19 16:55:22.460: I/System.out(13020): 6 com.aripollak.picturemap
06-19 16:55:22.460: I/System.out(13020): 7 com.instagram.android
06-19 16:55:22.460: I/System.out(13020): 8 com.facebook.katana
如果我想在选择应用程序时过滤一些应用程序。
例如,我想从共享应用列表中过滤 facebook 应用。
我怎么能dd?