Solved. This question was resolved by Diego D.
This code launch a Notification by a function: Notification(final String mytext). We get that Notification with ticker, title, text, autocancel,... when tap on it, run other function: My_Function(mytext);
To work, it doesn't need modify AndroidManifest because use Broadcasts.
public void Notification(final String mytext) {
final Intent notifIntent = new Intent("action_call_method");
PendingIntent pendingmyIntent = PendingIntent.getBroadcast(context, 0, notifIntent, PendingIntent.FLAG_UPDATE_CURRENT);
BroadcastReceiver receiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals("action_call_method")) {
My_Function(mytext);
}
}
};
IntentFilter filter = new IntentFilter("action_call_method");
context.registerReceiver(receiver, filter);
Notification noti = new Notification.Builder(context)
.setTicker(ticker)
.setContentTitle(title)
.setContentText(text)
.setSmallIcon(R.drawable.ic_lock_silent_mode_off)
.setDefaults(Notification.DEFAULT_VIBRATE | Notification.DEFAULT_SOUND | Notification.FLAG_SHOW_LIGHTS)
.setAutoCancel(true)
.setContentIntent(pendingmyIntent)
.build();
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(0, noti);
}