Android - Use putExtra to pass Object value for PendingIntent Notification Activity
把object传到另个Activity form
1. Add implements Serializable in your class- public class Article implements Serializable { }
复制代码 2. Create object for passing- Intent notificationIntent = new Intent(this,NotifyMessage.class);
- Article oArticle = new Article();
- oArticle.title = splited[0];
- oArticle.url = splited[1];
- notificationIntent.putExtra("Msg",oArticle);
- //For Notification
- PendingIntent oPendingIntent =PendingIntent.getActivity(this, 0,
- notificationIntent,
- PendingIntent.FLAG_UPDATE_CURRENT);
复制代码 2. Get object when opening the activity- Article ArticleObject=(Article)getIntent().getSerializableExtra("Msg");
复制代码 |
|