我正在尝试通过单击通知发送 Intent.ACTION_SEND。这就是我所做的
public static void generateNotification(Context context, String title, String message)
{
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
Builder notificationBuilder = new Notification.Builder(context)
.setContentTitle(title)
.setContentText(message)
.setSmallIcon(R.drawable.ic_launcher)
.setWhen(System.currentTimeMillis());
Intent shareIntent = new Intent(Intent.ACTION_SEND);
String extraText = title + " has " + message;
shareIntent.putExtra(Intent.EXTRA_TEXT, extraText);
PendingIntent pendingShareIntent = PendingIntent.getActivity(context, 0, Intent.createChooser(shareIntent, "share..."),
PendingIntent.FLAG_UPDATE_CURRENT);
notificationBuilder.addAction(android.R.drawable.ic_menu_share, "share...", pendingShareIntent);
Notification bigTextNotification = new Notification.BigTextStyle(notificationBuilder)
.setBigContentTitle(title)
.bigText(message)
.build();
notificationManager.notify(tag, notificationId++, bigTextNotification);
}
我在通知上获得了共享操作,但是当我单击它时,显示对话框
没有应用程序可以执行此操作
当我通过 startActivity() 运行相同的意图时,它工作正常。
有人可以帮我吗?