Register PendingIntents
A PendingIntent instance can be obtained using the factory methods PendingIntent.getActivity (), PendingIntent.getService (), PendingIntent.getBroadcast ().
, PendingIntent, ActivityManager PendingIntent cache/meta data, . , , .
,
public static PendingIntent getActivity(Context context, int requestCode,
Intent intent, int flags) {
String packageName = context.getPackageName();
String resolvedType = intent != null ? intent.resolveTypeIfNeeded(
context.getContentResolver()) : null;
try {
intent.setAllowFds(false);
IIntentSender target =
ActivityManagerNative.getDefault().getIntentSender(
IActivityManager.INTENT_SENDER_ACTIVITY, packageName,
null, null, requestCode, new Intent[] { intent },
resolvedType != null ? new String[] { resolvedType } : null, flags);
return target != null ? new PendingIntent(target) : null;
} catch (RemoteException e) {
}
return null;
}
:
PendingIntent
:
public void cancel() {
try {
ActivityManagerNative.getDefault().cancelIntentSender(mTarget);
} catch (RemoteException e) {
}
}
, PendingIntent . , , ActivityManager PendingIntent / , PendingIntent.
PendingIntent FLAG_NO_CREATE, null.
PendingIntent AlarmManager
AlarmManager , , , PendingIntent / IAlarmManager , , Android, ActivityManager.
public void cancel(PendingIntent operation) {
try {
mService.remove(operation); IAlarmManager instance
} catch (RemoteException ex) {
}
}
AlarmManager , PendingIntent, AlarmManager .
, .