簡體   English   中英

服務類別中的共享意圖

[英]Share Intent in Service Class

我的應用程序中具有“ 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);

它是從我的Service類調用的,並且得到了這個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);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM