这个bug比较坑,今天在测消息通知,要传几个参数,但是怎么都传不过去,最后搜了一下问题居然出在了这儿:
/**
* Retrieve a PendingIntent that will start a new activity, like calling
* {@link Context#startActivity(Intent) Context.startActivity(Intent)}.
* Note that the activity will be started outside of the context of an
* existing activity, so you must use the {@link Intent#FLAG_ACTIVITY_NEW_TASK
* Intent.FLAG_ACTIVITY_NEW_TASK} launch flag in the Intent.
*
* <p class="note">For security reasons, the {@link android.content.Intent}
* you supply here should almost always be an <em>explicit intent</em>,
* that is specify an explicit component to be delivered to through
* {@link Intent#setClass(android.content.Context, Class) Intent.setClass}</p>
*
* @param context The Context in which this PendingIntent should start
* the activity.
* @param requestCode Private request code for the sender
* @param intent Intent of the activity to be launched.
* @param flags May be {@link #FLAG_ONE_SHOT}, {@link #FLAG_NO_CREATE},
* {@link #FLAG_CANCEL_CURRENT}, {@link #FLAG_UPDATE_CURRENT},
* or any of the flags as supported by
* {@link Intent#fillIn Intent.fillIn()} to control which unspecified parts
* of the intent that can be supplied when the actual send happens.
* @param options Additional options for how the Activity should be started.
* May be null if there are no options.
*
* @return Returns an existing or new PendingIntent matching the given
* parameters. May return null only if {@link #FLAG_NO_CREATE} has been
* supplied.
*/
public static PendingIntent getActivity(Context context, int requestCode,
Intent intent, @Flags int flags)
由于根本就没往这方面想问题,结果废了相当长的时间。。。。。。好衰啊啊啊啊啊啊啊啊啊啊!
。。。。。。。。。。。。。。。。。。。。。
http://stackoverflow.com/questions/3009059/android-pending-intent-notification-problem
当发出多个通知时,需要区分requestCode,不然会认为是同一个notification,于是就不再更新参数。。。。。
还悲哀啊!我这一次都没传成功!哪怕成功一次也有点思路啊!好吧!这个问题是记清了。再也不犯了。
版权声明:本文为dabaoonline原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。