Notification中Intent携带数据重复问题
Notification中多个Intent使用putExtra方法携带数据,在目的activity中通过getIntent方法取出传递数据时,有时候会发现取出来的数据都是第一次putExtra中放入的数据。
下面看下代码,比较简单:
PendingIntent android.app.PendingIntent.getActivity(Context context, int requestCode, Intent intent, int flags)Retrieve a PendingIntent that will start a new activity, like calling Context.startActivity(Intent). Note that the activity will be started outside of the context of an existing activity, so you must use the Intent.FLAG_ACTIVITY_NEW_TASK launch flag in the Intent.Parameters:context The Context in which this PendingIntent should start the activity.requestCode Private request code for the sender (currently not used).intent Intent of the activity to be launched.flags May be FLAG_ONE_SHOT, FLAG_NO_CREATE, FLAG_CANCEL_CURRENT, FLAG_UPDATE_CURRENT, or any of the flags as supported by Intent.fillIn() to control which unspecified parts of the intent that can be supplied when the actual send happens.Returns:Returns an existing or new PendingIntent matching the given parameters. May return null only if FLAG_NO_CREATE has been supplied.
关于该方法的详细概述,敬请查看后面关于notification的源码解析,打算在周末的时候看一下notification源码,那个时候再详细分析下。