【发布时间】:2015-10-06 04:16:55
【问题描述】:
想使用 Android Intent.ACTION_SEND 快速分享内容。我写了一些代码,我可以显示自定义剪切对话框 但我想检查 Intent.ACTION_SEND 中选择的意图,例如,如果我从 Gmail 发送一些文件,我想显示 Toast 消息(从 Gmail 等发送的消息) 这是我的来源
PackageManager pm = mActivity.getPackageManager();
Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND);
shareIntent.setType("image/jpeg");
Uri photoUri = Uri.parse(path);
shareIntent.putExtra(Intent.EXTRA_TEXT, "Downloading your app");
shareIntent.putExtra(Intent.EXTRA_STREAM, photoUri);
List<ResolveInfo> activityList = pm.queryIntentActivities(shareIntent, 0);
for (final ResolveInfo app : activityList)
{
Log.e("Application pachage",app.activityInfo.name +"package");
if ((app.activityInfo.name).contains("Bluetooth"))
{
Log.e("Application pachage","mee" +"package");
Toast.makeText(mActivity,"Message sent from Bluetooth",Toast.LENGTH_SHORT).show();
final ActivityInfo activity = app.activityInfo;
final ComponentName name = new ComponentName(activity.applicationInfo.packageName, activity.name);
shareIntent.addCategory(Intent.CATEGORY_LAUNCHER);
shareIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
shareIntent.setComponent(name);
mActivity.startActivity(shareIntent);
break;
}
}
那么,有可能吗?
【问题讨论】:
标签: android android-intent android-bluetooth