extras(notification text) doesn't get passed

Saif Ashraf :

the extras ( a notification text) doesn't get passed to the textView, (the text view appears empty), what's the problem? here's the related code:

AlarmReceiver extends BroadcastReceiver : https://textuploader.com/1j851

Notification Activity( that should show the text): https://textuploader.com/1j85j

my main activity: https://textuploader.com/1j8tr

please excuse me if I did any stupid mistakes, I'm new to programming

Ticherhaz :

I guess this is your problem here. You pass the wrong value here. You make an object i but you are using intent object.

    Intent i = new Intent(context,
            NotificationActivity.class);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
            | Intent.FLAG_ACTIVITY_CLEAR_TASK);
    intent.putExtra("message",x);
    PendingIntent pendingIntent = PendingIntent.getActivity(context,0,i,PendingIntent.FLAG_UPDATE_CURRENT);

So use like this below.

    Intent i = new Intent(context,
            NotificationActivity.class);
    i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
            | Intent.FLAG_ACTIVITY_CLEAR_TASK); //i 
    i.putExtra("message",x); //i
    PendingIntent pendingIntent = PendingIntent.getActivity(context,0,i,PendingIntent.FLAG_UPDATE_CURRENT);

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=389404&siteId=1