Notification Shows Empty Activity

I wrote a notice in my project that before showing the alert, it saves the values ​​in general preferences. This works when the app is open and displays information and my values ​​in action, but it doesn't work when the app is closed and the app is closed and notified. Shows up and I clicked on it, it shows that the action is empty. I load the generic Pref in Oncreate of the Activity should show ... but it is empty ... please help me and when I click the Back Button It Crashed ... my notification code. it stores the value and shows a notification ...

@Override
public void onSuccesResponse(JSONArray responseArray) throws JSONException {
    if (responseArray.length() > 0) {
        sharedPref = new SharedPref(apiManager.customer, apiManager.requesting, context);
        if (!G.onecNotify) {
            sharedPref.saveRequestData();
            sharedPref.loadRequestData();
            showNotification();
            G.notificationShown = true;
            requestListener.onResponseRequest(apiManager);
        }
    }
}

      

my main notification codes

   private void showNotification() {
    G.onecNotify = true;
    String[] infoToShow = new String[2];
    String sourceAddress = "  آدرس مبدا :" + apiManager.requesting.getSourceAddress();
    String destinetionAddress = " آدرس مقصد :" + apiManager.requesting.getDestinationAddress();
    String contentNotification = "";
    infoToShow[0] = sourceAddress;
    infoToShow[1] = destinetionAddress;
    for (int i = 0; i < infoToShow.length; i++) {
        contentNotification += infoToShow[i] + "\n\n";
    }
    Intent intent = new Intent(context, RequestManagementActivity.class);
    Intent stackIntent = new Intent(context, MainAccountActivity.class);
    //PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, Intent.FLAG_ACTIVITY_NEW_TASK);
    PendingIntent pendingIntent = TaskStackBuilder.create(G.context)
            .addNextIntentWithParentStack(stackIntent)
            .addNextIntent(intent)
            .getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
    NotificationCompat.Builder builder = (NotificationCompat.Builder) new NotificationCompat.Builder(context)
            .setSmallIcon(R.drawable.whistle)
            .setContentTitle("شما درخواست ارسال بسته دارید")
            .setContentIntent(pendingIntent)
            .setColor(Color.parseColor("#ef9a9a"))
            .setDefaults(Notification.DEFAULT_VIBRATE | Notification.DEFAULT_SOUND | Notification.FLAG_SHOW_LIGHTS)
            .setLights(Color.parseColor("#e91e63"), 1, 1)
            .setStyle(new NotificationCompat.BigTextStyle().bigText(contentNotification))
            .setContentText(contentNotification);
    NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
    mNotificationManager.notify(1, builder.build());
}

      

and my activity should show. this is the load value and is set in my action controls

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_request_management);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    setTitle("");
    if (G.notificationShown) {
        apiManager = new ApiManager();
        sharedPref = new SharedPref(apiManager.customer, apiManager.requesting, G.context);
        sharedPref.loadCustomerData();
        sharedPref.loadRequestData();
        init();
        setControls();
    }
}

      

whwn app close it show activity empty..i need your help please help me ... :(

+3


source to share





All Articles