[英]Share an android notification to whatsapp/email/other 3rd party apps
我想讓我的用戶選擇將我的應用生成的通知文本分享給其他應用。
下面是我嘗試過的代碼,但沒有成功。 當我單擊通知上的共享按鈕時,它確實打開了“共享方式”屏幕,但是從“Intent.EXTRA_TEXT”中出現的共享文本沒有任何意義。 如果我對“sShare”是什么進行日志檢查,那么它會顯示正確的字符串。
請盡可能提供幫助。
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, sShare);
sendIntent.setType("text/plain");
PendingIntent sendPendingIntent = PendingIntent.getActivity(context, 0, sendIntent, 0);
mBuilder.setSmallIcon(R.drawable.ic_launcher);
mBuilder.setContentTitle("Title");
mBuilder.setContentText(sOther);
mBuilder.setVisibility(NotificationCompat.VISIBILITY_PUBLIC);
mBuilder.addAction(R.drawable.share, "Share", sendPendingIntent);
mBuilder.setContentIntent(pendingIntent);
PendingIntent sendPendingIntent = PendingIntent.getActivity(context, 0, sendIntent, PendingIntent.FLAG_UPDATE_CURRENT);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.