PendingIntent android.app.PendingIntent.getActivity的使用

PendingIntent android.app.PendingIntent.getActivity(Context context, int requestCode, Intent intent, int flags)

 

public static PendingIntent getActivity (Context context, int requestCode, Intent intent, int flags)

Since: API Level 1

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.

找到一个PendingIntent用来开始启动一个新的activity,类似于调用Context.startActivity(Intent),注意这个Activity将在当前存在的Activity外部启动,你必须使用Intent中的Intent.FLAG_ACTIVITY_NEW_TASK标志登陆这个Acitivity.

 

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.

例如:

PendingIntent contentIntent = PendingIntent.getActivity(this, 0,

        new Intent(this, NotifyingController.class), 0);

 

// Set the info for the views that show in the notification panel.

notification.setLatestEventInfo(this, getText(R.string.status_bar_notifications_mood_title),

               text, contentIntent);

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值