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:net.pmarks.chromadoze.NoiseService.java
private Notification makeNotify() { // android:launchMode="singleTask" ensures that the latest instance // of the Activity will be reachable from the Launcher. However, a // naive Intent can still overwrite the task, so we track down the // existing task by pretending to be the Launcher. PendingIntent contentIntent = PendingIntent.getActivity(this, 0, new Intent(this, ChromaDoze.class) .setAction(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_LAUNCHER), 0); Notification n = new NotificationCompat.Builder(this).setSmallIcon(R.drawable.ic_stat_bars).setWhen(0) .setContentTitle(getString(R.string.app_name)).setContentText(getString(R.string.notification_text)) .setContentIntent(contentIntent).setVisibility(NotificationCompat.VISIBILITY_PUBLIC).build(); // Add a Stop button to the Notification bar. Not trying to support // this pre-ICS, because the click detection and styling are weird. if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { addButtonToNotification(n);/*from ww w . j a v a 2 s . co m*/ } return n; }
From source file:mf.stickybit.android.trackergps.LoginActivity.java
public void checkLogin(boolean isLogin) { if (isLogin) { NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); notificationManager.cancelAll(); final Intent notificationIntent = new Intent(this, MainActivity.class); notificationIntent.setAction(Intent.ACTION_MAIN); notificationIntent.addCategory(Intent.CATEGORY_LAUNCHER); Notification notification = new NotificationCompat.Builder(this) .setContentIntent(PendingIntent.getActivity(this, 0, notificationIntent, 0)) .setSmallIcon(R.drawable.trackergps_icon) .setLargeIcon(BitmapFactory.decodeResource(this.getResources(), R.drawable.trackergps_icon)) .setTicker("TrackerGPS").setWhen(System.currentTimeMillis()).setAutoCancel(false) .setContentTitle("TrackerGPS esta ejecutandose").setContentText("A la espera...").build(); notification.flags |= Notification.FLAG_NO_CLEAR; notificationManager.notify(0, notification); moveTaskToBack(true);//from w w w.j a v a2 s . c o m } else { if ((getCantidadFails() == (getResources().getInteger(R.integer.login_max_retry)))) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage("Fallo " + String.valueOf( (int) getApplicationContext().getResources().getInteger(R.integer.login_max_retry)) + " veces al iniciar sesin.") .setPositiveButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { finish(); } }); builder.show(); } else { clear(); mPasswordView.setError(getString(R.string.error_incorrect_password)); mPasswordView.requestFocus(); } } }
From source file:codepath.watsiapp.utils.Util.java
private static void startShareIntentWithExplicitSocialActivity(Activity ctx, ShareableItem patient, Set<String> socialActivitiesName, String displayName) { Intent shareIntent = new Intent(); shareIntent.setAction(Intent.ACTION_SEND); shareIntent.setType("text/plain"); shareIntent.putExtra(Intent.EXTRA_TEXT, patient.getShareableUrl()); try {//from w ww . ja v a 2 s .c om final PackageManager pm = ctx.getPackageManager(); final List activityList = pm.queryIntentActivities(shareIntent, 0); int len = activityList.size(); for (int i = 0; i < len; i++) { final ResolveInfo app = (ResolveInfo) activityList.get(i); Log.d("#####################", app.activityInfo.name); if (socialActivitiesName.contains(app.activityInfo.name)) { final ActivityInfo activity = app.activityInfo; final ComponentName name = new ComponentName(activity.applicationInfo.packageName, activity.name); shareIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); shareIntent.putExtra(Intent.EXTRA_SUBJECT, "Fund Treatment"); shareIntent.addCategory(Intent.CATEGORY_LAUNCHER); shareIntent.setComponent(name); ctx.startActivity(shareIntent); break; } } } catch (final ActivityNotFoundException e) { Toast.makeText(ctx, "Could not find " + displayName + " app", Toast.LENGTH_SHORT).show(); } }
From source file:jieehd.villain.updater.VillainUpdater.java
private boolean haveNetworkConnection() { boolean haveConnectedWifi = false; boolean haveConnectedMobile = false; ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo[] netInfo = cm.getAllNetworkInfo(); for (NetworkInfo ni : netInfo) { if (ni.getTypeName().equalsIgnoreCase("WIFI")) if (ni.isConnected()) haveConnectedWifi = true; if (ni.getTypeName().equalsIgnoreCase("MOBILE")) if (ni.isConnected()) haveConnectedMobile = true; }//from ww w. j av a 2 s . c o m if (haveConnectedWifi == false && haveConnectedMobile == false) { Log.d("Network State", "false"); AlertDialog.Builder alert = new AlertDialog.Builder(VillainUpdater.this); alert.setTitle("No Data Connection!"); alert.setMessage( "You have no data connection, click ok to turn on WiFi or Mobile Data in order to check for OTA updates."); alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { // TODO Auto-generated method stub final Intent intent = new Intent(Intent.ACTION_MAIN, null); intent.addCategory(Intent.CATEGORY_LAUNCHER); final ComponentName cn = new ComponentName("com.android.settings", "com.android.settings.wifi.WifiSettings"); intent.setComponent(cn); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); } }); alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // TODO Auto-generated method stub return; } }); alert.show(); } else { download(); } return haveConnectedWifi || haveConnectedMobile; }
From source file:org.bohrmeista.chan.ui.service.WatchNotifier.java
@SuppressWarnings("deprecation") private Notification getNotificationFor(String tickerText, String title, String content, int count, List<CharSequence> lines, boolean makeSound, Pin targetPin) { Intent intent = new Intent(this, BoardActivity.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", targetPin == null ? -1 : targetPin.id); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); NotificationCompat.Builder builder = new NotificationCompat.Builder(this); builder.setContentIntent(pendingIntent); if (tickerText != null) { tickerText = tickerText.substring(0, Math.min(tickerText.length(), 50)); }//from w ww . j av a 2 s. c o m builder.setTicker(tickerText); builder.setContentTitle(title); builder.setContentText(content); if (count >= 0) { builder.setContentInfo(Integer.toString(count)); builder.setNumber(count); } 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 (makeSound) { builder.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)); } if (lines != null) { NotificationCompat.InboxStyle style = new NotificationCompat.InboxStyle(); for (CharSequence line : lines.subList(Math.max(0, lines.size() - 10), lines.size())) { style.addLine(line); } style.setBigContentTitle(title); builder.setStyle(style); } return builder.getNotification(); }
From source file:org.androidsoft.app.permission.ui.ApplicationFragment.java
/** * Open the application/*ww w . j av a 2s . c o m*/ */ private void open() { PackageManager pm = mActivity.getPackageManager(); Intent intentOpen = pm.getLaunchIntentForPackage(mPackageName); if (intentOpen != null) { intentOpen.addCategory(Intent.CATEGORY_LAUNCHER); startActivity(intentOpen); } else { Toast.makeText(mActivity, getString(R.string.message_error_open), Toast.LENGTH_LONG).show(); } }
From source file:com.itime.team.itime.services.ITimeGcmListenerService.java
/** * Create and show a simple notification containing the received GCM message. * * @param data GCM message received./* w w w.j a v a 2 s . c o m*/ */ private void sendNotification(Bundle data) { ParcelableMessage message = new ParcelableMessage(data); if (message.messageType == null) { return; } Intent intent = new Intent(this, CheckLoginActivity.class); // Set ACTION_MAIN and CATEGORY_LAUNCHER is the key! // Even though CheckLoginActivity is finish and no longer exist, the app will return to the // foreground and CheckLoginActivity would not be created again. Demonstrated in the logcat // where on CheckLoginActivity onCreate, onResume. intent.setAction(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_LAUNCHER); // Do add this flags otherwise it will clear all the activity in the stack //intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent, PendingIntent.FLAG_ONE_SHOT); Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); String messageTitle = data.getString("alert", "ITime Message"); String messageBody = data.getString("message_body", "ITime Message"); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.ic_notifications_active_black).setContentTitle(messageTitle) .setContentText(messageBody).setAutoCancel(true).setSound(defaultSoundUri) .setContentIntent(pendingIntent); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.notify(NotificationID.getID() /* ID of notification */, notificationBuilder.build()); }
From source file:net.vivekiyer.GAL.CorporateAddressBook.java
@Override protected void onStart() { super.onStart(); FragmentManager fm = getSupportFragmentManager(); CorporateContactRecordFragment details = (CorporateContactRecordFragment) fm .findFragmentById(R.id.contact_fragment); if (details != null && details.isInLayout()) { CorporateAddressBookFragment contacts = (CorporateAddressBookFragment) fm .findFragmentById(R.id.main_fragment); contacts.setIsSelectable(true);// w w w. j a v a 2 s.c o m contacts.setViewBackground(false); FragmentTransaction ft = fm.beginTransaction(); ft.hide(details); ft.commit(); } final Intent intent = getIntent(); if (intent != null) { final Set<String> categories = intent.getCategories(); if ((categories != null) && categories.contains(Intent.CATEGORY_LAUNCHER)) { this.onSearchRequested(); } } }
From source file:org.chromium.chrome.browser.sync.SyncNotificationController.java
/** * Creates an intent that launches an activity that requests the users password/passphrase. * * @return the intent for opening the password/passphrase activity */// ww w. j a v a 2 s . com private Intent createPasswordIntent() { // Make sure we don't prompt too many times. mProfileSyncService.setPassphrasePrompted(true); Intent intent = new Intent(Intent.ACTION_MAIN); intent.setComponent(new ComponentName(mApplicationContext, mPassphraseRequestActivity)); intent.addCategory(Intent.CATEGORY_LAUNCHER); // This activity will become the start of a new task on this history stack. intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // Clears the task stack above this activity if it already exists. intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); return intent; }
From source file:kr.go.hf.hfappandroid.app.intro.IntroActivity.java
/** * ???????VGuard??( ?? ? ?? )//from w w w. jav a 2s . c o m * * @date BSJ 13/05/06 */ private void startVGuard() { if (!Common.isPackageInstalled(this, Constants.VGUARD_PACKAGE_NAME)) { dialogInstallVGuard(); return; } ComponentName cn = new ComponentName(Constants.VGUARD_PACKAGE_NAME, Constants.VGUARD_PACKAGE_NAME + Constants.VGUARD_ACTIVITY_NAME); Intent actIntent = new Intent(Intent.ACTION_MAIN); actIntent.setComponent(cn); actIntent.addCategory(Intent.CATEGORY_LAUNCHER); actIntent.putExtra("LicenseKey", Constants.VGUARD_LICENSE_KEY); startActivityForResult(actIntent, REQUEST_START_VGUARD); CLog.e("VGuard", "start"); }