I would like to give my users the option of sharing the text of a notification that my app produces to other apps.
Below is the code that I have attempted, but does not result in any success. It does open the "share via" screen when I click the share button on the notification, but the text that is shared that appears from "Intent.EXTRA_TEXT" makes no sense. If I do a Log check on what "sShare" is, then it shows me the correct string.
Please assist in anyway that you can.
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);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.