List of usage examples for android.content Intent ACTION_MAIN
String ACTION_MAIN
To view the source code for android.content Intent ACTION_MAIN.
Click Source Link
From source file:com.sentaroh.android.SMBSync.NotificationUtil.java
@SuppressWarnings("deprecation") static final public void initNotification(GlobalParameters gwa) { gwa.notificationManager = (NotificationManager) gwa.svcContext .getSystemService(Context.NOTIFICATION_SERVICE); gwa.notification = new Notification(R.drawable.ic_32_smbsync, gwa.svcContext.getString(R.string.app_name), 0);//ww w .j a v a2 s. c om gwa.notificationAppName = gwa.svcContext.getString(R.string.app_name); gwa.notificationIntent = new Intent(gwa.svcContext, SMBSyncMain.class); gwa.notificationIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); gwa.notificationIntent.setAction(Intent.ACTION_MAIN); gwa.notificationIntent.addCategory(Intent.CATEGORY_LAUNCHER); gwa.notificationPendingIntent = PendingIntent.getActivity(gwa.svcContext, 0, gwa.notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT); gwa.notificationBuilder = new NotificationCompat.Builder(gwa.svcContext); gwa.notificationBuilder.setContentIntent(gwa.notificationPendingIntent) // .setTicker(gwa.notificationAppName) .setOngoing(true).setAutoCancel(false).setSmallIcon(gwa.notificationIcon)//smbsync_animation) .setContentTitle(gwa.notificationAppName).setContentText("") // .setSubText("subtext") // .setLargeIcon(largeIcon) .setWhen(0) // .addAction(action_icon, action_title, action_pi) ; gwa.notification = gwa.notificationBuilder.build(); if (Build.VERSION.SDK_INT >= 16) {//JB(4.1 gwa.notificationBigTextStyle = new NotificationCompat.BigTextStyle(gwa.notificationBuilder); gwa.notificationBigTextStyle.setBigContentTitle(gwa.notificationLastShowedTitle) .bigText(gwa.notificationLastShowedMessage); } }
From source file:com.sentaroh.android.TextFileBrowser.NotificationUtil.java
@SuppressWarnings("deprecation") static final public void initNotification(Context c, NotificationCommonParms gwa) { gwa.notificationManager = (NotificationManager) c.getSystemService(Context.NOTIFICATION_SERVICE); gwa.notification = new Notification(R.drawable.ic_32_browse_text, c.getString(R.string.app_name), 0); gwa.notificationAppName = c.getString(R.string.app_name); gwa.notificationIntent = new Intent(c, MainActivity.class); gwa.notificationIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); gwa.notificationIntent.setAction(Intent.ACTION_MAIN); gwa.notificationIntent.addCategory(Intent.CATEGORY_LAUNCHER); gwa.notificationPendingIntent = PendingIntent.getActivity(c, 0, gwa.notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT); buildNotification(c, gwa);// ww w. j a v a 2 s . c o m }
From source file:org.apache.cordova.home.Home.java
@Override public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException { if ("goHome".equals(action)) { try {// w ww .jav a 2s. co m Intent i = new Intent(Intent.ACTION_MAIN); i.addCategory(Intent.CATEGORY_HOME); this.cordova.getActivity().startActivity(i); } catch (Exception e) { Log.e(LOG_TAG, "Exception occurred: ".concat(e.getMessage())); return false; } callbackContext.success(); return true; } Log.e(LOG_TAG, "Called invalid action: " + action); return false; }
From source file:com.dmcc.chatlibrary.ui.EaseBaseActivity.java
@Override protected void onCreate(Bundle arg0) { super.onCreate(arg0); //http://stackoverflow.com/questions/4341600/how-to-prevent-multiple-instances-of-an-activity-when-it-is-launched-with-differ/ //?launcher activity,?app??? if (!isTaskRoot()) { Intent intent = getIntent();//w w w . j av a2 s. co m String action = intent.getAction(); if (intent.hasCategory(Intent.CATEGORY_LAUNCHER) && action.equals(Intent.ACTION_MAIN)) { finish(); return; } } }
From source file:com.sentaroh.android.SMBSync2.NotificationUtil.java
@SuppressWarnings("deprecation") static final public void initNotification(GlobalParameters gwa) { gwa.notificationManager = (NotificationManager) gwa.appContext .getSystemService(Context.NOTIFICATION_SERVICE); gwa.notification = new Notification(R.drawable.ic_48_smbsync_wait, gwa.appContext.getString(R.string.app_name), 0); gwa.notificationAppName = gwa.appContext.getString(R.string.app_name); gwa.notificationIntent = new Intent(gwa.appContext, ActivityMain.class); gwa.notificationIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); gwa.notificationIntent.setAction(Intent.ACTION_MAIN); gwa.notificationIntent.addCategory(Intent.CATEGORY_LAUNCHER); gwa.notificationPendingIntent = PendingIntent.getActivity(gwa.appContext, 0, gwa.notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT); gwa.notificationLargeIcon = BitmapFactory.decodeResource(gwa.appContext.getResources(), gwa.notificationSmallIcon);// ww w .j av a2 s .co m gwa.notificationBuilder = new NotificationCompat.Builder(gwa.appContext); gwa.notificationBuilder.setContentIntent(gwa.notificationPendingIntent) // .setTicker(gwa.notificationAppName) .setOngoing(true).setAutoCancel(false).setSmallIcon(R.drawable.ic_48_smbsync_wait)//smbsync_animation) .setLargeIcon(gwa.notificationLargeIcon).setContentTitle(gwa.notificationAppName).setContentText("") // .setSubText("subtext") // .setLargeIcon(largeIcon) .setWhen(0) // .addAction(action_icon, action_title, action_pi) ; gwa.notification = gwa.notificationBuilder.build(); gwa.notificationBigTextStyle = new NotificationCompat.BigTextStyle(gwa.notificationBuilder); gwa.notificationBigTextStyle.setBigContentTitle(gwa.notificationLastShowedTitle) .bigText(gwa.notificationLastShowedMessage); }
From source file:org.duckdns.raven.ttscallresponder.ui.notification.CallReceiverNotificationFactory.java
public Notification buildCallReceiverNotification(boolean enabled) { String newText = null;/* w w w . j a v a 2s .com*/ // Create Text newText = "AutoResponder "; if (enabled) { newText += "enabled"; } else { newText += "disabled"; } // Create Notification NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this.context) .setContentTitle(this.context.getResources().getString(R.string.app_name)).setContentText(newText) .setSmallIcon(R.drawable.ic_launcher).setOngoing(true); // Create Intent Intent bringMainToFront = new Intent(this.context, MainActivity.class); bringMainToFront.setAction(Intent.ACTION_MAIN); bringMainToFront.addCategory(Intent.CATEGORY_LAUNCHER); PendingIntent resultPendingIntent = PendingIntent.getActivity(this.context, 0, bringMainToFront, 0); mBuilder.setContentIntent(resultPendingIntent); return mBuilder.build(); }
From source file:com.farmerbb.taskbar.activity.KeyboardShortcutActivity.java
@SuppressWarnings("deprecation") @Override/*w w w . j av a 2s . c o m*/ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Perform different actions depending on how this activity was launched switch (getIntent().getAction()) { case Intent.ACTION_MAIN: Intent selector = getIntent().getSelector(); Set<String> categories = selector != null ? selector.getCategories() : getIntent().getCategories(); if (categories.contains(Intent.CATEGORY_APP_MAPS)) { SharedPreferences pref = U.getSharedPreferences(this); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && pref.getBoolean("freeform_hack", false) && isInMultiWindowMode() && !FreeformHackHelper.getInstance().isFreeformHackActive()) { U.startFreeformHack(this, false, false); } Intent startStopIntent; if (pref.getBoolean("taskbar_active", false)) startStopIntent = new Intent("com.farmerbb.taskbar.QUIT"); else startStopIntent = new Intent("com.farmerbb.taskbar.START"); startStopIntent.setPackage(BuildConfig.APPLICATION_ID); sendBroadcast(startStopIntent); } else if (categories.contains(Intent.CATEGORY_APP_CALENDAR)) U.lockDevice(this); break; case Intent.ACTION_ASSIST: if (U.isServiceRunning(this, StartMenuService.class)) { LocalBroadcastManager.getInstance(this) .sendBroadcast(new Intent("com.farmerbb.taskbar.TOGGLE_START_MENU")); } else { Intent intent = new Intent("com.google.android.googlequicksearchbox.TEXT_ASSIST"); if (intent.resolveActivity(getPackageManager()) == null) intent = new Intent(SearchManager.INTENT_ACTION_GLOBAL_SEARCH); if (intent.resolveActivity(getPackageManager()) != null) { SharedPreferences pref = U.getSharedPreferences(this); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && pref.getBoolean("freeform_hack", false) && isInMultiWindowMode()) { intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_MULTIPLE_TASK); U.launchAppMaximized(getApplicationContext(), intent); } else { intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent); } } } break; } finish(); }
From source file:love.juhe.androidmonkey.MonkeyActivityEvent.java
/** * @return Intent for the new activity/*from w w w .j a v a 2 s . c o m*/ */ private Intent getEvent() { Intent intent = new Intent(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_LAUNCHER); intent.setComponent(mApp); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); return intent; }
From source file:com.callba.phone.ui.ease.EaseBaseActivity.java
@Override protected void onCreate(Bundle arg0) { super.onCreate(arg0); //http://stackoverflow.com/questions/4341600/how-to-prevent-multiple-instances-of-an-activity-when-it-is-launched-with-differ/ //?launcher activity,?app??? if (!isTaskRoot()) { Intent intent = getIntent();// ww w .j a v a 2 s . co m String action = intent.getAction(); if (intent.hasCategory(Intent.CATEGORY_LAUNCHER) && action.equals(Intent.ACTION_MAIN)) { finish(); return; } } inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); }
From source file:cn.xcom.helper.chat.easeui.ui.EaseBaseActivity.java
@Override protected void onCreate(Bundle arg0) { super.onCreate(arg0); //http://stackoverflow.com/questions/4341600/how-to-prevent-multiple-instances-of-an-activity-when-it-is-launched-with-differ/ // should be in launcher activity, but all app use this can avoid the problem if (!isTaskRoot()) { Intent intent = getIntent();// w w w .j a v a 2 s .c o m String action = intent.getAction(); if (intent.hasCategory(Intent.CATEGORY_LAUNCHER) && action.equals(Intent.ACTION_MAIN)) { finish(); return; } } inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); }