List of usage examples for android.content Intent CATEGORY_LAUNCHER
String CATEGORY_LAUNCHER
To view the source code for android.content Intent CATEGORY_LAUNCHER.
Click Source Link
From source file:com.negaheno.android.NotificationsController.java
public static String getLauncherClassName(Context context) { try {/* w ww. j av a 2 s . co m*/ PackageManager pm = context.getPackageManager(); Intent intent = new Intent(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_LAUNCHER); List<ResolveInfo> resolveInfos = pm.queryIntentActivities(intent, 0); for (ResolveInfo resolveInfo : resolveInfos) { String pkgName = resolveInfo.activityInfo.applicationInfo.packageName; if (pkgName.equalsIgnoreCase(context.getPackageName())) { return resolveInfo.activityInfo.name; } } } catch (Throwable e) { FileLog.e("tmessages", e); } return null; }
From source file:com.goftagram.telegram.messenger.NotificationsController.java
private static String getLauncherClassName(Context context) { try {/*from w w w . j a va 2 s . co m*/ PackageManager pm = context.getPackageManager(); Intent intent = new Intent(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_LAUNCHER); List<ResolveInfo> resolveInfos = pm.queryIntentActivities(intent, 0); for (ResolveInfo resolveInfo : resolveInfos) { String pkgName = resolveInfo.activityInfo.applicationInfo.packageName; if (pkgName.equalsIgnoreCase(context.getPackageName())) { return resolveInfo.activityInfo.name; } } } catch (Throwable e) { FileLog.e("tmessages", e); } return null; }
From source file:com.aliyun.homeshell.Folder.java
public void onDropCompleted(View target, DragObject d, boolean isFlingToDelete, boolean success) { mDropAccepted = success;/*w w w . j a v a2s.com*/ Log.d(TAG, "sxsexe---------> onDropCompleted dragInfo " + d.dragInfo + " success " + success + " mDeleteFolderOnDropCompleted " + mDeleteFolderOnDropCompleted + " mItemAddedBackToSelfViaIcon " + mItemAddedBackToSelfViaIcon + " item count " + getItemCount() + " mHasDirtyData " + mHasDirtyData); /*YUNOS BEGIN*/ //##module(component name) //##date:2014/03/28 ##author:jun.dongj@alibaba-inc.com##BugID:105531 //there is a cellayout outline when drag icon in folder, otherwise, hide it showDragOutline(false); /*YUNOS END*/ mShortcutInfoCache = (ShortcutInfo) d.dragInfo; mLauncher.setCurrentFolder(this); if (success) { if (target instanceof DeleteDropTarget && mShortcutInfoCache.itemType == Favorites.ITEM_TYPE_APPLICATION) { /* YUNOS BEGIN PB*/ //##modules(HomeShell): ##author:guoshuai.lgs //##BugID:(5221896) ##date:2014/09/03 //##decrpition: support mainmenu feature, cancel drop feature, page management feature, and so on if (!LauncherApplication.isMainmenuMode()) { //go to uninstall or remove, Log.d(TAG, "sxsexe---------> onDropCompleted do not need to replaceFolderWithFinalItem"); mHasDirtyData = true; /*YUNOS BEGIN*/ //##date:2014/01/18 ##author:hao.liuhaolh ##BugID:83464 //app icon remove issue in folder if ((mShortcutInfoCache.intent != null) && (mShortcutInfoCache.intent.getComponent() != null) && (mShortcutInfoCache.intent.getComponent().getPackageName() != null)) { boolean storgeMount = Environment.getExternalStorageState() .equals(Environment.MEDIA_MOUNTED); String packageName = mShortcutInfoCache.intent.getComponent().getPackageName(); final PackageManager packageManager = ((Context) mLauncher).getPackageManager(); final Intent mainIntent = new Intent(Intent.ACTION_MAIN, null); mainIntent.addCategory(Intent.CATEGORY_LAUNCHER); mainIntent.setPackage(packageName); final List<ResolveInfo> apps = packageManager.queryIntentActivities(mainIntent, 0); if ((apps == null || apps.size() == 0) && (storgeMount == true)) { Log.d(TAG, "no app info, so it need to be cleaned"); mHasDirtyData = false; } } } /*YUNOS END PB*/ /*YUNOS END*/ } /*YUNOS BEGIN*/ //##date:2014/7/2 ##author:yangshan.ys##BugID:134407 //if the target is workspace or hotseat when drag or fling icon ,call this method mDeleteFolderOnDropCompleted = mInfo.count() <= 1; if (mDeleteFolderOnDropCompleted && !mItemAddedBackToSelfViaIcon && !(target instanceof DeleteDropTarget)) { /*YUNOS END*/ if (!mHasDirtyData) { //drag to workspace or hotseat replaceFolderWithFinalItem(); this.setNeedReplaceFolderWithFinalItemFlase(); } } } else { Log.d(TAG, "sxsexe---------> onDropCompleted drag failed need to get the item back "); /*YUNOS BEGIN*/ //##date:2014/06/18 ##author:guoshuai.lgs ##BugID: //support the folder feature in mainmenu if (LauncherApplication.isMainmenuMode() && (mInfo.isMainmenuFolder())) { // Exit spring loaded mode if we have not successfully dropped or have not handled the // drop in Workspace //Delete the dragview d.deferDragViewCleanupPostAnimation = false; mLauncher.exitSpringLoadedDragMode(); } else { // The drag failed, we need to return the item to the folder mFolderIcon.onDrop(d); } /*YUNOS END*/ // We're going to trigger a "closeFolder" which may occur before this item has // been added back to the folder -- this could cause the folder to be deleted if (mOnExitAlarm.alarmPending()) { mSuppressFolderDeletion = true; } } if (target != this) { if (mOnExitAlarm.alarmPending()) { mOnExitAlarm.cancelAlarm(); completeDragExit(); } } mDeleteFolderOnDropCompleted = false; mDragInProgress = false; mItemAddedBackToSelfViaIcon = false; mCurrentDragInfo = null; mCurrentDragView = null; mSuppressOnAdd = false; /* YUNOS BEGIN */ // ##date:2014/07/04 ##author:yangshan.ys##BugID:135044 // prevent the position of editfoldericon moving in folder if (target == this && mInfo.isEditFolderInContents() && mEditFolderTempView != null) { int childId = mEditFolderTempView.getId(); CellLayout.LayoutParams params = (CellLayout.LayoutParams) mEditFolderTempView.getLayoutParams(); mContentList.get(mInfo.getmEditFolderShortcutInfo().screen).addViewToCellLayout(mEditFolderTempView, -1, childId, params, true); mEditFolderHidden = false; } /* YUNOS END */ // Reordering may have occured, and we need to save the new item locations. We do this once // at the end to prevent unnecessary database operations. /*YUNOS BEGIN*/ //##date:2014/06/10 ##author:guoshuai.lgs ##BugID: //support the folder feature in mainmenu if (mInfo.isMainmenuFolder() && (LauncherApplication.isMainmenuMode())) { // TODO: do nothing? } else { updateItemLocationsInDatabase(); } /*YUNOS END*/ mLauncher.getWorkspace().cleanDragInfoFromFolder(); mLauncher.getWorkspace().checkAndRemoveEmptyCell(); }
From source file:com.codename1.impl.android.AndroidImplementation.java
@Override public void restoreMinimizedApplication() { if (getActivity() != null) { Intent i = new Intent(getActivity(), getActivity().getClass()); i.setAction(Intent.ACTION_MAIN); i.addCategory(Intent.CATEGORY_LAUNCHER); getContext().startActivity(i);//from w w w.j a v a 2 s. co m } }
From source file:com.android.launcher2.Launcher.java
void processShortcut(Intent intent) { // Handle case where user selected "Applications" String applicationName = getResources().getString(R.string.group_applications); String shortcutName = intent.getStringExtra(Intent.EXTRA_SHORTCUT_NAME); if (applicationName != null && applicationName.equals(shortcutName)) { Intent mainIntent = new Intent(Intent.ACTION_MAIN, null); mainIntent.addCategory(Intent.CATEGORY_LAUNCHER); Intent pickIntent = new Intent(Intent.ACTION_PICK_ACTIVITY); pickIntent.putExtra(Intent.EXTRA_INTENT, mainIntent); pickIntent.putExtra(Intent.EXTRA_TITLE, getText(R.string.title_select_application)); startActivityForResultSafely(pickIntent, REQUEST_PICK_APPLICATION); } else {//from w ww .ja v a 2s .c o m startActivityForResultSafely(intent, REQUEST_CREATE_SHORTCUT); } }
From source file:com.cognizant.trumobi.PersonaLauncher.java
void processShortcut(Intent intent, int requestCodeApplication, int requestCodeShortcut) { PersonaLog.e(LOG_TAG, "processShortcut" + intent); // Handle case where user selected "Applications" String applicationName = getResources().getString(R.string.group_applications); String shortcutName = intent.getStringExtra(Intent.EXTRA_SHORTCUT_NAME); if (applicationName != null && applicationName.equals(shortcutName)) { Intent mainIntent = new Intent(Intent.ACTION_MAIN, null); mainIntent.addCategory(Intent.CATEGORY_LAUNCHER); // 290778 modified for shortcut /*/*from w w w . ja v a2 s.co m*/ * Intent mainIntent = new Intent("Email"); * mainIntent.addCategory("android.intent.category.PIM"); */ Intent pickIntent = new Intent(Intent.ACTION_PICK_ACTIVITY); pickIntent.putExtra(Intent.EXTRA_INTENT, mainIntent); pickIntent.putExtra(Intent.EXTRA_TITLE, getString(R.string.group_applications)); startActivityForResult(pickIntent, requestCodeApplication); } else { startActivityForResult(intent, requestCodeShortcut); } }
From source file:com.android.soma.Launcher.java
void processShortcut(Intent intent) { // Handle case where user selected "Applications" String applicationName = getResources().getString(R.string.group_applications); String shortcutName = intent.getStringExtra(Intent.EXTRA_SHORTCUT_NAME); if (applicationName != null && applicationName.equals(shortcutName)) { Intent mainIntent = new Intent(Intent.ACTION_MAIN, null); mainIntent.addCategory(Intent.CATEGORY_LAUNCHER); Intent pickIntent = new Intent(Intent.ACTION_PICK_ACTIVITY); pickIntent.putExtra(Intent.EXTRA_INTENT, mainIntent); pickIntent.putExtra(Intent.EXTRA_TITLE, getText(R.string.title_select_application)); Utilities.startActivityForResultSafely(this, pickIntent, REQUEST_PICK_APPLICATION); } else {//from ww w .ja va 2 s . c o m Utilities.startActivityForResultSafely(this, intent, REQUEST_CREATE_SHORTCUT); } }
From source file:com.android.leanlauncher.LauncherModel.java
/** * Make an ShortcutInfo object for a shortcut that is an application. *//*from ww w .j av a 2s.co m*/ public ShortcutInfo getShortcutInfo(Intent intent, UserHandleCompat user, int titleIndex, Map<Object, CharSequence> labelCache, boolean allowMissingTarget) { if (user == null) { Log.d(TAG, "Null user found in getShortcutInfo"); return null; } ComponentName componentName = intent.getComponent(); if (componentName == null) { Log.d(TAG, "Missing component found in getShortcutInfo"); return null; } Intent newIntent = new Intent(intent.getAction(), null); newIntent.addCategory(Intent.CATEGORY_LAUNCHER); newIntent.setComponent(componentName); LauncherActivityInfoCompat lai = mLauncherApps.resolveActivity(newIntent, user); if ((lai == null) && !allowMissingTarget) { Log.d(TAG, "Missing activity found in getShortcutInfo: " + componentName); return null; } final ShortcutInfo info = new ShortcutInfo(); // From the cache. if (labelCache != null) { info.title = labelCache.get(componentName); } // from the resource if (info.title == null && lai != null) { info.title = lai.getLabel(); if (labelCache != null) { labelCache.put(componentName, info.title); } } // from the db if (info.title == null) { if (mApp.getContext() != null) { info.title = mApp.getContext().getString(titleIndex); } } // fall back to the class name of the activity if (info.title == null) { info.title = componentName.getClassName(); } info.itemType = LauncherSettings.Favorites.ITEM_TYPE_APPLICATION; info.user = user; info.contentDescription = mUserManager.getBadgedLabelForUser(info.title.toString(), info.user); return info; }
From source file:com.afwsamples.testdpc.policy.PolicyManagementFragment.java
private List<ResolveInfo> getAllLauncherIntentResolversSorted() { final Intent launcherIntent = new Intent(Intent.ACTION_MAIN); launcherIntent.addCategory(Intent.CATEGORY_LAUNCHER); final List<ResolveInfo> launcherIntentResolvers = mPackageManager.queryIntentActivities(launcherIntent, 0); Collections.sort(launcherIntentResolvers, new ResolveInfo.DisplayNameComparator(mPackageManager)); return launcherIntentResolvers; }
From source file:com.hichinaschool.flashcards.anki.DeckPicker.java
/** * Creates an intent to load a deck given the full pathname of it. The constructed intent is equivalent (modulo the * extras) to the open used by the launcher shortcut, which means it will not open a new study options window but * bring the existing one to the front./*from w ww .j a v a 2 s.com*/ */ public static Intent getLoadDeckIntent(Context context, long deckId) { Intent loadDeckIntent = new Intent(context, DeckPicker.class); loadDeckIntent.setAction(Intent.ACTION_MAIN); loadDeckIntent.addCategory(Intent.CATEGORY_LAUNCHER); loadDeckIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP); loadDeckIntent.putExtra(EXTRA_DECK_ID, deckId); return loadDeckIntent; }