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:org.openlmis.core.view.activity.LoginActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (!isTaskRoot() && getIntent().hasCategory(Intent.CATEGORY_LAUNCHER) && Intent.ACTION_MAIN.equals(getIntent().getAction())) { finish();//from ww w .j a va 2 s . c o m return; } initUI(); restoreFromResync(); }
From source file:jahirfiquitiva.iconshowcase.utilities.utils.Utils.java
public static String getDefaultLauncherPackage(@NonNull Context context) { final Intent intent = new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_HOME); final ResolveInfo resolveInfo = context.getPackageManager().resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY); return resolveInfo.activityInfo.packageName; }
From source file:com.nhn.android.archetype.base.AABaseApplicationOrg.java
public static void applicationAllKill() { final ActivityManager am = (ActivityManager) _internalInstance.getSystemService(Activity.ACTIVITY_SERVICE); // stop running service inside current process. List<RunningServiceInfo> serviceList = am.getRunningServices(100); for (RunningServiceInfo service : serviceList) { if (service.pid == android.os.Process.myPid()) { Intent stop = new Intent(); stop.setComponent(service.service); _internalInstance.stopService(stop); }/*from w ww. j a va 2 s.c o m*/ } // move current task to background. Intent launchHome = new Intent(Intent.ACTION_MAIN); launchHome.addCategory(Intent.CATEGORY_DEFAULT); launchHome.addCategory(Intent.CATEGORY_HOME); _internalInstance.startActivity(launchHome); // post delay runnable(waiting for home application launching) new Handler().postDelayed(new Runnable() { public void run() { am.killBackgroundProcesses(_internalInstance.getPackageName()); } }, 2000); }
From source file:com.denimgroup.android.training.pandemobium.stocktrader.ManageTipsActivity.java
/** Called when the activity is first created. */ @Override//from ww w.ja v a 2 s. c o m public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.managetips); etSymbol = (EditText) findViewById(R.id.et_symbol); etTargetPrice = (EditText) findViewById(R.id.et_target_price); etReason = (EditText) findViewById(R.id.et_reason); btnSaveTip = (Button) findViewById(R.id.btn_save_tip); btnSaveTip.setOnClickListener(this); tvTipStatus = (TextView) findViewById(R.id.tv_tip_status); if (Intent.ACTION_MAIN.equals(getIntent().getAction())) { Log.d("ManageTipsActivity", "Action launched manually"); } else { Uri data = getIntent().getData(); if (data == null) { Log.i("ManageTipsActivity", "No data passed with intent"); } else { Uri tradeUri = getIntent().getData(); Log.i("ManageTipsActivity", "Intent launched with data: " + tradeUri.toString()); String symbol = tradeUri.getQueryParameter("symbol").toUpperCase(); // test ... //String target_price = tradeUri.getQueryParameter("target_price"); doSendTipData(symbol); } } }
From source file:io.selendroid.ServerInstrumentation.java
public void startActivity(Class activity) { if (activity == null) { SelendroidLogger.log("activity class is empty", new NullPointerException("Activity class to start is null.")); return;/*from w w w . j a v a 2 s .com*/ } finishAllActivities(); // start now the new activity Intent intent = new Intent(getTargetContext(), activity); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_REORDER_TO_FRONT | Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.setAction(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_LAUNCHER); Activity a = startActivitySync(intent); }
From source file:com.google.android.gms.nearby.messages.samples.nearbybackgroundbeacons.BackgroundSubscribeIntentService.java
private void updateNotification() { List<String> messages = Utils.getCachedMessages(getApplicationContext()); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); Intent launchIntent = new Intent(getApplicationContext(), MainActivity.class); launchIntent.setAction(Intent.ACTION_MAIN); launchIntent.addCategory(Intent.CATEGORY_LAUNCHER); PendingIntent pi = PendingIntent.getActivity(getApplicationContext(), 0, launchIntent, PendingIntent.FLAG_UPDATE_CURRENT); String contentTitle = getContentTitle(messages); String contentText = getContentText(messages); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) .setSmallIcon(android.R.drawable.star_on).setContentTitle(contentTitle).setContentText(contentText) .setStyle(new NotificationCompat.BigTextStyle().bigText(contentText)).setOngoing(true) .setContentIntent(pi);//from ww w. ja v a 2 s .co m notificationManager.notify(MESSAGES_NOTIFICATION_ID, notificationBuilder.build()); }
From source file:com.lee.sdk.utils.Utils.java
/** * ????//from w w w. jav a2 s.co m * * @param activity ?Activity??? * @param nameId ???? * @param iconId ?? * @param appendFlags ????IntentFlag */ public static void addShortcut(Activity activity, int nameId, int iconId, int appendFlags) { Intent shortcut = new Intent("com.android.launcher.action.INSTALL_SHORTCUT"); // ???? shortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME, activity.getString(nameId)); shortcut.putExtra("duplicate", false); // ???? // ?Activity??? ComponentName comp = new ComponentName(activity.getPackageName(), activity.getClass().getName()); Intent intent = new Intent(Intent.ACTION_MAIN).setComponent(comp); if (appendFlags != 0) { intent.addFlags(appendFlags); } shortcut.putExtra(Intent.EXTRA_SHORTCUT_INTENT, intent); // ?? ShortcutIconResource iconRes = Intent.ShortcutIconResource.fromContext(activity, iconId); shortcut.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, iconRes); activity.sendBroadcast(shortcut); }
From source file:com.gigathinking.simpleapplock.ResetUnlockMethod.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.layout_reset); getActionBar().setDisplayHomeAsUpEnabled(true); mDialog = new ProgressDialog(this, ProgressDialog.STYLE_SPINNER); mDialog.setIndeterminate(true);/*from ww w. j a v a 2s . c o m*/ prefs = PreferenceManager.getDefaultSharedPreferences(this); mResetReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { prefs.edit().putString(AppLockApplication.LOCKTYPE, AppLockApplication.LOCKTYPE_PIN).commit(); prefs.edit() .putString(AppLockApplication.PASSWORD, intent.getStringExtra(AppLockApplication.PASSWORD)) .commit(); Toast.makeText(context, getString(R.string.pin_reset), Toast.LENGTH_LONG).show(); startActivity(new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_HOME) .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)); //startActivity(new Intent(ResetUnlockMethod.this,UnlockWithPIN.class).putExtra("test","test")); finish(); } }; LocalBroadcastManager.getInstance(this).registerReceiver(mResetReceiver, new IntentFilter(AppLockApplication.RESET_UNLOCK)); if (!PreferenceManager.getDefaultSharedPreferences(this).getBoolean(getString(R.string.register_complete), false)) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage(getString(R.string.reset_register_device)); builder.setTitle(getString(R.string.info)); builder.setPositiveButton(getString(R.string.register), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { new Register().execute(); if (mDialog != null) { mDialog.setMessage(getString(R.string.register_ongoing)); mDialog.show(); } dialog.dismiss(); } }); builder.setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); finish(); Intent intent = new Intent(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_HOME); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); } }); builder.create().show(); } else { if (mDialog != null) { mDialog.setMessage(getString(R.string.connect_to_server)); mDialog.show(); } new DoRequestReset().execute(); } }
From source file:com.gigaset.home.Home.java
/** * Handle reopen this Activity//from w w w . j av a 2 s . c o m */ @Override protected void onNewIntent(Intent intent) { super.onNewIntent(intent); // Close the menu if (Intent.ACTION_MAIN.equals(intent.getAction())) { getWindow().closeAllPanels(); } }
From source file:com.android.test.uibench.MainActivity.java
protected List<Map<String, Object>> getData(String prefix) { List<Map<String, Object>> myData = new ArrayList<>(); Intent mainIntent = new Intent(Intent.ACTION_MAIN, null); mainIntent.addCategory(CATEGORY_HWUI_TEST); PackageManager pm = getPackageManager(); List<ResolveInfo> list = pm.queryIntentActivities(mainIntent, 0); if (null == list) return myData; String[] prefixPath;/* ww w . j a v a2 s . c om*/ String prefixWithSlash = prefix; if (prefix.equals("")) { prefixPath = null; } else { prefixPath = prefix.split("/"); prefixWithSlash = prefix + "/"; } int len = list.size(); Map<String, Boolean> entries = new HashMap<>(); for (int i = 0; i < len; i++) { ResolveInfo info = list.get(i); CharSequence labelSeq = info.loadLabel(pm); String label = labelSeq != null ? labelSeq.toString() : info.activityInfo.name; if (prefixWithSlash.length() == 0 || label.startsWith(prefixWithSlash)) { String[] labelPath = label.split("/"); String nextLabel = prefixPath == null ? labelPath[0] : labelPath[prefixPath.length]; if ((prefixPath != null ? prefixPath.length : 0) == labelPath.length - 1) { addItem(myData, nextLabel, activityIntent(info.activityInfo.applicationInfo.packageName, info.activityInfo.name)); } else { if (entries.get(nextLabel) == null) { addItem(myData, nextLabel, browseIntent(prefix.equals("") ? nextLabel : prefix + "/" + nextLabel)); entries.put(nextLabel, true); } } } } Collections.sort(myData, sDisplayNameComparator); return myData; }