我想从我的应用程序共享多个图像到其他应用程序。在Android的开发者页面上,我发现:来自intentservice的Android共享意图
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND_MULTIPLE);
shareIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, SavedImages);
shareIntent.setType("image/*");
startActivity(Intent.createChooser(shareIntent, "Share images to.."));
如何从intentservice中使用此代码? 当使用从intentservice示例代码,我的应用程序崩溃与logcat的错误:
Calling startActivity from outside of an Activity context requires the flag FLAG_ACTIVITY_NEW_TASK
所以我添加
shareIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
,但我仍然得到同样的错误,我的应用程序崩溃。
如何从intentservice中使用共享意图?
- 你不知道现在是否适合弹出一个活动,因为当你的IntentService在后台工作时,用户可能不会做其他事情。 – CommonsWare
我知道用户可以做其他事情,但我仍想使用代码... – wildcat