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:org.telegram.messenger.LocationSharingService.java
public int onStartCommand(Intent intent, int flags, int startId) { if (getInfos().isEmpty()) { stopSelf();//from ww w .j a v a2 s . c om } if (builder == null) { Intent intent2 = new Intent(ApplicationLoader.applicationContext, LaunchActivity.class); intent2.setAction("org.tmessages.openlocations"); intent2.addCategory(Intent.CATEGORY_LAUNCHER); PendingIntent contentIntent = PendingIntent.getActivity(ApplicationLoader.applicationContext, 0, intent2, 0); builder = new NotificationCompat.Builder(ApplicationLoader.applicationContext); builder.setWhen(System.currentTimeMillis()); builder.setSmallIcon(R.drawable.live_loc); builder.setContentIntent(contentIntent); NotificationsController.checkOtherNotificationsChannel(); builder.setChannelId(NotificationsController.OTHER_NOTIFICATIONS_CHANNEL); builder.setContentTitle(LocaleController.getString("AppName", R.string.AppName)); Intent stopIntent = new Intent(ApplicationLoader.applicationContext, StopLiveLocationReceiver.class); builder.addAction(0, LocaleController.getString("StopLiveLocation", R.string.StopLiveLocation), PendingIntent.getBroadcast(ApplicationLoader.applicationContext, 2, stopIntent, PendingIntent.FLAG_UPDATE_CURRENT)); } updateNotification(false); startForeground(6, builder.build()); return Service.START_NOT_STICKY; }
From source file:edu.mit.mobile.android.demomode.DemoMode.java
/** * Loads the list of installed applications in mApplications. *//*from www . jav a 2s.co m*/ private void loadApplications(boolean isLaunching) { if (isLaunching && mApplications != null) { return; } final PackageManager manager = getPackageManager(); final Intent mainIntent = new Intent(Intent.ACTION_MAIN, null); mainIntent.addCategory(Intent.CATEGORY_LAUNCHER); final List<ResolveInfo> apps = manager.queryIntentActivities(mainIntent, 0); Collections.sort(apps, new ResolveInfo.DisplayNameComparator(manager)); if (apps != null) { final int count = apps.size(); if (mApplications == null) { mApplications = new ArrayList<ApplicationInfo>(count); } mApplications.clear(); for (int i = 0; i < count; i++) { final ApplicationInfo application = new ApplicationInfo(); final ResolveInfo info = apps.get(i); application.title = info.loadLabel(manager); application.setActivity( new ComponentName(info.activityInfo.applicationInfo.packageName, info.activityInfo.name), Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); application.icon = info.activityInfo.loadIcon(manager); mApplications.add(application); } } }
From source file:edu.stanford.mobisocial.dungbeetle.feed.objects.AppReferenceObj.java
@Override public void handleDirectMessage(Context context, Contact from, JSONObject obj) { String packageName = obj.optString(PACKAGE_NAME); String arg = obj.optString(ARG); Intent launch = new Intent(); launch.setAction(Intent.ACTION_MAIN); launch.addCategory(Intent.CATEGORY_LAUNCHER); launch.putExtra(AppState.EXTRA_APPLICATION_ARGUMENT, arg); launch.putExtra("creator", false); launch.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); launch.setPackage(packageName);//www.j a v a2s . co m final PackageManager mgr = context.getPackageManager(); List<ResolveInfo> resolved = mgr.queryIntentActivities(launch, 0); if (resolved == null || resolved.size() == 0) { Toast.makeText(context, "Could not find application to handle invite", Toast.LENGTH_SHORT).show(); return; } ActivityInfo info = resolved.get(0).activityInfo; launch.setComponent(new ComponentName(info.packageName, info.name)); PendingIntent contentIntent = PendingIntent.getActivity(context, 0, launch, PendingIntent.FLAG_CANCEL_CURRENT); (new PresenceAwareNotify(context)).notify("New Invitation", "Invitation received from " + from.name, "Click to launch application.", contentIntent); }
From source file:com.velli.passwordmanager.FragmentPasswordDetails.java
public static void openApp(Context context, String packageName) { PackageManager manager = context.getPackageManager(); Intent i = manager.getLaunchIntentForPackage(packageName); if (i != null) { i.addCategory(Intent.CATEGORY_LAUNCHER); context.startActivity(i);/* w w w. j a v a 2 s . c o m*/ } }
From source file:edu.pdx.cecs.orcycle.Controller.java
private void transitionToLocationServices(Fragment f) { final ComponentName toLaunch = new ComponentName(COM_ANDROID_SETTINGS, COM_ANDROID_SETTINGS_SECURITY_SETTINGS); final Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS); intent.addCategory(Intent.CATEGORY_LAUNCHER); intent.setComponent(toLaunch);/* w w w .j a v a 2 s . com*/ intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); f.startActivityForResult(intent, 0); }
From source file:com.launcher.silverfish.AppDrawerTabFragment.java
/** * Loads apps from the database/* www .j a v a2 s .c om*/ */ private void loadApps() { Intent i = new Intent(Intent.ACTION_MAIN, null); i.addCategory(Intent.CATEGORY_LAUNCHER); switch (tabId) { case 1: // Tab 1 is a special tab and includes all except for the once in other tabs // so we retrieve all apps that are in the database LinkedList<String> ordered_apps = sqlHelper.getAllApps(); // And all installed apps on the device List<ResolveInfo> availableActivities = mPacMan.queryIntentActivities(i, 0); // And only add those that are not in the database for (int j = 0; j < availableActivities.size(); j++) { ResolveInfo ri = availableActivities.get(j); // Skip the apps that are in the database if (ordered_apps.contains(ri.activityInfo.packageName)) { continue; } AppDetail app = new AppDetail(); app.label = ri.loadLabel(mPacMan); app.name = ri.activityInfo.packageName; // Load the icon later in an async task. app.icon = null; appsList.add(app); } break; default: // All other tabs just query the apps from the database LinkedList<String> app_names = sqlHelper.getAppsForTab(tabId); for (String app_name : app_names) { boolean success = addAppToList(app_name); // If the app could not be added then it was probably uninstalled, // so we have to remove it from the database if (!success) { Log.d("DB", "Removing app " + app_name + " from db"); sqlHelper.removeAppFromTab(app_name, this.tabId); } } // show the empty category notice if this tab is empty if (app_names.size() == 0) { showEmptyCategoryNotice(); } } }
From source file:com.android.talkbacktests.testsession.NotificationTest.java
private void showCustomNotification() { NotificationCompat.Builder builder = new NotificationCompat.Builder(getContext()).setAutoCancel(true) .setSmallIcon(android.R.drawable.ic_notification_overlay) .setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)); RemoteViews contentView = new RemoteViews(getContext().getPackageName(), R.layout.custom_notification); contentView.setImageViewResource(R.id.notification_image, android.R.drawable.ic_dialog_email); contentView.setTextViewText(R.id.notification_title, getString(R.string.custom_notification_title)); contentView.setTextViewText(R.id.notification_text, getString(R.string.custom_notification_text)); builder.setContent(contentView);// ww w .jav a2 s . co m Intent resultIntent = new Intent(getContext(), MainActivity.class); resultIntent.setAction(Intent.ACTION_MAIN); resultIntent.addCategory(Intent.CATEGORY_LAUNCHER); PendingIntent pendingIntent = PendingIntent.getActivity(getContext(), 0, resultIntent, 0); builder.setContentIntent(pendingIntent); NotificationManager notificationManager = (NotificationManager) getContext() .getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.notify(NOTIFICATION_ID_LAST_VIEW, builder.build()); }
From source file:com.aylanetworks.aura.GcmIntentService.java
private void sendNotification(String msg, String sound) { mNotificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE); // Find the launcher class for our application PackageManager pm = getPackageManager(); String packageName = getPackageName(); Intent query = new Intent(Intent.ACTION_MAIN); Class launcherClass = null;//from w w w . j av a2 s . co m query.addCategory(Intent.CATEGORY_LAUNCHER); List<ResolveInfo> foundIntents = pm.queryIntentActivities(query, 0); for (ResolveInfo info : foundIntents) { if (TextUtils.equals(info.activityInfo.packageName, packageName)) { launcherClass = info.activityInfo.getClass(); } } if (launcherClass == null) { Log.e(TAG, "Could not find application launcher class"); return; } Intent appIntent = new Intent(this, launcherClass); // main activity of Ayla Control/aMCA PendingIntent contentIntent = PendingIntent.getActivity(this, 0, appIntent, 0); //Determine the sound to be played Uri soundUri = null; if (sound == null) { // NOP //PushNotification.playSound("bdth.mp3"); } else if (sound.equals("none")) { // NOP } else if (sound.equals("default")) { soundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); // TYPE_NOTIFICATION or TYPE_ALARM } else if (sound.equals("alarm")) { soundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_ALARM); // TYPE_NOTIFICATION or TYPE_ALARM } else { boolean playedSound; playedSound = PushNotification.playSound(sound); if (playedSound == false) { soundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); // TYPE_NOTIFICATION or TYPE_ALARM } } // @formatter:off NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this) //.setSound(soundUri) .setSmallIcon(R.drawable.ic_push_icon).setContentTitle(getResources().getString(R.string.app_name)) .setStyle(new NotificationCompat.BigTextStyle().bigText(msg)).setLights(0xFFff0000, 500, 500) // flashing red light .setContentText(msg).setAutoCancel(true) //.setPriority(Notification.FLAG_HIGH_PRIORITY) .setDefaults(Notification.DEFAULT_VIBRATE | Notification.FLAG_SHOW_LIGHTS); // @formatter:on if (soundUri != null) { mBuilder.setSound(soundUri); } mBuilder.setPriority(PRIORITY_MAX); mBuilder.setContentIntent(contentIntent); mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build()); }
From source file:com.gigaset.home.Home.java
/** * Loads the list of installed applications in mApplications. *///from w w w . jav a 2s .c o m private void loadApplications(boolean isLaunching) { if (isLaunching && mApplications != null) { return; } PackageManager manager = getPackageManager(); Intent mainIntent = new Intent(Intent.ACTION_MAIN, null); mainIntent.addCategory(Intent.CATEGORY_LAUNCHER); final List<ResolveInfo> apps = manager.queryIntentActivities(mainIntent, 0); Collections.sort(apps, new ResolveInfo.DisplayNameComparator(manager)); if (apps != null) { final int count = apps.size(); if (mApplications == null) { mApplications = new ArrayList<ApplicationInfo>(count); } mApplications.clear(); ApplicationInfo application; // ********************* ADD Key Pad ********************************** application = new ApplicationInfo(); application.title = "Key Pad"; application.icon = application.icon = getResources().getDrawable(R.drawable.main_screen_iocon_key_pad); application.setActivity( new ComponentName("com.android.contacts", "com.android.contacts.activities.DialtactsActivity"), Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); mApplications.add(application); // ********************* ADD Messages ********************************* application = new ApplicationInfo(); application.title = "Messages"; application.icon = application.icon = getResources().getDrawable(R.drawable.main_screen_icon_messages); application.setActivity(new ComponentName("com.android.mms", "com.android.mms.ui.ConversationList"), Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); mApplications.add(application); // ********************* ADD Contacts ********************************* application = new ApplicationInfo(); application.title = "Contacts"; application.icon = application.icon = getResources().getDrawable(R.drawable.main_screen_icon_contacts); application.setActivity( new ComponentName("com.android.contacts", "com.android.contacts.activities.PeopleActivity"), Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); mApplications.add(application); // ********************* ADD Call Log ********************************* // http://hi-android.info/src/index.html application = new ApplicationInfo(); application.title = "Call List"; application.icon = getResources().getDrawable(R.drawable.main_screen_icon_call_log); application.setActivityWithAction(Intent.ACTION_VIEW, CallLog.Calls.CONTENT_TYPE); mApplications.add(application); // ********************* ADD Browser ********************************** application = new ApplicationInfo(); application.title = "Browser"; application.icon = application.icon = getResources().getDrawable(R.drawable.main_screen_icon_browser); application.setActivity(new ComponentName("com.android.browser", "com.android.browser.BrowserActivity"), Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); mApplications.add(application); // ********************* ADD Call Settings **************************** application = new ApplicationInfo(); application.title = "Call Settings"; application.icon = application.icon = getResources() .getDrawable(R.drawable.main_screen_icon_call_settings); application.setActivity(new ComponentName("com.android.settings", "com.android.settings.Settings"), Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); mApplications.add(application); // // for (int i = 0; i < count; i++) // { // ApplicationInfo application = new ApplicationInfo(); // ResolveInfo info = apps.get(i); // // application.title = info.loadLabel(manager); // application.setActivity(new ComponentName( // info.activityInfo.applicationInfo.packageName, // info.activityInfo.name), // Intent.FLAG_ACTIVITY_NEW_TASK // | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); // // Log.v("Home APP", "package neme= "+info.activityInfo.applicationInfo.packageName); // Log.v("Home APP", "neme= "+info.activityInfo.name); // Log.v("Home APP", "title= "+application.title); // // // application.icon = info.activityInfo.loadIcon(manager); // // // Replace Icons // if((application.title+"").equals("Browser")) application.icon = getResources().getDrawable(R.drawable.main_screen_icon_browser); // if((application.title+"").equals("Phone")) application.icon = getResources().getDrawable(R.drawable.main_screen_iocon_key_pad); // if((application.title+"").equals("People")) application.icon = getResources().getDrawable(R.drawable.main_screen_icon_contacts); // if((application.title+"").equals("Messaging")) application.icon = getResources().getDrawable(R.drawable.main_screen_icon_messages); // if((application.title+"").equals("Settings")) application.icon = getResources().getDrawable(R.drawable.main_screen_icon_call_settings); // //if((application.title+"").equals("Call Log")) application.icon = getResources().getDrawable(R.drawable.main_screen_icon_call_log); // // // Add Application // if((application.title+"").equals("Browser")) mApplications.add(application); // if((application.title+"").equals("Phone")) mApplications.add(application); // if((application.title+"").equals("People")) mApplications.add(application); // if((application.title+"").equals("Messaging")) mApplications.add(application); // if((application.title+"").equals("Settings")) mApplications.add(application); // // } } }
From source file:org.thomnichols.android.gmarks.WebViewLoginActivity.java
protected void showTwoFactorAuthDialog() { dismissWaitDialog();/*from w w w . j a va 2 s . c o m*/ final Intent launchAuthIntent = new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_LAUNCHER) .setClassName(AUTHENTICATOR_PACKAGE, "com.google.android.apps.authenticator.AuthenticatorActivity"); ResolveInfo ri = getPackageManager().resolveActivity(launchAuthIntent, 0); if (ri == null) { WebViewLoginActivity.this.showAuthenticatorMissingDialog(); return; } Log.d(TAG, "Resolve info: " + ri); new AlertDialog.Builder(this).setTitle(R.string.two_factor_auth_dlg_title) .setMessage(Html.fromHtml(getString(R.string.two_factor_auth_dlg_msg))).setCancelable(true) .setNegativeButton(R.string.btn_cancel, new OnClickListener() { public void onClick(DialogInterface dlg, int _) { dlg.dismiss(); } }).setPositiveButton(R.string.btn_ok, new OnClickListener() { public void onClick(DialogInterface dlg, int _) { // dlg.dismiss(); try { startActivity(launchAuthIntent); } catch (ActivityNotFoundException ex) { Log.d(TAG, "Activity not found", ex); WebViewLoginActivity.this.showAuthenticatorMissingDialog(); } // catch ( Exception ex ) { // Log.w(TAG,"Unexpected exception from activity launch",ex); // } } }).show(); }