Methods Summary |
---|
private void | addCallbackLocked(android.content.pm.LauncherApps$Callback callback, android.os.Handler handler)
// Remove if already present.
removeCallbackLocked(callback);
if (handler == null) {
handler = new Handler();
}
CallbackMessageHandler toAdd = new CallbackMessageHandler(handler.getLooper(), callback);
mCallbacks.add(toAdd);
|
public java.util.List | getActivityList(java.lang.String packageName, android.os.UserHandle user)Retrieves a list of launchable activities that match {@link Intent#ACTION_MAIN} and
{@link Intent#CATEGORY_LAUNCHER}, for a specified user.
List<ResolveInfo> activities = null;
try {
activities = mService.getLauncherActivities(packageName, user);
} catch (RemoteException re) {
}
if (activities == null) {
return Collections.EMPTY_LIST;
}
ArrayList<LauncherActivityInfo> lais = new ArrayList<LauncherActivityInfo>();
final int count = activities.size();
for (int i = 0; i < count; i++) {
ResolveInfo ri = activities.get(i);
long firstInstallTime = 0;
try {
firstInstallTime = mPm.getPackageInfo(ri.activityInfo.packageName,
PackageManager.GET_UNINSTALLED_PACKAGES).firstInstallTime;
} catch (NameNotFoundException nnfe) {
// Sorry, can't find package
}
LauncherActivityInfo lai = new LauncherActivityInfo(mContext, ri, user,
firstInstallTime);
if (DEBUG) {
Log.v(TAG, "Returning activity for profile " + user + " : "
+ lai.getComponentName());
}
lais.add(lai);
}
return lais;
|
static android.content.ComponentName | getComponentName(ResolveInfo ri)
return new ComponentName(ri.activityInfo.packageName, ri.activityInfo.name);
|
public boolean | isActivityEnabled(android.content.ComponentName component, android.os.UserHandle user)Checks if the activity exists and it enabled for a profile.
try {
return mService.isActivityEnabled(component, user);
} catch (RemoteException re) {
throw new RuntimeException("Failed to call LauncherAppsService");
}
|
public boolean | isPackageEnabled(java.lang.String packageName, android.os.UserHandle user)Checks if the package is installed and enabled for a profile.
try {
return mService.isPackageEnabled(packageName, user);
} catch (RemoteException re) {
throw new RuntimeException("Failed to call LauncherAppsService");
}
|
public void | registerCallback(android.content.pm.LauncherApps$Callback callback, android.os.Handler handler)Registers a callback for changes to packages in current and managed profiles.
synchronized (this) {
if (callback != null && !mCallbacks.contains(callback)) {
boolean addedFirstCallback = mCallbacks.size() == 0;
addCallbackLocked(callback, handler);
if (addedFirstCallback) {
try {
mService.addOnAppsChangedListener(mAppsChangedListener);
} catch (RemoteException re) {
}
}
}
}
|
public void | registerCallback(android.content.pm.LauncherApps$Callback callback)Registers a callback for changes to packages in current and managed profiles.
registerCallback(callback, null);
|
private void | removeCallbackLocked(android.content.pm.LauncherApps$Callback callback)
if (callback == null) {
throw new IllegalArgumentException("Callback cannot be null");
}
final int size = mCallbacks.size();
for (int i = 0; i < size; ++i) {
if (mCallbacks.get(i).mCallback == callback) {
mCallbacks.remove(i);
return;
}
}
|
public LauncherActivityInfo | resolveActivity(android.content.Intent intent, android.os.UserHandle user)Returns the activity info for a given intent and user handle, if it resolves. Otherwise it
returns null.
try {
ResolveInfo ri = mService.resolveActivity(intent, user);
if (ri != null) {
long firstInstallTime = 0;
try {
firstInstallTime = mPm.getPackageInfo(ri.activityInfo.packageName,
PackageManager.GET_UNINSTALLED_PACKAGES).firstInstallTime;
} catch (NameNotFoundException nnfe) {
// Sorry, can't find package
}
LauncherActivityInfo info = new LauncherActivityInfo(mContext, ri, user,
firstInstallTime);
return info;
}
} catch (RemoteException re) {
throw new RuntimeException("Failed to call LauncherAppsService");
}
return null;
|
public void | startAppDetailsActivity(android.content.ComponentName component, android.os.UserHandle user, android.graphics.Rect sourceBounds, android.os.Bundle opts)Starts the settings activity to show the application details for a
package in the specified profile.
try {
mService.showAppDetailsAsUser(component, sourceBounds, opts, user);
} catch (RemoteException re) {
// Oops!
}
|
public void | startMainActivity(android.content.ComponentName component, android.os.UserHandle user, android.graphics.Rect sourceBounds, android.os.Bundle opts)Starts a Main activity in the specified profile.
if (DEBUG) {
Log.i(TAG, "StartMainActivity " + component + " " + user.getIdentifier());
}
try {
mService.startActivityAsUser(component, sourceBounds, opts, user);
} catch (RemoteException re) {
// Oops!
}
|
public void | unregisterCallback(android.content.pm.LauncherApps$Callback callback)Unregisters a callback that was previously registered.
synchronized (this) {
removeCallbackLocked(callback);
if (mCallbacks.size() == 0) {
try {
mService.removeOnAppsChangedListener(mAppsChangedListener);
} catch (RemoteException re) {
}
}
}
|