在AndroidManifest.xml里去掉下面这段就可以不再分享列表中展示,反之,则在分享列表中展示
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
</intent-filter>
去除本身:
PackageManager packageManager = this.getPackageManager();
List<ResolveInfo> resolveInfo = packageManager.queryIntentActivities(
intent, PackageManager.MATCH_DEFAULT_ONLY);
List<Intent> targetedShareIntents = new ArrayList<Intent>();
if (null != resolveInfo && !resolveInfo.isEmpty()) {
for (ResolveInfo resolve : resolveInfo) {
Intent targeted = new Intent(Intent.ACTION_SEND);
targeted.putExtra(Intent.EXTRA_TEXT, mContent);
targeted.setType("text/plain");
ActivityInfo activityInfo = resolve.activityInfo;
if ("com.suning.notes".equals(activityInfo.packageName)
|| "com.suning.notes".equals(activityInfo.name)) {
continue;
}
targeted.setPackage(activityInfo.packageName);
targetedShareIntents.add(targeted);
}
}
int titleResource = com.android.internal.R.string.whichApplication;
Intent chooseIntent = Intent.createChooser(targetedShareIntents.remove(0), getResources().getText(titleResource));
if (null == chooseIntent) {
return;
}
chooseIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS,
targetedShareIntents.toArray(new Parcelable[] {}));
NotesListActivity.this.startActivity(chooseIntent);