Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to launch a new activity using pending intent [closed]

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

like image 349
Ashish Augustine Avatar asked Oct 25 '11 22:10

Ashish Augustine


People also ask

What is pending intent were do we use pending intent?

A PendingIntent itself is simply a reference to a token maintained by the system describing the original data used to retrieve it. This means that, even if its owning application's process is killed, the PendingIntent itself will remain usable from other processes that have been given it.

How do I intent my second activity?

The following code demonstrates how you can start another activity via an intent. # Start the activity connect to the # specified class Intent i = new Intent(this, ActivityTwo. class); startActivity(i); Activities which are started by other Android activities are called sub-activities.


1 Answers

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

like image 65
sparksalot Avatar answered Dec 05 '22 04:12

sparksalot