在服务类中分享意图



我在我的应用程序中使用共享按钮的 Service打开共享意图:

Intent dialogIntent = new Intent(android.content.Intent.ACTION_SEND);
dialogIntent.addCategory(Intent.CATEGORY_LAUNCHER);
dialogIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
dialogIntent.setType("text/plain");
dialogIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, ytf.getTitle());
startActivity(dialogIntent);

它是从我的服务类中调用的,我得到了此Exception

Caused by: java.lang.RuntimeException: Unable to start service com.services.BackgroundPlayerService@95236fd with Intent { cmp=com.dev/com.services.BackgroundPlayerService launchParam=MultiScreenLaunchParams { mDisplayId=0 mFlags=0 } (has extras) }: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.SEND cat=[android.intent.category.LAUNCHER] typ=text/plain flg=0x10000001 launchParam=MultiScreenLaunchParams { mDisplayId=0 mFlags=0 } clip={text/plain T:Watch "CHVRCHES - Get Out (Preview)"

任何想法问题在哪里?

任何想法在哪里?

删除此行:

dialogIntent.addCategory(Intent.CATEGORY_LAUNCHER);

最新更新