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.appmanager.parimal.activity.MainActivity.java
private void loadApps() { manager = this.getPackageManager(); apps = new ArrayList<AppDetail>(); Intent i = new Intent(Intent.ACTION_MAIN, null); i.addCategory(Intent.CATEGORY_LAUNCHER); AppEntryDBHelper mDbHelper = new AppEntryDBHelper(getApplicationContext()); SQLiteDatabase db = mDbHelper.getWritableDatabase(); List<ResolveInfo> availableActivities = manager.queryIntentActivities(i, 0); for (ResolveInfo ri : availableActivities) { if (!ri.activityInfo.packageName.matches("com.appmanager.parimal")) { AppDetail app = new AppDetail(); app.setLabel(ri.loadLabel(manager)); app.setName(ri.activityInfo.packageName); app.setIcon(ri.activityInfo.loadIcon(manager)); apps.add(app);//from w ww.j a v a 2s . c o m ContentValues values = new ContentValues(); values.put(AppsReaderContract.AppEntry.COLUMN_APP_NAME, ri.loadLabel(manager).toString()); values.put(AppsReaderContract.AppEntry.COLUMN_APP_PACKAGE, ri.activityInfo.packageName); values.put(AppsReaderContract.AppEntry.COLUMN_APP_CATEGORY, "Uncategorized"); values.put(AppsReaderContract.AppEntry.COLUMN_APP_PIN, "0000"); values.put(AppsReaderContract.AppEntry.COLUMN_APP_PIN_USE, "false"); values.put(AppsReaderContract.AppEntry.COLUMN_APP_USAGE, "0"); long newRowId; newRowId = db.insert(AppsReaderContract.AppEntry.TABLE_NAME, null, values); } } db.close(); }
From source file:com.manumanu.alarmexample2.AlarmNotification.java
private void addNotification(Alarm alarm) { NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); Notification notification;//from www .j a v a 2s .co m PendingIntent activity; Intent intent; Log.i(TAG, "AlarmNotification.addNotification(" + alarm.getId() + ", '" + alarm.getTitle() + "', '" + mDateTime.formatDetails(alarm) + "')"); intent = new Intent(this.getApplicationContext(), AlarmMe.class); intent.setAction(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_LAUNCHER); activity = PendingIntent.getActivity(this, (int) alarm.getId(), intent, PendingIntent.FLAG_UPDATE_CURRENT); NotificationCompat.Builder builder = new NotificationCompat.Builder(this); notification = builder.setContentIntent(activity).setSmallIcon(R.drawable.ic_notification) .setAutoCancel(true).setContentTitle("Missed alarm: " + alarm.getTitle()) .setContentText(mDateTime.formatDetails(alarm)).build(); notificationManager.notify((int) alarm.getId(), notification); }
From source file:de.hshannover.f4.trust.ironcontrol.view.SearchFragmentActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.menu_settings: startActivity(new Intent(getBaseContext(), SettingsActivity.class)); return true; case R.id.menu_exit: Intent home = new Intent(Intent.ACTION_MAIN); home.addCategory(Intent.CATEGORY_HOME); home.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(home);/*from www . j a v a 2 s . c om*/ return true; default: return super.onOptionsItemSelected(item); } }
From source file:eu.alefzero.owncloud.ui.activity.FileDisplayActivity.java
@Override public void onCreate(Bundle savedInstanceState) { Log.i(getClass().toString(), "onCreate() start"); super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); Thread.setDefaultUncaughtExceptionHandler(new CrashHandler(getApplicationContext())); if (savedInstanceState != null) { mDirs = savedInstanceState.getStringArray(KEY_DIR_ARRAY); mDirectories = new CustomArrayAdapter<String>(this, R.layout.sherlock_spinner_dropdown_item); mDirectories.add(OCFile.PATH_SEPARATOR); if (mDirs != null) for (String s : mDirs) mDirectories.insert(s, 0); mCurrentDir = savedInstanceState.getParcelable(FileDetailFragment.EXTRA_FILE); }// w ww. j av a 2s. co m mLayoutView = getLayoutInflater().inflate(R.layout.files, null); // always inflate this at onCreate() ; just once! if (AccountUtils.accountsAreSetup(this)) { initDelayedTilAccountAvailabe(); // PIN CODE request ; best location is to decide, let's try this first //if (savedInstanceState == null) { if (getIntent().getAction() != null && getIntent().getAction().equals(Intent.ACTION_MAIN) && savedInstanceState == null) { requestPinCode(); } } else { setContentView(R.layout.no_account_available); getSupportActionBar().setNavigationMode(ActionBar.DISPLAY_SHOW_TITLE); findViewById(R.id.setup_account).setOnClickListener(this); setSupportProgressBarIndeterminateVisibility(false); Intent intent = new Intent(android.provider.Settings.ACTION_ADD_ACCOUNT); intent.putExtra(android.provider.Settings.EXTRA_AUTHORITIES, new String[] { AccountAuthenticator.AUTH_TOKEN_TYPE }); startActivity(intent); // although the code is here, the activity won't be created until this.onStart() and this.onResume() are finished; mForcedLoginToCreateFirstAccount = true; } Log.i(getClass().toString(), "onCreate() end"); }
From source file:com.github.chenxiaolong.dualbootpatcher.switcher.SwitcherService.java
private void setForegroundNotification() { Intent startupIntent = new Intent(this, MainActivity.class); startupIntent.setAction(Intent.ACTION_MAIN); startupIntent.addCategory(Intent.CATEGORY_LAUNCHER); PendingIntent startupPendingIntent = PendingIntent.getActivity(this, 0, startupIntent, PendingIntent.FLAG_UPDATE_CURRENT); NotificationCompat.Builder builder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.ic_launcher).setContentIntent(startupPendingIntent) .setContentTitle(getString(R.string.switcher_service_background_service)) .setPriority(Notification.PRIORITY_MIN); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { builder.setCategory(Notification.CATEGORY_SERVICE); }//from ww w. j a va 2 s. co m startForeground(NOTIFICATION_ID, builder.build()); }
From source file:com.example.easyvoice.MessageDetail.java
public void onWrite(View view) { String which = getIntent().getAction(); Log.d(getClass().getSimpleName(), "which is " + which); if (which.equalsIgnoreCase(Intent.ACTION_MAIN)) { onSave(view);// www . ja v a 2s . c o m } else if (which.equalsIgnoreCase(Intent.ACTION_EDIT)) { // TODO set msgId? onUpdate(view); } }
From source file:com.greatnowhere.radar.MainRadarActivity.java
public void goHome() { Intent setIntent = new Intent(Intent.ACTION_MAIN); setIntent.addCategory(Intent.CATEGORY_HOME); setIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(setIntent);/* w w w .jav a2 s . co m*/ }
From source file:com.amaze.carbonfilemanager.activities.PreferencesActivity.java
@Override public void onBackPressed() { if (selectedItem != START_PREFERENCE && changed) restartPC(this); else if (selectedItem != START_PREFERENCE) { selectItem(START_PREFERENCE);// w ww . j a v a 2 s . co m } else { Intent in = new Intent(PreferencesActivity.this, MainActivity.class); in.setAction(Intent.ACTION_MAIN); in.setAction(Intent.CATEGORY_LAUNCHER); this.startActivity(in); this.finish(); } }
From source file:com.filemanager.free.activities.Preferences.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: // Navigate "up" the demo structure to the launchpad activity. if (select == 1 && changed == 1) restartPC(this); else if (select == 1) { selectItem(0);//w w w .j av a 2 s. c om } else { Intent in = new Intent(Preferences.this, MainActivity.class); in.setAction(Intent.ACTION_MAIN); final int enter_anim = android.R.anim.fade_in; final int exit_anim = android.R.anim.fade_out; Activity activity = this; activity.overridePendingTransition(enter_anim, exit_anim); activity.finish(); activity.overridePendingTransition(enter_anim, exit_anim); activity.startActivity(in); } MainActivity.showInterstitial(); return true; } return true; }
From source file:com.detroitteatime.autocarfinder.Main.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mainLayout = (LinearLayout) this.getLayoutInflater().inflate(R.layout.main, null); setContentView(mainLayout);//w ww . ja v a 2s . c o m // Possible work around for market launches. See // http://code.google.com/p/android/issues/detail?id=2373 // for more details. Essentially, the market launches the main activity // on top of other activities. // we never want this to happen. Instead, we check if we are the root // and if not, we finish. if (!isTaskRoot()) { final Intent intent = getIntent(); final String intentAction = intent.getAction(); if (intent.hasCategory(Intent.CATEGORY_LAUNCHER) && intentAction != null && intentAction.equals(Intent.ACTION_MAIN)) { // Log.w("My Code", // "Main Activity is not the root. Finishing Main Activity instead of launching."); finish(); return; } } // set up buttons start = (Button) findViewById(R.id.start); manual = (Button) findViewById(R.id.manual); // progress = (ProgressBar) findViewById(R.id.progressBar1); start.setOnClickListener(this); start.getBackground().setColorFilter(Color.parseColor(COLOR), PorterDuff.Mode.MULTIPLY); manual.setOnClickListener(this); manual.getBackground().setColorFilter(Color.parseColor(COLOR), PorterDuff.Mode.MULTIPLY); monitor = (FrameLayout) findViewById(R.id.frameLayout1); data1 = this.getSharedPreferences("storage", 0); editor1 = data1.edit(); // firstTime = data1.getBoolean("first_time", true); editor1.putBoolean("first_time", false); editor1.commit(); pi = PendingIntent.getActivity(this, 0, new Intent(this, Main.class), 0); data1 = getSharedPreferences("storage", 0); editor1 = data1.edit(); // set a global layout listener which will be called when the layout // pass is completed and the view is drawn FragmentManager myFragmentManager = getSupportFragmentManager(); mySupportMapFragment = (SupportMapFragment) myFragmentManager.findFragmentById(R.id.map); if (MapsInitializer.initialize(this) != ConnectionResult.SUCCESS) { Toast.makeText(this, "Map failed to initialize.", Toast.LENGTH_SHORT).show(); } map = mySupportMapFragment.getMap(); manager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); // Define the criteria how to select the locatioin provider -> use // default criteria = new Criteria(); criteria.setAccuracy(Criteria.ACCURACY_FINE); criteria.setAltitudeRequired(false); criteria.setBearingRequired(false); provider = manager.getBestProvider(criteria, false); manager.requestLocationUpdates(provider, 1000, 1, this); navigate = (Button) findViewById(R.id.navigate); navigate.setOnClickListener(this); type = (Button) findViewById(R.id.satellite); type.setOnClickListener(this); }