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:id.zelory.codepolitan.ui.ReadActivity.java
private void onShareArticle(String packageName) { Article article = articles.get(position); if ("more".equals(packageName)) { Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); intent.putExtra(Intent.EXTRA_SUBJECT, Html.fromHtml(article.getTitle())); intent.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(article.getTitle()) + "\n" + article.getLink()); startActivity(Intent.createChooser(intent, "Share")); } else if ("email".equals(packageName)) { Intent intent = new Intent(Intent.ACTION_SENDTO); intent.setData(Uri.parse("mailto:")); intent.putExtra(Intent.EXTRA_SUBJECT, Html.fromHtml(article.getTitle())); intent.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(article.getTitle()) + "\n" + article.getLink()); startActivity(intent);//from www.j a va 2 s.c o m } else if ("sms".equals(packageName)) { Intent intent = new Intent(Intent.ACTION_SENDTO); intent.setData(Uri.parse("smsto:")); intent.putExtra(Intent.EXTRA_SUBJECT, Html.fromHtml(article.getTitle())); intent.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(article.getTitle()) + "\n" + article.getLink()); startActivity(intent); } else { boolean shared = false; Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); intent.putExtra(Intent.EXTRA_SUBJECT, Html.fromHtml(article.getTitle())); intent.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(article.getTitle()) + "\n" + article.getLink()); for (ResolveInfo resolveInfo : getPackageManager().queryIntentActivities(intent, 0)) { if (packageName.equals(resolveInfo.activityInfo.packageName)) { intent.addCategory(Intent.CATEGORY_LAUNCHER); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.setComponent(new ComponentName(packageName, resolveInfo.activityInfo.name)); startActivity(intent); shared = true; break; } } if (!shared) { openPlayStore(packageName); } } }
From source file:com.miz.service.MovieLibraryUpdate.java
private void setup() { LocalBroadcastManager.getInstance(getApplicationContext()).registerReceiver(mMessageReceiver, new IntentFilter(STOP_MOVIE_LIBRARY_UPDATE)); // Set up cancel dialog intent Intent notificationIntent = new Intent(this, CancelLibraryUpdate.class); notificationIntent.putExtra("isMovie", true); notificationIntent.setAction(Intent.ACTION_MAIN); notificationIntent.addCategory(Intent.CATEGORY_LAUNCHER); PendingIntent contentIntent = PendingIntent.getActivity(this, NOTIFICATION_ID, notificationIntent, 0); // Setup up notification mBuilder = new NotificationCompat.Builder(getApplicationContext()); mBuilder.setColor(getResources().getColor(R.color.color_primary)); mBuilder.setPriority(NotificationCompat.PRIORITY_MAX); mBuilder.setSmallIcon(R.drawable.ic_sync_white_24dp); mBuilder.setTicker(getString(R.string.updatingMovies)); mBuilder.setContentTitle(getString(R.string.updatingMovies)); mBuilder.setContentText(getString(R.string.gettingReady)); mBuilder.setContentIntent(contentIntent); mBuilder.setOngoing(true);//from w w w . j a v a 2 s . co m mBuilder.setOnlyAlertOnce(true); mBuilder.addAction(R.drawable.ic_close_white_24dp, getString(android.R.string.cancel), contentIntent); // Build notification Notification updateNotification = mBuilder.build(); // Show the notification mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); mNotificationManager.notify(NOTIFICATION_ID, updateNotification); // Tell the system that this is an ongoing notification, so it shouldn't be killed startForeground(NOTIFICATION_ID, updateNotification); mSettings = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); mClearLibrary = mSettings.getBoolean(CLEAR_LIBRARY_MOVIES, false); mClearUnavailable = mSettings.getBoolean(REMOVE_UNAVAILABLE_FILES_MOVIES, false); mSyncLibraries = mSettings.getBoolean(SYNC_WITH_TRAKT, true); }
From source file:com.anjalimacwan.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"); }/* ww w .ja va2 s . c o m*/ 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) { /* Gracefully fail */ } if (hasAndroidWear) { try { pInfo = getPackageManager().getPackageInfo("com.anjalimacwan.wear", 0); Intent intent = new Intent(Intent.ACTION_MAIN); intent.setComponent(ComponentName .unflattenFromString("com.anjalimacwan.wear/com.anjalimacwan.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) { /* Gracefully fail */ } } } }
From source file:com.adguard.android.commons.BrowserUtils.java
private static ComponentName getSamsungBrowser(Context context) { Intent mainIntent = new Intent(Intent.ACTION_MAIN, null); mainIntent.addCategory(Intent.CATEGORY_LAUNCHER); List<ResolveInfo> installedPackages = context.getPackageManager().queryIntentActivities(mainIntent, 0); ArrayList<ActivityInfo> samsungActivities = new ArrayList<>(); for (ResolveInfo installedPackage : installedPackages) { if (installedPackage.activityInfo.packageName.startsWith(SAMSUNG_BROWSER_PACKAGE)) { samsungActivities.add(installedPackage.activityInfo); }//w ww . j a v a 2 s . c o m } if (CollectionUtils.isNotEmpty(samsungActivities)) { Collections.sort(samsungActivities, new Comparator<ActivityInfo>() { @Override public int compare(ActivityInfo lhs, ActivityInfo rhs) { return lhs.packageName.compareTo(rhs.packageName); } }); ActivityInfo activityInfo = samsungActivities.get(0); return new ComponentName(activityInfo.packageName, activityInfo.name); } return null; }
From source file:com.teocci.utubinbg.BackgroundAudioService.java
/** * Builds notification panel with buttons and info on it * * @param action Action to be applied//w ww.j a v a2 s.c om */ private void buildNotification(NotificationCompat.Action action) { final NotificationCompat.MediaStyle style = new NotificationCompat.MediaStyle(); Intent intent = new Intent(getApplicationContext(), BackgroundAudioService.class); intent.setAction(ACTION_STOP); PendingIntent stopPendingIntent = PendingIntent.getService(getApplicationContext(), 1, intent, 0); Intent clickIntent = new Intent(this, MainActivity.class); clickIntent.setAction(Intent.ACTION_MAIN); clickIntent.addCategory(Intent.CATEGORY_LAUNCHER); PendingIntent clickPendingIntent = PendingIntent.getActivity(this, 0, clickIntent, 0); builder = new NotificationCompat.Builder(this); builder.setSmallIcon(R.mipmap.utubinbg_icon); builder.setContentTitle(videoItem.getTitle()); builder.setContentInfo(videoItem.getDuration()); builder.setShowWhen(false); builder.setContentIntent(clickPendingIntent); builder.setDeleteIntent(stopPendingIntent); builder.setOngoing(false); builder.setSubText(videoItem.getViewCount()); builder.setStyle(style); //load bitmap for largeScreen if (videoItem.getThumbnailURL() != null && !videoItem.getThumbnailURL().isEmpty()) { Picasso.with(this).load(videoItem.getThumbnailURL()).into(target); } builder.addAction(generateAction(android.R.drawable.ic_media_previous, "Previous", ACTION_PREVIOUS)); builder.addAction(action); builder.addAction(generateAction(android.R.drawable.ic_media_next, "Next", ACTION_NEXT)); style.setShowActionsInCompactView(0, 1, 2); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.notify(1, builder.build()); }
From source file:com.novemser.voicetest.ui.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { requestWindowFeature(Window.FEATURE_NO_TITLE); super.onCreate(savedInstanceState); setContentView(R.layout.activity_template); initView();//w ww . j av a2 s . co m //test.db? db = openOrCreateDatabase("alarm.db", Context.MODE_PRIVATE, null); mAdapter = new ListMessageAdapter(this, mDatas); mChatView.setAdapter(mAdapter); packageManager = getPackageManager(); // Context BaseAction.context = getApplicationContext(); SpeechUtility.createUtility(getApplicationContext(), SpeechConstant.APPID + "=573d5744"); //1.RecognizerDialog mDialog = new RecognizerDialog(this, null); mIat = SpeechRecognizer.createRecognizer(getApplicationContext(), null); //2.accent? language? mDialog.setParameter(SpeechConstant.LANGUAGE, "zh_cn"); mDialog.setParameter(SpeechConstant.ACCENT, "mandarin"); //?UI???onResult? // // mDialog.setParameter("asr_sch", "1"); // mDialog.setParameter("nlp_version", "2.0"); //3.? mDialog.setListener(new RecognizerDialogListener() { @Override public void onResult(RecognizerResult recognizerResult, boolean b) { Log.d("VoiceResult", recognizerResult.getResultString()); printResult(recognizerResult); } @Override public void onError(SpeechError speechError) { } }); // 4. mStartVoiceRecord.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //dialog mDialog.show(); } }); // ?TTS initTTS(); // 5.?? understander = TextUnderstander.createTextUnderstander(this, null); // 6.??? SharedPreferences sharedPreferences = getSharedPreferences("user", MODE_PRIVATE); if (!sharedPreferences.getBoolean("isContactUploaded", false)) { SharedPreferences.Editor editor = sharedPreferences.edit(); ContactManager manager = ContactManager.createManager(this, contactListener); manager.asyncQueryAllContactsName(); editor.putBoolean("isContactUploaded", true); editor.apply(); } Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); toolbar.setTitle(getString(R.string.title_toolbar)); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { toolbar.setTextAlignment(View.TEXT_ALIGNMENT_CENTER); } setSupportActionBar(toolbar); DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); drawer.setDrawerListener(toggle); toggle.syncState(); NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view); navigationView.setNavigationItemSelectedListener(this); new Thread(new Runnable() { /** * ? */ @Override public void run() { //? Intent mainIntent = new Intent(Intent.ACTION_MAIN, null); mainIntent.addCategory(Intent.CATEGORY_LAUNCHER); resolveInfoList = packageManager.queryIntentActivities(mainIntent, 0); //??? Collections.sort(resolveInfoList, new ResolveInfo.DisplayNameComparator(packageManager)); for (ResolveInfo res : resolveInfoList) { String pkg = res.activityInfo.packageName; String cls = res.activityInfo.name; String name = res.loadLabel(packageManager).toString(); Log.d("ApplicationInfo:", "Pkg:" + pkg + " Class:" + cls + " Name:" + name); } } }).start(); // ? mGoogleApiClient = new GoogleApiClient.Builder(this).addApi(Wearable.API).addConnectionCallbacks(this) .addOnConnectionFailedListener(this).build(); }
From source file:net.potterpcs.recipebook.RecipeBookActivity.java
void switchToFlipBook() { // Change from list mode to flipbook mode Intent intent;/*from w w w .j a v a 2s . c o m*/ if (!lastIntent.hasCategory(Intent.CATEGORY_LAUNCHER)) { intent = new Intent(lastIntent); } else { intent = new Intent(); } intent.setClass(this, RecipeFlipbook.class); startActivity(intent); }
From source file:com.uphyca.idobata.android.service.IdobataService.java
private PendingIntent buildPendingStartActivityIntent(Message message, String organizationSlug, String roomName) {// ww w .j a v a 2s .c o m final Intent intent = new Intent(IdobataService.this, MainActivity.class); intent.setAction(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_LAUNCHER); intent.setData(Uri .parse(String.format("https://idobata.io/#/organization/%s/room/%s", organizationSlug, roomName))); return PendingIntent.getActivity(IdobataService.this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); }
From source file:com.miz.service.TvShowsLibraryUpdate.java
private void setup() { if (!MizLib.isOnline(this)) { mStopUpdate = true;/* w w w.jav a 2s .c o m*/ return; } LocalBroadcastManager.getInstance(getApplicationContext()).registerReceiver(mMessageReceiver, new IntentFilter(STOP_TVSHOW_LIBRARY_UPDATE)); // Set up cancel dialog intent Intent notificationIntent = new Intent(this, CancelLibraryUpdate.class); notificationIntent.putExtra("isMovie", false); notificationIntent.setAction(Intent.ACTION_MAIN); notificationIntent.addCategory(Intent.CATEGORY_LAUNCHER); PendingIntent contentIntent = PendingIntent.getActivity(this, NOTIFICATION_ID, notificationIntent, 0); // Setup up notification mBuilder = new NotificationCompat.Builder(getApplicationContext()); mBuilder.setColor(getResources().getColor(R.color.color_primary)); mBuilder.setSmallIcon(R.drawable.ic_sync_white_24dp); mBuilder.setTicker(getString(R.string.updatingTvShows)); mBuilder.setContentTitle(getString(R.string.updatingTvShows)); mBuilder.setContentText(getString(R.string.gettingReady)); mBuilder.setContentIntent(contentIntent); mBuilder.setOngoing(true); mBuilder.setOnlyAlertOnce(true); mBuilder.addAction(R.drawable.ic_close_white_24dp, getString(android.R.string.cancel), contentIntent); // Build notification Notification updateNotification = mBuilder.build(); // Show the notification mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); mNotificationManager.notify(NOTIFICATION_ID, updateNotification); // Tell the system that this is an ongoing notification, so it shouldn't be killed startForeground(NOTIFICATION_ID, updateNotification); mSettings = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); mClearLibrary = mSettings.getBoolean(CLEAR_LIBRARY_TVSHOWS, false); mClearUnavailable = mSettings.getBoolean(REMOVE_UNAVAILABLE_FILES_TVSHOWS, false); mSyncLibraries = mSettings.getBoolean(SYNC_WITH_TRAKT, true); }
From source file:com.smedic.tubtub.BackgroundAudioService.java
/** * Builds notification panel with buttons and info on it * * @param action Action to be applied/*from w w w.ja v a 2 s. c o m*/ */ private void buildNotification(NotificationCompat.Action action) { final NotificationCompat.MediaStyle style = new NotificationCompat.MediaStyle(); Intent intent = new Intent(getApplicationContext(), BackgroundAudioService.class); intent.setAction(ACTION_STOP); PendingIntent stopPendingIntent = PendingIntent.getService(getApplicationContext(), 1, intent, 0); Intent clickIntent = new Intent(this, MainActivity.class); clickIntent.setAction(Intent.ACTION_MAIN); clickIntent.addCategory(Intent.CATEGORY_LAUNCHER); PendingIntent clickPendingIntent = PendingIntent.getActivity(this, 0, clickIntent, 0); builder = new NotificationCompat.Builder(this); builder.setSmallIcon(R.mipmap.ic_launcher); builder.setContentTitle(videoItem.getTitle()); builder.setContentInfo(videoItem.getDuration()); builder.setShowWhen(false); builder.setContentIntent(clickPendingIntent); builder.setDeleteIntent(stopPendingIntent); builder.setOngoing(false); builder.setSubText(videoItem.getViewCount()); builder.setStyle(style); //load bitmap for largeScreen if (videoItem.getThumbnailURL() != null && !videoItem.getThumbnailURL().isEmpty()) { Picasso.with(this).load(videoItem.getThumbnailURL()).into(target); } builder.addAction(generateAction(android.R.drawable.ic_media_previous, "Previous", ACTION_PREVIOUS)); builder.addAction(action); builder.addAction(generateAction(android.R.drawable.ic_media_next, "Next", ACTION_NEXT)); style.setShowActionsInCompactView(0, 1, 2); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.notify(1, builder.build()); }