I am trying to send and Intent.ACTION_SEND on click of a notification. This is what I have done
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);
}
I get the share action on the notification but when i click it i a dialog box that says
No Apps can perform this action
When I run the same intent via startActivity() it works fine.
Can somebody help me out here?
You failed to specify a MIME type on the Intent, using setType(). Try adding that and see if it helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With