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.lchtime.safetyexpress.ui.chat.hx.activity.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 a2 s . c om*/ 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:mobisocial.socialkit.musubi.Musubi.java
public static boolean isMusubiInstalled(Context context) { try {/*w ww. j a va2 s. com*/ final Intent intent = new Intent(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_LAUNCHER); intent.setPackage(SUPER_APP_ID); return context.getPackageManager().queryIntentActivities(intent, 0).size() > 0; } catch (Throwable t) { return false; } }
From source file:edu.stanford.mobisocial.dungbeetle.feed.objects.InviteToWebSessionObj.java
public void handleDirectMessage(Context context, Contact from, JSONObject obj) { String arg = obj.optString(ARG); Intent launch = new Intent(); launch.setAction(Intent.ACTION_MAIN); launch.addCategory(Intent.CATEGORY_LAUNCHER); launch.putExtra("android.intent.extra.APPLICATION_ARGUMENT", arg); launch.putExtra("creator", false); launch.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); String webUrl = obj.optString(WEB_URL); launch.setData(Uri.parse(webUrl));/* w w w . j ava 2 s . c o m*/ PendingIntent contentIntent = PendingIntent.getActivity(context, 0, launch, PendingIntent.FLAG_CANCEL_CURRENT); (new PresenceAwareNotify(context)).notify("New Invitation", "Invitation received", "Click to launch application.", contentIntent); }
From source file:com.example.android.repeatingalarm.RepeatingAlarmFragment.java
@Override public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == R.id.sample_action) { // BEGIN_INCLUDE (intent_fired_by_alarm) // First create an intent for the alarm to activate. // This code simply starts an Activity, or brings it to the front if it has already // been created. Intent intent = new Intent(getActivity(), MainActivity.class); intent.setAction(Intent.ACTION_MAIN); intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); // END_INCLUDE (intent_fired_by_alarm) // BEGIN_INCLUDE (pending_intent_for_alarm) // Because the intent must be fired by a system service from outside the application, // it's necessary to wrap it in a PendingIntent. Providing a different process with // a PendingIntent gives that other process permission to fire the intent that this // application has created. // Also, this code creates a PendingIntent to start an Activity. To create a // BroadcastIntent instead, simply call getBroadcast instead of getIntent. PendingIntent pendingIntent = PendingIntent.getActivity(getActivity(), REQUEST_CODE, intent, 0); // END_INCLUDE (pending_intent_for_alarm) // BEGIN_INCLUDE (configure_alarm_manager) // There are two clock types for alarms, ELAPSED_REALTIME and RTC. // ELAPSED_REALTIME uses time since system boot as a reference, and RTC uses UTC (wall // clock) time. This means ELAPSED_REALTIME is suited to setting an alarm according to // passage of time (every 15 seconds, 15 minutes, etc), since it isn't affected by // timezone/locale. RTC is better suited for alarms that should be dependant on current // locale. // Both types have a WAKEUP version, which says to wake up the device if the screen is // off. This is useful for situations such as alarm clocks. Abuse of this flag is an // efficient way to skyrocket the uninstall rate of an application, so use with care. // For most situations, ELAPSED_REALTIME will suffice. int alarmType = AlarmManager.ELAPSED_REALTIME; final int FIFTEEN_SEC_MILLIS = 15000; // The AlarmManager, like most system services, isn't created by application code, but // requested from the system. AlarmManager alarmManager = (AlarmManager) getActivity().getSystemService(getActivity().ALARM_SERVICE); // setRepeating takes a start delay and period between alarms as arguments. // The below code fires after 15 seconds, and repeats every 15 seconds. This is very // useful for demonstration purposes, but horrendous for production. Don't be that dev. alarmManager.setRepeating(alarmType, SystemClock.elapsedRealtime() + FIFTEEN_SEC_MILLIS, FIFTEEN_SEC_MILLIS, pendingIntent); // END_INCLUDE (configure_alarm_manager); Log.i("RepeatingAlarmFragment", "Alarm set."); }/*from www . j a v a 2 s.c om*/ return true; }
From source file:me.tassoevan.cordova.GoHomePlugin.java
private boolean doGoHomeAction(JSONArray args, CallbackContext callbackContext) { try {// www. j a va2 s . com Intent i = new Intent(Intent.ACTION_MAIN); i.addCategory(Intent.CATEGORY_HOME); this.cordova.getActivity().startActivity(i); callbackContext.success(); return true; } catch (Exception e) { this.logError("Exception occurred: ".concat(e.getMessage())); callbackContext.error("Exception occurred: ".concat(e.getMessage())); return false; } }
From source file:com.zhi.android.modules.splash.SplashActivity.java
@Override @SuppressWarnings({ "CheckReturnValue", "unchecked" }) protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); mTimerObservable = Observable.timer(1000, TimeUnit.MILLISECONDS).subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()); mTimerObservable.subscribe(aLong -> { mTimerObservable = null;/*from ww w . j a v a 2s. c om*/ final Intent intent = getIntent(); final Intent nextIntent; if (intent != null && intent.hasExtra(BuildConfig.NEXT_INTENT)) { nextIntent = intent.getParcelableExtra(BuildConfig.NEXT_INTENT); } else { nextIntent = new Intent(Intent.ACTION_MAIN); } nextIntent.addCategory(Intent.CATEGORY_DEFAULT); ActivityCompat.startActivity(SplashActivity.this, nextIntent, ActivityOptionsCompat.makeSceneTransitionAnimation(SplashActivity.this).toBundle()); supportFinishAfterTransition(); }); }
From source file:org.mozilla.focus.fragment.HomeFragment.java
@Override public void onAttach(Context context) { super.onAttach(context); final FragmentActivity activity = getActivity(); // No safe intent needed here - intent.getAction() is always safe: if (activity != null && Intent.ACTION_VIEW.equals(activity.getIntent().getAction())) { // If this activity was launched from a ACTION_VIEW intent then pressing back will send // the user back to the previous application (finishing this activity). However if the // user presses "erase" we will send the user back to the home screen. Pressing back // in a new browsing session should send the user back to the home screen instead of // the previous app. Therefore we clear the intent once we show the home screen. activity.setIntent(new Intent(Intent.ACTION_MAIN)); }//from w w w .j a v a2s . com }
From source file:com.dm.material.dashboard.candybar.helpers.RequestHelper.java
@NonNull public static List<Request> loadMissingApps(@NonNull Context context) { List<Request> requests = new ArrayList<>(); Database database = new Database(context); String activities = RequestHelper.loadAppFilter(context); PackageManager packageManager = context.getPackageManager(); Intent intent = new Intent(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_LAUNCHER); List<ResolveInfo> installedApps = packageManager.queryIntentActivities(intent, PackageManager.GET_RESOLVED_FILTER); CandyBarMainActivity.sInstalledAppsCount = installedApps.size(); try {/*ww w.j a v a2 s . c om*/ Collections.sort(installedApps, new ResolveInfo.DisplayNameComparator(packageManager)); } catch (Exception ignored) { } for (ResolveInfo app : installedApps) { String packageName = app.activityInfo.packageName; String activity = packageName + "/" + app.activityInfo.name; if (!activities.contains(activity)) { String name = LocaleHelper.getOtherAppLocaleName(context, new Locale("en-US"), packageName); if (name == null) name = app.activityInfo.loadLabel(packageManager).toString(); boolean requested = database.isRequested(activity); requests.add(new Request(name, app.activityInfo.packageName, activity, requested)); } } return requests; }
From source file:edu.stanford.mobisocial.dungbeetle.feed.objects.IMObj.java
public void handleDirectMessage(Context context, Contact from, JSONObject obj) { Intent launch = new Intent(); launch.setAction(Intent.ACTION_MAIN); launch.addCategory(Intent.CATEGORY_LAUNCHER); launch.setComponent(new ComponentName(context.getPackageName(), HomeActivity.class.getName())); PendingIntent contentIntent = PendingIntent.getActivity(context, 0, launch, PendingIntent.FLAG_CANCEL_CURRENT); String msg = obj.optString(TEXT); (new PresenceAwareNotify(context)).notify("IM from " + from.name, "IM from " + from.name, "\"" + msg + "\"", contentIntent);/* w w w . j ava 2 s . co m*/ }
From source file:org.wahtod.wififixer.utility.NotifUtil.java
private static Notification build(Context ctxt, NotificationCompat.Builder builder, StatusMessage in) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) return builder.build(); Intent intent = new Intent(ctxt, MainActivity.class).setAction(Intent.ACTION_MAIN) .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); Notification out = builder.build(); out.icon = getIconfromSignal(in.getSignal(), NotifUtil.ICON_SET_SMALL); out.iconLevel = in.getSignal();//ww w.j ava2 s. co m /*out.setLatestEventInfo(ctxt, ctxt.getString(R.string.app_name), in.getSSID() + NotifUtil.SEPARATOR + in.getStatus(), PendingIntent.getActivity(ctxt, getPendingIntentCode(), intent, PendingIntent.FLAG_UPDATE_CURRENT) );*/ return out; }