Class ShadowPendingIntent
- java.lang.Object
-
- org.robolectric.shadows.ShadowPendingIntent
-
@Implements(android.app.PendingIntent.class) public class ShadowPendingIntent extends Object
-
-
Constructor Summary
Constructors Constructor Description ShadowPendingIntent()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected static void__staticInitializer__()booleancallLastOnFinished(Intent intent, int resultCode, String resultData, Bundle resultExtras)protected voidcancel()booleanequals(Object o)protected static PendingIntentgetActivities(Context context, int requestCode, Intent[] intents, int flags)protected static PendingIntentgetActivities(Context context, int requestCode, Intent[] intents, int flags, Bundle options)protected static PendingIntentgetActivity(Context context, int requestCode, Intent intent, int flags)protected static PendingIntentgetActivity(Context context, int requestCode, Intent intent, int flags, Bundle options)protected static PendingIntentgetBroadcast(Context context, int requestCode, Intent intent, int flags)protected StringgetCreatorPackage()protected intgetCreatorUid()intgetFlags()protected static PendingIntentgetForegroundService(Context context, int requestCode, Intent intent, int flags)protected IntentSendergetIntentSender()BundlegetOptions()intgetRequestCode()ContextgetSavedContext()IntentgetSavedIntent()This returns the last Intent in the Intent[] to be delivered when the PendingIntent is sent.Intent[]getSavedIntents()This method is particularly useful for PendingIntents created with multiple Intents:getActivities(Context, int, Intent[], int)getActivities(Context, int, Intent[], int, Bundle)protected static PendingIntentgetService(Context context, int requestCode, Intent intent, int flags)protected StringgetTargetPackage()inthashCode()booleanisActivity()Returnstrueif thisPendingIntentwas created withgetActivity(android.content.Context, int, android.content.Intent, int)orgetActivities(android.content.Context, int, android.content.Intent[], int).booleanisActivityIntent()Deprecated.preferisActivity()which was added toPendingIntentin API 31 (Android S).booleanisBroadcast()Returnstrueif thisPendingIntentwas created withgetBroadcast(android.content.Context, int, android.content.Intent, int).booleanisBroadcastIntent()Deprecated.preferisBroadcast()which was added toPendingIntentin API 31 (Android S).booleanisCanceled()booleanisForegroundService()Returnstrueif thisPendingIntentwas created withgetForegroundService(android.content.Context, int, android.content.Intent, int).booleanisForegroundServiceIntent()Deprecated.preferisForegroundService()which was added toPendingIntentin API 31 (Android S).booleanisImmutable()booleanisService()Returnstrueif thisPendingIntentwas created withgetService(android.content.Context, int, android.content.Intent, int).booleanisServiceIntent()Deprecated.preferisService()which was added toPendingIntentin API 31 (Android S).static PendingIntentreadPendingIntentOrNullFromParcel(Parcel in)static voidreset()protected voidsend()protected voidsend(int code)protected voidsend(int code, PendingIntent.OnFinished onFinished, Handler handler)protected voidsend(Context context, int code, Intent intent)protected voidsend(Context context, int code, Intent intent, PendingIntent.OnFinished onFinished, Handler handler)protected voidsend(Context context, int code, Intent intent, PendingIntent.OnFinished onFinished, Handler handler, String requiredPermission)protected voidsend(Context context, int code, Intent intent, PendingIntent.OnFinished onFinished, Handler handler, String requiredPermission, Bundle options)voidsetCreatorPackage(String creatorPackage)voidsetCreatorUid(int uid)static voidwritePendingIntentOrNullToParcel(PendingIntent sender, Parcel out)protected voidwriteToParcel(Parcel out, int flags)
-
-
-
Method Detail
-
__staticInitializer__
@Implementation protected static void __staticInitializer__()
-
getActivity
@Implementation protected static PendingIntent getActivity(Context context, int requestCode, Intent intent, int flags)
-
getActivity
@Implementation protected static PendingIntent getActivity(Context context, int requestCode, Intent intent, int flags, Bundle options)
-
getActivities
@Implementation protected static PendingIntent getActivities(Context context, int requestCode, Intent[] intents, int flags)
-
getActivities
@Implementation protected static PendingIntent getActivities(Context context, int requestCode, Intent[] intents, int flags, Bundle options)
-
getBroadcast
@Implementation protected static PendingIntent getBroadcast(Context context, int requestCode, Intent intent, int flags)
-
getService
@Implementation protected static PendingIntent getService(Context context, int requestCode, Intent intent, int flags)
-
getForegroundService
@Implementation(minSdk=26) protected static PendingIntent getForegroundService(Context context, int requestCode, Intent intent, int flags)
-
cancel
@Implementation protected void cancel()
-
send
@Implementation protected void send() throws PendingIntent.CanceledException- Throws:
PendingIntent.CanceledException
-
send
@Implementation protected void send(int code) throws PendingIntent.CanceledException- Throws:
PendingIntent.CanceledException
-
send
@Implementation protected void send(int code, PendingIntent.OnFinished onFinished, Handler handler) throws PendingIntent.CanceledException- Throws:
PendingIntent.CanceledException
-
send
@Implementation protected void send(Context context, int code, Intent intent) throws PendingIntent.CanceledException
- Throws:
PendingIntent.CanceledException
-
send
@Implementation protected void send(Context context, int code, Intent intent, PendingIntent.OnFinished onFinished, Handler handler) throws PendingIntent.CanceledException
- Throws:
PendingIntent.CanceledException
-
send
@Implementation protected void send(Context context, int code, Intent intent, PendingIntent.OnFinished onFinished, Handler handler, String requiredPermission) throws PendingIntent.CanceledException
- Throws:
PendingIntent.CanceledException
-
send
@Implementation(minSdk=23) protected void send(Context context, int code, Intent intent, PendingIntent.OnFinished onFinished, Handler handler, String requiredPermission, Bundle options) throws PendingIntent.CanceledException
- Throws:
PendingIntent.CanceledException
-
getIntentSender
@Implementation protected IntentSender getIntentSender()
-
isActivity
@Implementation(minSdk=31) public boolean isActivity()
Returnstrueif thisPendingIntentwas created withgetActivity(android.content.Context, int, android.content.Intent, int)orgetActivities(android.content.Context, int, android.content.Intent[], int).This method is intentionally left
publicrather thanprotectedbecause it serves a secondary purpose as a utility shadow method for API levels < 31.
-
isBroadcast
@Implementation(minSdk=31) public boolean isBroadcast()
Returnstrueif thisPendingIntentwas created withgetBroadcast(android.content.Context, int, android.content.Intent, int).This method is intentionally left
publicrather thanprotectedbecause it serves a secondary purpose as a utility shadow method for API levels < 31.
-
isForegroundService
@Implementation(minSdk=31) public boolean isForegroundService()
Returnstrueif thisPendingIntentwas created withgetForegroundService(android.content.Context, int, android.content.Intent, int).This method is intentionally left
publicrather thanprotectedbecause it serves a secondary purpose as a utility shadow method for API levels < 31.
-
isService
@Implementation(minSdk=31) public boolean isService()
Returnstrueif thisPendingIntentwas created withgetService(android.content.Context, int, android.content.Intent, int).This method is intentionally left
publicrather thanprotectedbecause it serves a secondary purpose as a utility shadow method for API levels < 31.
-
isImmutable
@Implementation(minSdk=31) public boolean isImmutable()
Returnstrueif thisPendingIntentis marked withPendingIntent.FLAG_IMMUTABLE.This method is intentionally left
publicrather thanprotectedbecause it serves a secondary purpose as a utility shadow method for API levels < 31.
-
isActivityIntent
@Deprecated public boolean isActivityIntent()
Deprecated.preferisActivity()which was added toPendingIntentin API 31 (Android S).- Returns:
trueiff sending this PendingIntent will start an activity
-
isBroadcastIntent
@Deprecated public boolean isBroadcastIntent()
Deprecated.preferisBroadcast()which was added toPendingIntentin API 31 (Android S).- Returns:
trueiff sending this PendingIntent will broadcast an Intent
-
isServiceIntent
@Deprecated public boolean isServiceIntent()
Deprecated.preferisService()which was added toPendingIntentin API 31 (Android S).- Returns:
trueiff sending this PendingIntent will start a service
-
isForegroundServiceIntent
@Deprecated public boolean isForegroundServiceIntent()
Deprecated.preferisForegroundService()which was added toPendingIntentin API 31 (Android S).- Returns:
trueiff sending this PendingIntent will start a foreground service
-
getSavedContext
public Context getSavedContext()
- Returns:
- the context in which this PendingIntent was created
-
getSavedIntent
public Intent getSavedIntent()
This returns the last Intent in the Intent[] to be delivered when the PendingIntent is sent. This method is particularly useful for PendingIntents created with a single Intent:- Returns:
- the final Intent to be delivered when the PendingIntent is sent
-
getSavedIntents
public Intent[] getSavedIntents()
This method is particularly useful for PendingIntents created with multiple Intents:- Returns:
- all Intents to be delivered when the PendingIntent is sent
-
isCanceled
public boolean isCanceled()
- Returns:
- iff this PendingIntent has been canceled
-
getRequestCode
public int getRequestCode()
- Returns:
- the request code with which this PendingIntent was created
-
getFlags
public int getFlags()
- Returns:
- the flags with which this PendingIntent was created
-
getOptions
@Nullable public Bundle getOptions()
- Returns:
- the flags with which this PendingIntent was created
-
callLastOnFinished
public boolean callLastOnFinished(Intent intent, int resultCode, String resultData, Bundle resultExtras)
CallsPendingIntent.OnFinished.onSendFinished(android.app.PendingIntent, android.content.Intent, int, java.lang.String, android.os.Bundle)on the lastPendingIntent.OnFinishedpassed withsend().PendingIntent.OnFinished.onSendFinished(android.app.PendingIntent, android.content.Intent, int, java.lang.String, android.os.Bundle)is called on theHandlerpassed withsend()(if any). If noHandlerwas provided it's invoked on the calling thread.- Returns:
- false if no
PendingIntent.OnFinishedcallback was passed with the lastsend()call, true otherwise.
-
getTargetPackage
@Implementation protected String getTargetPackage()
-
getCreatorPackage
@Implementation(minSdk=17) protected String getCreatorPackage()
-
setCreatorPackage
public void setCreatorPackage(String creatorPackage)
-
getCreatorUid
@Implementation(minSdk=17) protected int getCreatorUid()
-
setCreatorUid
public void setCreatorUid(int uid)
-
readPendingIntentOrNullFromParcel
@Implementation @Nullable public static PendingIntent readPendingIntentOrNullFromParcel(Parcel in)
-
writePendingIntentOrNullToParcel
@Implementation public static void writePendingIntentOrNullToParcel(@Nullable PendingIntent sender, Parcel out)
-
writeToParcel
@Implementation protected void writeToParcel(Parcel out, int flags)
-
reset
@Resetter public static void reset()
-
-