public static PendingIntent getActivity (Context context, int requestCode, Intent intent, int flags) was
added in 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.
Parameters:
context - The Context in which this PendingIntent should start the activity.
requestCode - Private request code for the sender
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.
1. Declare a PendingIntent named myPendingIntent.
2. Add the below line to the onCreate method. This will set a PendingIntent named myPendingIntent.
myPendingIntent = PendingIntent.getActivity(this, 0, myIntent, 0);
3. Compile and run!
Resources:
http://developer.android.com/reference/android/app/PendingIntent.html
http://stackoverflow.com/questions/16963522/dealing-with-notifications-on-api-10-in-android
Showing posts with label PendingIntent. Show all posts
Showing posts with label PendingIntent. Show all posts
How to Declare a PendingIntent
PendingIntent was added in API Level 1
A description of an Intent and target action to perform with it. Instances of this class are created with getActivity(Context, int, Intent, int), getActivities(Context, int, Intent[], int),getBroadcast(Context, int, Intent, int), and getService(Context, int, Intent, int); the returned object can be handed to other applications so that they can perform the action you described on your behalf at a later time.
1. In the MainActivity.java file, add the below line to the import section.
import android.app.PendingIntent;
2. Add the below line to the onCreate method. This will declare a PendingIntent named myPendingIntent.
PendingIntent myPendingIntent;
3. Compile and run!
Next Recommended Article: How to Set a PendingIntent with getActivity
Resources:
http://developer.android.com/reference/android/app/PendingIntent.html
A description of an Intent and target action to perform with it. Instances of this class are created with getActivity(Context, int, Intent, int), getActivities(Context, int, Intent[], int),getBroadcast(Context, int, Intent, int), and getService(Context, int, Intent, int); the returned object can be handed to other applications so that they can perform the action you described on your behalf at a later time.
1. In the MainActivity.java file, add the below line to the import section.
import android.app.PendingIntent;
2. Add the below line to the onCreate method. This will declare a PendingIntent named myPendingIntent.
PendingIntent myPendingIntent;
3. Compile and run!
Next Recommended Article: How to Set a PendingIntent with getActivity
Resources:
http://developer.android.com/reference/android/app/PendingIntent.html
Subscribe to:
Posts (Atom)
Popular Posts
- android:ellipsize - Add an ellipsis(...) in a TextView
- Save LogCat to a Text File
- Solution: error: Error parsing XML: unbound prefix
- Perform an Action after Enter keypress on EditText
- Intent setType(String type) - How to Set an Explicit MIME data type
- Cursor getColumnIndex - Get the Index for a Column Name
- android:nextFocusRight - Set the Next Focus Right to a TextView/EditText
- android:textColorHint - Set the Color of Hint Text in TextView/EditText
- android:nextFocusDown - Set Next Focus to a TextView/EditText
- Determine the Hex value for a color