1
I’m having problems in an android app, when trying to send a notification everything happens 100% until you arrive at the opening of the notification Activity.
This call Activity needs a "store" parameter and I am unable to send it via notification.
Look at the sources below:
private void Notify(String notificationTitle, String notificationMessage){
NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
@SuppressWarnings("deprecation")
Notification notification = new Notification(R.drawable.header_logo,"New Message", System.currentTimeMillis());
Intent notificationIntent = new Intent(NewReviewActivity.this,ReviewActivity.class);
notificationIntent.putExtra("store",String.valueOf(store.getStore_id()));
PendingIntent pendingIntent = PendingIntent.getActivity(NewReviewActivity.this, 0, notificationIntent, 0);
notification.vibrate = new long[]{150, 300, 150, 600};
notification.flags = Notification.FLAG_AUTO_CANCEL;
notification.setLatestEventInfo(NewReviewActivity.this, notificationTitle, notificationMessage, pendingIntent);
notificationManager.notify(9999, notification);
}
And my logcat:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.projects.storefinder/com.projects.activities.ReviewActivity}: java.lang.ClassCastException: java.lang.String cannot be cast to com.models.Store
It is clear that the problem is that the parameter is not being properly passed.
Could you help me?
Can you show how you try to get the parameter? Where does the error occur? Thanks!
– Thiago Luiz Domacoski
Of course Thiago, Follow: store = (Store) this.getIntent(). getSerializableExtra("store");
– Ygor Magrii