WEB开发网      濠电娀娼ч崐濠氬疾椤愶附鍋熸い鏍ㄧ〒闂勫嫰鏌﹀Ο渚Ц闁诲氦顕ч湁婵犲﹤楠告禍鍓х磼鏉堛劌绗氶柟宄版嚇閹晠宕归銈嗘濠电偞鍨堕幐鎾磻閹捐秮褰掓偐閻戞﹩妫勯梺鎼炲妼鐎涒晝绮嬪澶樻晝闁挎繂鏌婇敃鍌涚厵閻庢稒锚閻忥絾绻濇繝鍐ㄧ伌闁诡垰鍟村畷鐔碱敂閸♀晙绱樺┑鐐差嚟婵儳螞閸曨剚鍙忛柍鍝勬噹缁€澶嬬箾閹存繄锛嶆鐐灲閹綊宕惰濡插鏌涢妸銉ヮ劉缂佸倸绉归弫鎾绘晸閿燂拷 ---闂備焦瀵уú鈺呭箯閿燂拷
开发学院手机开发Android 开发 一个Android SDK文档PendingIntent的问题 阅读

一个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 1R

发现了一个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.

大家一定注意!!!

Tags:一个 Android SDK

编辑录入:coldstar [复制链接] [打 印]
赞助商链接