public abstract class PackageMonitor extends BroadcastReceiver
BroadcastReceiver.PendingResult
Modifier and Type | Field and Description |
---|---|
static int |
PACKAGE_PERMANENT_CHANGE |
static int |
PACKAGE_TEMPORARY_CHANGE |
static int |
PACKAGE_UNCHANGED |
static int |
PACKAGE_UPDATING |
Constructor and Description |
---|
PackageMonitor() |
Modifier and Type | Method and Description |
---|---|
boolean |
anyPackagesAppearing() |
boolean |
anyPackagesDisappearing() |
boolean |
didSomePackagesChange() |
int |
getChangingUserId() |
Handler |
getRegisteredHandler() |
int |
isPackageAppearing(String packageName) |
int |
isPackageDisappearing(String packageName) |
boolean |
isPackageModified(String packageName) |
boolean |
isReplacing() |
void |
onBeginPackageChanges() |
void |
onFinishPackageChanges() |
boolean |
onHandleForceStop(Intent intent,
String[] packages,
int uid,
boolean doit) |
void |
onHandleUserStop(Intent intent,
int userHandle) |
void |
onPackageAdded(String packageName,
int uid)
Called when a package is really added (and not replaced).
|
void |
onPackageAppeared(String packageName,
int reason)
Called when a package appears for any reason.
|
boolean |
onPackageChanged(String packageName,
int uid,
String[] components)
Direct reflection of
Intent.ACTION_PACKAGE_CHANGED being received, informing you of
changes to the enabled/disabled state of components in a package
and/or of the overall package. |
void |
onPackageDataCleared(String packageName,
int uid) |
void |
onPackageDisappeared(String packageName,
int reason)
Called when a package disappears for any reason.
|
void |
onPackageModified(String packageName)
Called when an existing package is updated or its disabled state changes.
|
void |
onPackageRemoved(String packageName,
int uid)
Called when a package is really removed (and not replaced).
|
void |
onPackageRemovedAllUsers(String packageName,
int uid)
Called when a package is really removed (and not replaced) for
all users on the device.
|
void |
onPackagesAvailable(String[] packages) |
void |
onPackagesSuspended(String[] packages) |
void |
onPackagesUnavailable(String[] packages) |
void |
onPackagesUnsuspended(String[] packages) |
void |
onPackageUpdateFinished(String packageName,
int uid) |
void |
onPackageUpdateStarted(String packageName,
int uid) |
void |
onReceive(Context context,
Intent intent)
This method is called when the BroadcastReceiver is receiving an Intent
broadcast.
|
void |
onSomePackagesChanged() |
void |
onUidRemoved(int uid) |
void |
register(Context context,
Looper thread,
boolean externalStorage) |
void |
register(Context context,
Looper thread,
UserHandle user,
boolean externalStorage) |
void |
register(Context context,
UserHandle user,
boolean externalStorage,
Handler handler) |
void |
unregister() |
abortBroadcast, clearAbortBroadcast, getAbortBroadcast, getDebugUnregister, getPendingResult, getResultCode, getResultData, getResultExtras, getSendingUserId, goAsync, isInitialStickyBroadcast, isOrderedBroadcast, peekService, setDebugUnregister, setOrderedHint, setPendingResult, setResult, setResultCode, setResultData, setResultExtras
public static final int PACKAGE_UNCHANGED
public static final int PACKAGE_UPDATING
public static final int PACKAGE_TEMPORARY_CHANGE
public static final int PACKAGE_PERMANENT_CHANGE
public void register(Context context, Looper thread, UserHandle user, boolean externalStorage)
public void register(Context context, UserHandle user, boolean externalStorage, Handler handler)
public Handler getRegisteredHandler()
public void unregister()
public void onBeginPackageChanges()
public void onPackageAdded(String packageName, int uid)
public void onPackageRemoved(String packageName, int uid)
public void onPackageRemovedAllUsers(String packageName, int uid)
public void onPackageUpdateStarted(String packageName, int uid)
public void onPackageUpdateFinished(String packageName, int uid)
public boolean onPackageChanged(String packageName, int uid, String[] components)
Intent.ACTION_PACKAGE_CHANGED
being received, informing you of
changes to the enabled/disabled state of components in a package
and/or of the overall package.packageName
- The name of the package that is changing.uid
- The user ID the package runs under.components
- Any components in the package that are changing. If
the overall package is changing, this will contain an entry of the
package name itself.onSomePackagesChanged()
being called later. If you
return false, no further callbacks will happen about this change. The
default implementation returns true if this is a change to the entire
package.public boolean onHandleForceStop(Intent intent, String[] packages, int uid, boolean doit)
public void onHandleUserStop(Intent intent, int userHandle)
public void onUidRemoved(int uid)
public void onPackagesAvailable(String[] packages)
public void onPackagesUnavailable(String[] packages)
public void onPackagesSuspended(String[] packages)
public void onPackagesUnsuspended(String[] packages)
public void onPackageDisappeared(String packageName, int reason)
public void onPackageAppeared(String packageName, int reason)
public void onPackageModified(String packageName)
public boolean didSomePackagesChange()
public int isPackageAppearing(String packageName)
public boolean anyPackagesAppearing()
public int isPackageDisappearing(String packageName)
public boolean anyPackagesDisappearing()
public boolean isReplacing()
public boolean isPackageModified(String packageName)
public void onSomePackagesChanged()
public void onFinishPackageChanges()
public void onPackageDataCleared(String packageName, int uid)
public int getChangingUserId()
public void onReceive(Context context, Intent intent)
BroadcastReceiver
Context.registerReceiver(BroadcastReceiver,
IntentFilter, String, android.os.Handler)
. When it runs on the main
thread you should
never perform long-running operations in it (there is a timeout of
10 seconds that the system allows before considering the receiver to
be blocked and a candidate to be killed). You cannot launch a popup dialog
in your implementation of onReceive().
If this BroadcastReceiver was launched through a <receiver> tag,
then the object is no longer alive after returning from this
function. This means you should not perform any operations that
return a result to you asynchronously -- in particular, for interacting
with services, you should use
Context.startService(Intent)
instead of
Context.bindService(Intent, ServiceConnection, int)
. If you wish
to interact with a service that is already running, you can use
BroadcastReceiver.peekService(android.content.Context, android.content.Intent)
.
The Intent filters used in Context.registerReceiver(android.content.BroadcastReceiver, android.content.IntentFilter)
and in application manifests are not guaranteed to be exclusive. They
are hints to the operating system about how to find suitable recipients. It is
possible for senders to force delivery to specific recipients, bypassing filter
resolution. For this reason, onReceive()
implementations should respond only to known actions, ignoring any unexpected
Intents that they may receive.
onReceive
in class BroadcastReceiver
context
- The Context in which the receiver is running.intent
- The Intent being received.