use of android.content.pm.LauncherApps in project KISS by Neamar.
the class AppResult method doLaunch.
@Override
public void doLaunch(Context context, View v) {
try {
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
LauncherApps launcher = (LauncherApps) context.getSystemService(Context.LAUNCHER_APPS_SERVICE);
launcher.startMainActivity(className, appPojo.userHandle.getRealHandle(), v.getClipBounds(), null);
} else {
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
intent.setComponent(className);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
intent.setSourceBounds(v.getClipBounds());
}
context.startActivity(intent);
}
} catch (ActivityNotFoundException e) {
// Application was just removed?
Toast.makeText(context, R.string.application_not_found, Toast.LENGTH_LONG).show();
}
}
use of android.content.pm.LauncherApps in project KISS by Neamar.
the class AppResult method buildPopupMenu.
@Override
protected PopupMenu buildPopupMenu(Context context, final RecordAdapter parent, View parentView) {
PopupMenu menu = inflatePopupMenu(R.menu.menu_item_app, context, parentView);
if ((context instanceof MainActivity) && (!((MainActivity) context).isOnSearchView())) {
menu.getMenu().removeItem(R.id.item_remove);
}
try {
// app installed under /system can't be uninstalled
boolean isSameProfile = true;
ApplicationInfo ai;
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
LauncherApps launcher = (LauncherApps) context.getSystemService(Context.LAUNCHER_APPS_SERVICE);
LauncherActivityInfo info = launcher.getActivityList(this.appPojo.packageName, this.appPojo.userHandle.getRealHandle()).get(0);
ai = info.getApplicationInfo();
isSameProfile = this.appPojo.userHandle.isCurrentUser();
} else {
ai = context.getPackageManager().getApplicationInfo(this.appPojo.packageName, 0);
}
// Need to AND the flags with SYSTEM:
if ((ai.flags & ApplicationInfo.FLAG_SYSTEM) == 0 && isSameProfile) {
menu.getMenuInflater().inflate(R.menu.menu_item_app_uninstall, menu.getMenu());
}
} catch (NameNotFoundException | IndexOutOfBoundsException e) {
// should not happen
}
//append root menu if available
if (KissApplication.getRootHandler(context).isRootActivated() && KissApplication.getRootHandler(context).isRootAvailable()) {
menu.getMenuInflater().inflate(R.menu.menu_item_app_root, menu.getMenu());
}
return menu;
}
use of android.content.pm.LauncherApps in project KISS by Neamar.
the class AppResult method launchAppDetails.
/**
* Open an activity displaying details regarding the current package
*/
private void launchAppDetails(Context context, AppPojo app) {
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
LauncherApps launcher = (LauncherApps) context.getSystemService(Context.LAUNCHER_APPS_SERVICE);
launcher.startAppDetailsActivity(className, appPojo.userHandle.getRealHandle(), null, null);
} else {
Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS, Uri.fromParts("package", app.packageName, null));
context.startActivity(intent);
}
}
use of android.content.pm.LauncherApps in project platform_frameworks_base by android.
the class AppWidgetHostView method updateContentDescription.
private void updateContentDescription(AppWidgetProviderInfo info) {
if (info != null) {
LauncherApps launcherApps = getContext().getSystemService(LauncherApps.class);
ApplicationInfo appInfo = launcherApps.getApplicationInfo(info.provider.getPackageName(), 0, info.getProfile());
if (appInfo != null && (appInfo.flags & ApplicationInfo.FLAG_SUSPENDED) != 0) {
setContentDescription(Resources.getSystem().getString(com.android.internal.R.string.suspended_widget_accessibility, info.label));
} else {
setContentDescription(info.label);
}
}
}
use of android.content.pm.LauncherApps in project android_frameworks_base by DirtyUnicorns.
the class AppWidgetHostView method updateContentDescription.
private void updateContentDescription(AppWidgetProviderInfo info) {
if (info != null) {
LauncherApps launcherApps = getContext().getSystemService(LauncherApps.class);
ApplicationInfo appInfo = launcherApps.getApplicationInfo(info.provider.getPackageName(), 0, info.getProfile());
if (appInfo != null && (appInfo.flags & ApplicationInfo.FLAG_SUSPENDED) != 0) {
setContentDescription(Resources.getSystem().getString(com.android.internal.R.string.suspended_widget_accessibility, info.label));
} else {
setContentDescription(info.label);
}
}
}
Aggregations