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.apexlabs.alarm.AlarmService.java
private Intent getClockIntent() { PackageManager packageManager = getPackageManager(); Intent alarmClockIntent = new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_LAUNCHER); // Verify clock implementation String clockImpls[][] = {/* ww w . j a v a2 s .co m*/ { "HTC", "com.htc.android.worldclock", "com.htc.android.worldclock.WorldClockTabControl" }, { "Standard", "com.android.deskclock", "com.android.deskclock.AlarmClock" }, { "Froyo", "com.google.android.deskclock", "com.android.deskclock.DeskClock" }, { "Motorola", "com.motorola.blur.alarmclock", "com.motorola.blur.alarmclock.AlarmClock" }, { "Sony Ericsson", "com.sonyericsson.alarm", "com.sonyericsson.alarm.Alarm" }, { "Samsung", "com.sec.android.app.clockpackage", "com.sec.android.app.clockpackage.ClockPackage" } }; boolean foundClockImpl = false; for (int i = 0; i < clockImpls.length; i++) { String packageName = clockImpls[i][1]; String className = clockImpls[i][2]; try { ComponentName cn = new ComponentName(packageName, className); packageManager.getActivityInfo(cn, PackageManager.GET_META_DATA); alarmClockIntent.setComponent(cn); foundClockImpl = true; break; } catch (NameNotFoundException e) { Log.d(TAG, "Alarm clock " + clockImpls[i][0] + " not found"); } } if (foundClockImpl) { alarmClockIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); } return alarmClockIntent; }
From source file:com.anykey.balala.activity.MainActivity.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { Intent intent = new Intent(Intent.ACTION_MAIN); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.addCategory(Intent.CATEGORY_HOME); startActivity(intent);//from www .ja v a 2 s .c o m return true; } return super.onKeyDown(keyCode, event); }
From source file:cn.newgxu.android.notty.MainActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.dark_theme: ThemeUtils.apply(this, ThemeUtils.DARK_THEME); break;//w w w . j a v a2 s . c o m case R.id.light_theme: ThemeUtils.apply(this, ThemeUtils.LIGHT_THEME); break; case R.id.refresh: Intent intent = new Intent(this, FetchService.class); String[] uris = { C.BASE_URI + C.NOTICES, C.BASE_URI + C.USERS }; intent.putExtra("uris", uris); // TODO: ??? intent.putExtra(C.URI, C.DOMAIN + "/info/notices?type=4&count=50"); startService(intent); break; case R.id.logout: Intent i = new Intent(Intent.ACTION_MAIN); i.addCategory(Intent.CATEGORY_HOME); i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(i); break; case R.id.about: AboutBoxDialogFragment about = new AboutBoxDialogFragment(); about.show(fm, "about"); break; default: break; } return true; }
From source file:menion.android.whereyougo.gui.extension.activity.CustomActivity.java
public static void setStatusbar(Activity activity) { try {/*from ww w.ja v a2 s. c o m*/ NotificationManager mNotificationManager = (NotificationManager) activity .getSystemService(Context.NOTIFICATION_SERVICE); // set statusbar if (Preferences.APPEARANCE_STATUSBAR) { Context context = activity.getApplicationContext(); Intent intent = new Intent(context, menion.android.whereyougo.gui.activity.MainActivity.class); // intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); intent.addCategory(Intent.CATEGORY_LAUNCHER); intent.setAction(Intent.ACTION_MAIN); PendingIntent pIntent = PendingIntent.getActivity(context, 0, intent, 0); final int sdkVersion = Integer.parseInt(android.os.Build.VERSION.SDK); Notification notif = null; if (sdkVersion < android.os.Build.VERSION_CODES.HONEYCOMB) { notif = new Notification(R.drawable.ic_title_logo, A.getAppName(), System.currentTimeMillis()); notif.setLatestEventInfo(activity, A.getAppName(), "", pIntent); } else { NotificationCompat.Builder builder = new NotificationCompat.Builder(activity) .setContentTitle(A.getAppName()).setSmallIcon(R.drawable.ic_title_logo) .setContentIntent(pIntent); notif = builder.build(); } notif.flags = Notification.FLAG_ONGOING_EVENT; mNotificationManager.notify(0, notif); } else { mNotificationManager.cancel(0); } } catch (Exception e) { // Logger.e(TAG, "setStatusbar(" + activity + ")", e); } }
From source file:com.quickcar.thuexe.UI.ListPassengerActivity.java
private void initComponents() { imgMenu = (ImageView) findViewById(R.id.img_menu); btnBack = (ImageView) findViewById(R.id.img_back); btnBack.setOnClickListener(new View.OnClickListener() { @Override/*from w w w . j a v a2s . c o m*/ public void onClick(View v) { if (doubleBackToExitPressedOnce) { Intent intent = new Intent(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_HOME); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); } else { Toast.makeText(mContext, getResources().getString(R.string.notice_close_app), Toast.LENGTH_SHORT).show(); doubleBackToExitPressedOnce = true; new Handler().postDelayed(new Runnable() { @Override public void run() { doubleBackToExitPressedOnce = false; } }, 2000); } } }); imgMenu.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { PopupMenu popup = new PopupMenu(ListPassengerActivity.this, v); MenuInflater inflater = popup.getMenuInflater(); inflater.inflate(R.menu.intro_menu_owner, popup.getMenu()); popup.show(); popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { switch (item.getItemId()) { case R.id.edit_user: Intent intent = new Intent(ListPassengerActivity.this, EditOwnerActivity.class); startActivity(intent); return true; case R.id.share_social: showDialogShareSocial(); return true; case R.id.change_role: showDialogSwitchUser(); return true; } return false; } }); } }); if (!preference.getRegisterToken()) { dialog = new ProgressDialog(mContext); dialog.setMessage("?ang ti d liu"); dialog.setCanceledOnTouchOutside(false); dialog.setCancelable(false); dialog.show(); registerToken(preference.getToken()); } viewPager = (ViewPager) findViewById(R.id.viewpager); setupViewPager(viewPager); tabLayout = (TabLayout) findViewById(R.id.tabs); tabLayout.setupWithViewPager(viewPager); setupTabIcons(); }
From source file:com.github.chenxiaolong.dualbootpatcher.patcher.PatcherService.java
private void patchFile(Bundle data) { Intent resultIntent = new Intent(this, MainActivity.class); resultIntent.addCategory(Intent.CATEGORY_LAUNCHER); resultIntent.setAction(Intent.ACTION_MAIN); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, resultIntent, 0); final Notification.Builder builder = new Notification.Builder(this); builder.setSmallIcon(R.drawable.ic_launcher); builder.setOngoing(true);/*from w w w.j a v a 2 s. c o m*/ builder.setContentTitle(getString(R.string.overall_progress)); builder.setContentIntent(pendingIntent); builder.setProgress(0, 0, true); final NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); nm.notify(1, builder.build()); Patcher.ProgressListener listener = new Patcher.ProgressListener() { @Override public void onProgressUpdated(long bytes, long maxBytes) { updateProgress(bytes, maxBytes); } @Override public void onFilesUpdated(long files, long maxFiles) { builder.setContentText(String.format(getString(R.string.overall_progress_files), files, maxFiles)); builder.setProgress((int) maxFiles, (int) files, false); nm.notify(1, builder.build()); updateFiles(files, maxFiles); } @Override public void onDetailsUpdated(String text) { updateDetails(text); } }; Bundle result = PatcherUtils.patchFile(this, data, listener); if (result != null) { String newFile = result.getString(PatcherUtils.RESULT_PATCH_FILE_NEW_FILE); int errorCode = result.getInt(PatcherUtils.RESULT_PATCH_FILE_ERROR_CODE); boolean failed = result.getBoolean(PatcherUtils.RESULT_PATCH_FILE_FAILED); onPatchedFile(failed, errorCode, newFile); } nm.cancel(1); }
From source file:com.money.manager.ex.currency.list.CurrencyListFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); MoneyManagerApplication.getApp().iocComponent.inject(this); mAction = getActivity().getIntent().getAction(); if (mAction.equals(Intent.ACTION_MAIN)) { mAction = Intent.ACTION_EDIT;//from w ww .j a v a 2 s . c om } // Filter currencies only if in the standalone Currencies list. Do not filter in pickers. mShowOnlyUsedCurrencies = !mAction.equals(Intent.ACTION_PICK); loaderCallbacks = initLoaderCallbacks(); }
From source file:org.cyanogenmod.theme.chooser.ChooserActivity.java
private void handleIntent(final Intent intent) { //Determine if there we need to filter by component (ex icon sets only) Bundle extras = intent.getExtras();//from w w w. java 2 s. c o m String filter = (extras == null) ? null : extras.getString(EXTRA_COMPONENT_FILTER); // If activity started by wallpaper chooser then filter on wallpapers if (Intent.ACTION_SET_WALLPAPER.equals(intent.getAction())) { filter = "mods_homescreen"; } // Support filters passed in as csv. Since XML prefs do not support // passing extras in as arrays. ArrayList<String> filtersList = new ArrayList<String>(); if (filter != null) { String[] filters = filter.split(","); filtersList.addAll(Arrays.asList(filters)); } Fragment fragment = null; if (Intent.ACTION_MAIN.equals(intent.getAction()) && intent.hasExtra(EXTRA_PKGNAME)) { String pkgName = intent.getStringExtra(EXTRA_PKGNAME); fragment = ChooserDetailFragment.newInstance(pkgName, filtersList); // Handle case where Theme Store or some other app wishes to open // a detailed theme view for a given package try { final PackageManager pm = getPackageManager(); if (pm.getPackageInfo(pkgName, 0) == null) { fragment = ChooserBrowseFragment.newInstance(filtersList); } } catch (PackageManager.NameNotFoundException e) { fragment = ChooserBrowseFragment.newInstance(filtersList); } } else { fragment = ChooserBrowseFragment.newInstance(filtersList); } getSupportFragmentManager().beginTransaction().replace(R.id.content, fragment, "ChooserBrowseFragment") .commit(); }
From source file:com.chale22.ico01.fragments.FragmentExtras.java
private void actWallpapers() { String pkg = getResources().getString(R.string.pkg); Intent wallpapers = new Intent(Intent.ACTION_MAIN); wallpapers.setComponent(new ComponentName(pkg, pkg + ".wallpaper")); try {// ww w .ja v a 2s. c o m startActivity(wallpapers); } catch (RuntimeException wall) { wall.printStackTrace(); } }
From source file:com.tesfayeabel.lolchat.ui.MainActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.action_leave: finish();//from w w w. j a va 2s . c o m stopService(new Intent(this, ChatService.class)); Intent mainIntent = new Intent(this, LoginActivity.class); mainIntent.setAction(Intent.ACTION_MAIN); mainIntent.addCategory(Intent.CATEGORY_LAUNCHER); startActivity(mainIntent); return true; case R.id.action_about: Intent aboutActivity = new Intent(this, AboutActivity.class); startActivity(aboutActivity); return true; default: return super.onOptionsItemSelected(item); } }