一个Android SDK文档PendingIntent的问题
2010-06-22 02:13:00 来源:WEB开发网发现了一个PendingIntent的一个问题,在SDK文档对几个API描述如下:
public static PendingIntent getActivity (Context context, int requestCode, Intent intent, int flags)
Since: API Level 1Retrieve 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
contextThe Context in which this PendingIntent should start the activity.
requestCodePrivate request code for the sender ( currently not used).
intentIntent of the activity to be launched.
flagsMay 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.
public static PendingIntent getBroadcast (Context context, int requestCode, Intent intent, int flags)
Since: API Level 1Retrieve a PendingIntent that will perform a broadcast, like calling Context.sendBroadcast().
Parameters
contextThe Context in which this PendingIntent should perform the broadcast.
requestCodePrivate request code for the sender (currently not used).
intentThe Intent to be broadcast.
flagsMay 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.
请看 requestCode参数,这里注明了这个参数当前并不使用,实际上这个参数是有用的,当通知同时有很多个的时候,必须指定这个参数来达到唯一识别的效果,仅仅通过notification.notify(id, n);来指定ID是不够的,这样仅能在通知栏上显示唯一,具体点进去的时候使用的intent会是最后一个被加进去的intent.
大家一定注意!!!
- ››Android 当修改一些代码时,使用什么编译命令可以最...
- ››Android 如何添加一个apk使模拟器和真机都编译进去...
- ››Android 修改Camera拍照的默认保存路径
- ››Android 如何修改默认输入法
- ››android开发中finish()和System.exit(0)的区别
- ››Android手势识别简单封装类
- ››android中查看项目数字证书的两种方法
- ››Android中获取IMEI码的办法
- ››android 相机报错 setParameters failed
- ››Android重启运用程序的代码
- ››Android为ListView的Item设置不同的布局
- ››android bitmap与base64字符串的互相转换
更多精彩
赞助商链接