How to launch a new activity using pending intent

2019-04-04 02:20发布

Can anyone please say how to launch a new activity using pending intent and also to pass a value using pending intent. Thanks in advance.

1条回答
Explosion°爆炸
2楼-- · 2019-04-04 02:40
Intent intent = new Intent(getApplicationContext(), ActivityToLaunch.class);
intent.putExtra(<oneOfThePutExtraFunctions>);
PendingIntent pi = PendingIntent.getActivity(this, 0, intent, 0);

You can add extra data into an Intent by using one of the various Intent.PutExtra() functions located: http://developer.android.com/reference/android/content/Intent.html

Then, when you are ready to launch your PendingIntent, use one of the Send() functions located: http://developer.android.com/reference/android/app/PendingIntent.html

查看更多
登录 后发表回答