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.redhorse.quickstart.AppAll.java
private void loadApps() { Intent mainIntent = new Intent(Intent.ACTION_MAIN, null); mainIntent.addCategory(Intent.CATEGORY_LAUNCHER); mAllApps = getPackageManager().queryIntentActivities(mainIntent, 0); mApps = new ArrayList<ResolveInfo>(); Cursor c = dbStart.getAllItems(); Iterator it1 = mAllApps.iterator(); while (it1.hasNext()) { ResolveInfo info = (ResolveInfo) it1.next(); if (!info.activityInfo.packageName.equalsIgnoreCase("com.redhorse.quickstart")) mApps.add(info);/*from w w w . j ava2s. com*/ } c.close(); }
From source file:com.andybotting.tubechaser.activity.Home.java
/** * Activity start// ww w . j a v a 2s.c o m */ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_home); // Refresh button findViewById(R.id.btn_title_refresh).setOnClickListener(new View.OnClickListener() { public void onClick(View v) { new GetTubeStatus().execute(); } }); // Search button findViewById(R.id.btn_title_search).setOnClickListener(new View.OnClickListener() { public void onClick(View v) { UIUtils.goSearch(Home.this); } }); // Overview findViewById(R.id.home_btn_overview).setOnClickListener(new View.OnClickListener() { public void onClick(View v) { startActivity(new Intent(Home.this, LineOverview.class)); } }); // Browse findViewById(R.id.home_btn_stations).setOnClickListener(new View.OnClickListener() { public void onClick(View v) { startActivity(new Intent(Home.this, StationsList.class)); } }); // Nearby findViewById(R.id.home_btn_nearby).setOnClickListener(new View.OnClickListener() { public void onClick(View v) { startActivity(new Intent(Home.this, StationsNearby.class)); } }); // Starred findViewById(R.id.home_btn_starred).setOnClickListener(new View.OnClickListener() { public void onClick(View v) { startActivity(new Intent(Intent.ACTION_VIEW, Stations.buildStarredUri())); } }); // Search findViewById(R.id.home_btn_search).setOnClickListener(new View.OnClickListener() { public void onClick(View v) { UIUtils.goSearch(Home.this); } }); // Settings findViewById(R.id.home_btn_settings).setOnClickListener(new View.OnClickListener() { public void onClick(View v) { startActivity(new Intent(Home.this, Settings.class)); } }); mInfoLoadingView = findViewById(R.id.info_window_loading); mContext = this.getBaseContext(); mPreferenceHelper = new PreferenceHelper(); mProvider = new TubeChaserProvider(); checkStats(); // Show about dialog window on first launch (or just after an upgrade) if (mPreferenceHelper.isFirstLaunchThisVersion()) showAbout(); long lastUpdate = mPreferenceHelper.getLastUpdateTimestamp(); long timeDiff = UIUtils.dateDiff(lastUpdate); if (LOGV) Log.v(TAG, "Last tube status update: " + timeDiff / 1000 + "sec"); // Kick off an update if (timeDiff > UPDATE_MINS * 60000) { new GetTubeStatus().execute(); } else { getInfoWindows(); changeInfoWindow(); startRefreshThread(); } // If we're started by the launcher, then try the default activity if (getIntent().hasCategory(Intent.CATEGORY_LAUNCHER)) goDefaultLaunchActivity(); }
From source file:org.floens.chan.ui.service.WatchNotifier.java
/** * Create a notification with the supplied parameters. * The style of the big notification is InboxStyle, a list of text. * * @param tickerText The tickertext to show, or null if no tickertext should be shown. * @param contentTitle The title of the notification * @param contentText The content of the small notification * @param contentNumber The contentInfo and number, or -1 if not shown * @param expandedLines A list of lines for the big notification, or null if not shown * @param makeSound Should the notification make a sound * @param target The target pin, or null to open the pinned pane on tap * @return//from w w w. ja va2s. c o m */ @SuppressWarnings("deprecation") private Notification getNotificationFor(String tickerText, String contentTitle, String contentText, int contentNumber, List<CharSequence> expandedLines, boolean light, boolean makeSound, Pin target) { Intent intent = new Intent(this, ChanActivity.class); intent.setAction(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_LAUNCHER); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); intent.putExtra("pin_id", target == null ? -1 : target.id); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); NotificationCompat.Builder builder = new NotificationCompat.Builder(this); if (makeSound) { builder.setDefaults(Notification.DEFAULT_SOUND | Notification.DEFAULT_VIBRATE); } if (light) { long watchLed = ChanPreferences.getWatchLed(); if (watchLed >= 0) { builder.setLights((int) watchLed, 1000, 1000); } } builder.setContentIntent(pendingIntent); if (tickerText != null) { tickerText = tickerText.substring(0, Math.min(tickerText.length(), 50)); } builder.setTicker(tickerText); builder.setContentTitle(contentTitle); builder.setContentText(contentText); if (contentNumber >= 0) { builder.setContentInfo(Integer.toString(contentNumber)); builder.setNumber(contentNumber); } builder.setSmallIcon(R.drawable.ic_stat_notify); Intent pauseWatching = new Intent(this, WatchNotifier.class); pauseWatching.putExtra("pause_pins", true); PendingIntent pauseWatchingPending = PendingIntent.getService(this, 0, pauseWatching, PendingIntent.FLAG_UPDATE_CURRENT); builder.addAction(R.drawable.ic_action_pause, getString(R.string.watch_pause_pins), pauseWatchingPending); if (expandedLines != null) { NotificationCompat.InboxStyle style = new NotificationCompat.InboxStyle(); for (CharSequence line : expandedLines.subList(Math.max(0, expandedLines.size() - 10), expandedLines.size())) { style.addLine(line); } style.setBigContentTitle(contentTitle); builder.setStyle(style); } return builder.getNotification(); }
From source file:edu.stanford.mobisocial.dungbeetle.feed.objects.AppStateObj.java
public static Intent getLaunchIntent(Context context, SignedObj obj) { JSONObject content = obj.getJson();/*ww w . j av a 2 s . co m*/ if (DBG) Log.d(TAG, "Getting launch intent for " + content); Uri appFeed; if (content.has(DbObject.CHILD_FEED_NAME)) { Log.d(TAG, "using child feed"); appFeed = Feed.uriForName(content.optString(DbObject.CHILD_FEED_NAME)); } else { Log.d(TAG, "using obj feed"); appFeed = Feed.uriForName(content.optString(DbObjects.FEED_NAME)); } String arg = content.optString(ARG); String state = content.optString(STATE); String appId = obj.getAppId(); // TODO: Hack for deprecated launch method if (appId.equals(DungBeetleContentProvider.SUPER_APP_ID)) { appId = content.optString(PACKAGE_NAME); } if (DBG) Log.d(TAG, "Preparing launch of " + appId + " on " + appFeed); Intent launch = new Intent(); if (content.has(AppReferenceObj.OBJ_INTENT_ACTION)) { launch.setAction(content.optString(AppReferenceObj.OBJ_INTENT_ACTION)); } else { launch.setAction(Intent.ACTION_MAIN); } if (state != null) { launch.putExtra("mobisocial.db.STATE", state); } launch.addCategory(Intent.CATEGORY_LAUNCHER); launch.putExtra(AppState.EXTRA_FEED_URI, appFeed); // TODO: hack until this obj is available in 'related' query. launch.putExtra("obj", content.toString()); // TODO: this is better. launch.putExtra(Musubi.EXTRA_OBJ_HASH, obj.getHash()); if (arg != null) { launch.putExtra(AppState.EXTRA_APPLICATION_ARGUMENT, arg); } // TODO: optimize! List<ResolveInfo> resolved = context.getPackageManager().queryIntentActivities(launch, 0); for (ResolveInfo r : resolved) { ActivityInfo activity = r.activityInfo; if (activity.packageName.equals(appId)) { launch.setClassName(activity.packageName, activity.name); launch.putExtra("mobisocial.db.PACKAGE", activity.packageName); return launch; } } Intent market = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + appId)); return market; }
From source file:com.example.trumpetproject.activities.MainActivity.java
/** * Set the appropriate fragment given the state of the Activity and the Intent used to start it. * If the intent is a launcher intent the Splash Fragment is shown otherwise the SignIn Fragment is shown. * * @param intent Intent used to determine which Fragment is used. */// w ww. j av a2s. co m private void setFragment(Intent intent) { Fragment fragment; String tag; if (intent != null && intent.hasCategory(Intent.CATEGORY_LAUNCHER)) { fragment = new SplashFragment(); tag = SPLASH_TAG; } else { fragment = new SignInFragment(); tag = SIGN_IN_TAG; } String currentTag = getCurrentFragmentTag(); if (currentTag == null || !currentTag.equals(tag)) { // only change frag if it's different than the current one loaded getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, fragment, tag).commit(); } }
From source file:free.yhc.netmbuddy.model.NotiManager.java
private Notification buildNotificationICS(NotiType ntype, CharSequence videoTitle) { RemoteViews rv = new RemoteViews(Utils.getAppContext().getPackageName(), R.layout.player_notification); NotificationCompat.Builder nbldr = new NotificationCompat.Builder(Utils.getAppContext()); rv.setTextViewText(R.id.title, videoTitle); Intent intent = new Intent(Utils.getAppContext(), NotiManager.NotiIntentReceiver.class); intent.setAction(NOTI_INTENT_ACTION); intent.putExtra("type", ntype.name()); PendingIntent pi = PendingIntent.getBroadcast(Utils.getAppContext(), 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); rv.setImageViewResource(R.id.action, ntype.getIcon()); rv.setOnClickPendingIntent(R.id.action, pi); intent = new Intent(Utils.getAppContext(), NotiManager.NotiIntentReceiver.class); intent.setAction(NOTI_INTENT_STOP_PLAYER); pi = PendingIntent.getBroadcast(Utils.getAppContext(), 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); rv.setImageViewResource(R.id.stop, R.drawable.ic_media_stop); rv.setOnClickPendingIntent(R.id.stop, pi); intent = new Intent(Utils.getAppContext(), NotiManager.NotiIntentReceiver.class); intent.setAction(NOTI_INTENT_DELETE); PendingIntent piDelete = PendingIntent.getBroadcast(Utils.getAppContext(), 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); intent = new Intent(Utils.getAppContext(), YTMPActivity.class); intent.setAction(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_LAUNCHER); PendingIntent piContent = PendingIntent.getActivity(Utils.getAppContext(), 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); nbldr.setContent(rv).setContentIntent(piContent).setDeleteIntent(piDelete).setAutoCancel(true) .setSmallIcon(ntype.getIcon()).setTicker(null); return nbldr.build(); }
From source file:com.notepadlite.MainActivity.java
private void checkForAndroidWear() { // Notepad Plugin for Android Wear sends intent with "plugin_install_complete" extra, // in order to verify that the main Notepad app is installed correctly if (getIntent().hasExtra("plugin_install_complete")) { if (getSupportFragmentManager().findFragmentByTag("WearPluginDialogFragmentAlt") == null) { DialogFragment wearDialog = new WearPluginDialogFragmentAlt(); wearDialog.show(getSupportFragmentManager(), "WearPluginDialogFragmentAlt"); }/* w w w. j a va 2 s . com*/ SharedPreferences pref = getSharedPreferences(getPackageName() + "_preferences", Context.MODE_PRIVATE); SharedPreferences.Editor editor = pref.edit(); editor.putBoolean("show_wear_dialog", false); editor.apply(); } else { boolean hasAndroidWear = false; @SuppressWarnings("unused") PackageInfo pInfo; try { pInfo = getPackageManager().getPackageInfo("com.google.android.wearable.app", 0); hasAndroidWear = true; } catch (PackageManager.NameNotFoundException e) { } if (hasAndroidWear) { try { pInfo = getPackageManager().getPackageInfo("com.notepadlite.wear", 0); Intent intent = new Intent(Intent.ACTION_MAIN); intent.setComponent(ComponentName .unflattenFromString("com.notepadlite.wear/com.notepadlite.wear.MobileMainActivity")); intent.addCategory(Intent.CATEGORY_LAUNCHER); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); } catch (PackageManager.NameNotFoundException e) { SharedPreferences pref = getSharedPreferences(getPackageName() + "_preferences", Context.MODE_PRIVATE); if (pref.getBoolean("show_wear_dialog", true) && getSupportFragmentManager().findFragmentByTag("WearPluginDialogFragment") == null) { DialogFragment wearDialog = new WearPluginDialogFragment(); wearDialog.show(getSupportFragmentManager(), "WearPluginDialogFragment"); } } catch (ActivityNotFoundException e) { } } } }
From source file:com.android.launcher3.InstallShortcutReceiver.java
/** * Returns true if the intent is a valid launch intent for a shortcut. * This is used to identify shortcuts which are different from the ones exposed by the * applications' manifest file./*from w w w . j a v a2 s. co m*/ * * When DISABLE_ALL_APPS is true, shortcuts exposed via the app's manifest should never be * duplicated or removed(unless the app is un-installed). * * @param launchIntent The intent that will be launched when the shortcut is clicked. */ static boolean isValidShortcutLaunchIntent(Intent launchIntent) { if (launchIntent != null && Intent.ACTION_MAIN.equals(launchIntent.getAction()) && launchIntent.getComponent() != null && launchIntent.getCategories() != null && launchIntent.getCategories().size() == 1 && launchIntent.hasCategory(Intent.CATEGORY_LAUNCHER) && launchIntent.getExtras() == null && TextUtils.isEmpty(launchIntent.getDataString())) { return false; } return true; }
From source file:com.adguard.android.commons.BrowserUtils.java
public static void startBrowser(Context context, ComponentName component) { Intent intent = new Intent(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_LAUNCHER); intent.setComponent(component);/*from w ww .j a v a 2 s .co m*/ intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent); }