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:it.feio.android.omninotes.extensions.ONDashClockExtension.java
@SuppressLint("DefaultLocale") @Override//from ww w . j a v a2s . c o m protected void onUpdateData(int reason) { Map<String, List<Note>> notesCounters = getNotesCounters(); int reminders = notesCounters.get(Counters.REMINDERS).size(); StringBuilder expandedTitle = new StringBuilder(); expandedTitle.append(notesCounters.get(Counters.ACTIVE).size()).append(" ") .append(getString(R.string.notes).toLowerCase()); if (reminders > 0) { expandedTitle.append(", ").append(reminders).append(" ").append(getString(R.string.reminders)); } StringBuilder expandedBody = new StringBuilder(); if (notesCounters.get(Counters.TODAY).size() > 0) { expandedBody.append(notesCounters.get(Counters.TODAY).size()).append(" ") .append(getString(R.string.today)).append(":"); for (Note todayReminder : notesCounters.get(Counters.TODAY)) { expandedBody.append(System.getProperty("line.separator")).append((" ")) .append(getNoteTitle(this, todayReminder)); } expandedBody.append("\n"); } if (notesCounters.get(Counters.TOMORROW).size() > 0) { expandedBody.append(notesCounters.get(Counters.TOMORROW).size()).append(" ") .append(getString(R.string.tomorrow)).append(":"); for (Note tomorrowReminder : notesCounters.get(Counters.TOMORROW)) { expandedBody.append(System.getProperty("line.separator")).append((" ")) .append(getNoteTitle(this, tomorrowReminder)); } } // Publish the extension data update. Intent launchIntent = new Intent(this, MainActivity.class); launchIntent.setAction(Intent.ACTION_MAIN); publishUpdate(new ExtensionData().visible(true).icon(R.drawable.ic_stat_literal_icon) .status(String.valueOf(notesCounters.get(Counters.ACTIVE).size())) .expandedTitle(expandedTitle.toString()).expandedBody(expandedBody.toString()) .clickIntent(launchIntent)); }
From source file:com.fvd.nimbus.MainActivity.java
/** Called when the activity is first created. */ @Override/*from w w w . j av a2s. co m*/ public void onCreate(Bundle savedInstanceState) { try { super.onCreate(savedInstanceState); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); try { requestWindowFeature(Window.FEATURE_NO_TITLE); } catch (Exception e) { e.printStackTrace(); } File ex = getExternalCacheDir(); if (ex == null) ex = getCacheDir(); if (ex == null) ex = Environment.getExternalStorageDirectory(); if (ex != null) appSettings.cacheDir = ex.getPath(); setContentView(R.layout.screen_start); //overridePendingTransition( R.anim.slide_in_up, R.anim.slide_out_up ); overridePendingTransition(R.anim.activity_open_translate, R.anim.activity_close_translate); if (!isTaskRoot()) { Intent intent = getIntent(); String action = intent.getAction(); if (action != null && action.equals(Intent.ACTION_MAIN)) { finish(); return; } } prefs = PreferenceManager.getDefaultSharedPreferences(this); appSettings.getInstance().setIsTablet(isTablet()); serverHelper.getInstance().setCallback(this, this); /*findViewById(R.id.bTakePhoto).setOnClickListener(this); findViewById(R.id.bFromGallery).setOnClickListener(this); findViewById(R.id.bWebClipper).setOnClickListener(this); findViewById(R.id.bPdfAnnotate).setOnClickListener(this); findViewById(R.id.ibSettings).setOnClickListener(this);*/ /*userMail = prefs.getString("userMail", ""); userPass = prefs.getString("userPass", ""); String sessionId = prefs.getString("sessionId", ""); appSettings.sessionId=sessionId; appSettings.userMail=userMail; appSettings.userPass=userPass;*/ appSettings.init(this); userMail = appSettings.userMail; userPass = appSettings.userPass; if (isFirst()) { createShortcut(this); showHelp(); } else if (!prefs.getBoolean("offline", false)) { if ((userMail.length() == 0 || userPass.length() == 0)) showLogin(); else { if (appSettings.sessionId.length() == 0 /*|| true*/) { //serverHelper.getInstance().setSessionId(sessionId); serverHelper.getInstance().sendRequest("user:auth", String.format("\"email\":\"%s\",\"password\":\"%s\"", userMail, userPass), ""); } else { //serverHelper.getInstance().setSessionId(sessionId); serverHelper.getInstance().sendQuietRequest("user:authstate", "", ""); } AppRate.start(this); } } else AppRate.start(this); } catch (Exception e) { appSettings.appendLog("main:onCreate " + e.getMessage()); } }
From source file:com.rafamaya.imagesearch.DataLayerListenerService.java
@Override public void onMessageReceived(MessageEvent messageEvent) { LOGD(TAG, "onMessageReceived: " + messageEvent); // Check to see if the message is to start an activity if (messageEvent.getPath().equals(START_ACTIVITY_PATH)) { Intent startIntent = new Intent(this, PhotoActivity.class).setAction(Intent.ACTION_MAIN) .setData(Uri.fromParts("NODEID", messageEvent.getSourceNodeId(), "")); PendingIntent startPendingIntent = PendingIntent.getActivity(this, 0, startIntent, 0); long[] pattern = { 0, 100, 1000 }; Notification notify = new NotificationCompat.Builder(this).setAutoCancel(false) .setStyle(new NotificationCompat.BigTextStyle() .bigText("View or Search images and sync navigation!")) .setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher)) .setVibrate(pattern)/*w ww. j a va 2 s . c o m*/ //.addAction(android.R.drawable.ic_menu_gallery, "View", startPendingIntent) .setSmallIcon(R.drawable.ic_launcher).setContentIntent(startPendingIntent).build(); notify.flags |= Notification.FLAG_AUTO_CANCEL; NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this); notificationManager.notify(0, notify); } }
From source file:com.nks.nksmod.MainActivity.java
@SuppressWarnings("StatementWithEmptyBody") @Override//www .j av a2 s .c om public boolean onNavigationItemSelected(MenuItem item) { // Handle navigation view item clicks here. int id = item.getItemId(); if (id == R.id.nav_info) { Intent intent = new Intent(this, InformationActivity.class); startActivity(intent); } if (id == R.id.nav_update) { Intent intent = new Intent(Intent.ACTION_MAIN); intent.setComponent(ComponentName .unflattenFromString("com.nks.nksmod.otaupdater/com.nks.nksmod.otaupdater.OTAUpdaterActivity")); intent.addCategory(Intent.CATEGORY_LAUNCHER); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); } /* if (id == R.id.nav_gallery) { } else if (id == R.id.nav_slideshow) { } else if (id == R.id.nav_manage) { } else if (id == R.id.nav_share) { } else if (id == R.id.nav_send) { } */ DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); drawer.closeDrawer(GravityCompat.START); return true; }
From source file:com.amaze.filemanager.services.CopyService.java
@Override public int onStartCommand(Intent intent, int flags, int startId) { Bundle b = new Bundle(); ArrayList<BaseFile> files = intent.getParcelableArrayListExtra("FILE_PATHS"); String FILE2 = intent.getStringExtra("COPY_DIRECTORY"); int mode = intent.getIntExtra("MODE", 0); mNotifyManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); b.putInt("id", startId); Intent notificationIntent = new Intent(this, MainActivity.class); notificationIntent.setAction(Intent.ACTION_MAIN); notificationIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); notificationIntent.putExtra("openprocesses", true); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0); mBuilder = new NotificationCompat.Builder(c); mBuilder.setContentIntent(pendingIntent); mBuilder.setContentTitle(getResources().getString(R.string.copying)) .setSmallIcon(R.drawable.ic_content_copy_white_36dp); if (foreground) { startForeground(Integer.parseInt("456" + startId), mBuilder.build()); foreground = false;//from ww w . ja v a 2 s .com } b.putBoolean("move", intent.getBooleanExtra("move", false)); b.putString("FILE2", FILE2); b.putInt("MODE", mode); b.putParcelableArrayList("files", files); hash.put(startId, true); DataPackage intent1 = new DataPackage(); intent1.setName(files.get(0).getName()); intent1.setTotal(0); intent1.setDone(0); intent1.setId(startId); intent1.setP1(0); intent1.setP2(0); intent1.setMove(intent.getBooleanExtra("move", false)); intent1.setCompleted(false); hash1.put(startId, intent1); //going async new DoInBackground().execute(b); // If we get killed, after returning from here, restart return START_STICKY; }
From source file:com.launcher.silverfish.LauncherActivity.java
private void autoSortApplications() { // Set up both SQL helper and package manager LauncherSQLiteHelper sql = new LauncherSQLiteHelper(this.getBaseContext()); PackageManager mPacMan = getApplicationContext().getPackageManager(); // Set MAIN and LAUNCHER filters, so we only get activities with that defined on their manifest Intent i = new Intent(Intent.ACTION_MAIN, null); i.addCategory(Intent.CATEGORY_LAUNCHER); // Get all activities that have those filters List<ResolveInfo> availableActivities = mPacMan.queryIntentActivities(i, 0); // Store here the packages and their categories IDs // This will allow us to add all the apps at once instead opening the database over and over HashMap<String, Integer> pkg_categoryId = PackagesCategories.setCategories(getApplicationContext(), availableActivities);// w w w. jav a 2 s.c o m // Then add all the apps to their corresponding tabs at once sql.addAppsToTab(pkg_categoryId); }
From source file:com.dycody.android.idealnote.extensions.ONDashClockExtension.java
@SuppressLint("DefaultLocale") @Override// www . ja va2s . c o m protected void onUpdateData(int reason) { Map<Counters, List<Note>> notesCounters = getNotesCounters(); int reminders = notesCounters.get(Counters.REMINDERS).size(); StringBuilder expandedTitle = new StringBuilder(); expandedTitle.append(notesCounters.get(Counters.ACTIVE).size()).append(" ") .append(getString(com.dycody.android.idealnote.R.string.notes).toLowerCase()); if (reminders > 0) { expandedTitle.append(", ").append(reminders).append(" ") .append(getString(com.dycody.android.idealnote.R.string.reminders)); } StringBuilder expandedBody = new StringBuilder(); if (notesCounters.get(Counters.TODAY).size() > 0) { expandedBody.append(notesCounters.get(Counters.TODAY).size()).append(" ") .append(getString(com.dycody.android.idealnote.R.string.today)).append(":"); for (Note todayReminder : notesCounters.get(Counters.TODAY)) { expandedBody.append(System.getProperty("line.separator")).append((" ")) .append(getNoteTitle(this, todayReminder)); } expandedBody.append("\n"); } if (notesCounters.get(Counters.TOMORROW).size() > 0) { expandedBody.append(notesCounters.get(Counters.TOMORROW).size()).append(" ") .append(getString(com.dycody.android.idealnote.R.string.tomorrow)).append(":"); for (Note tomorrowReminder : notesCounters.get(Counters.TOMORROW)) { expandedBody.append(System.getProperty("line.separator")).append((" ")) .append(getNoteTitle(this, tomorrowReminder)); } } // Publish the extension data update. Intent launchIntent = new Intent(this, MainActivity.class); launchIntent.setAction(Intent.ACTION_MAIN); publishUpdate( new ExtensionData().visible(true).icon(com.dycody.android.idealnote.R.drawable.ic_stat_literal_icon) .status(String.valueOf(notesCounters.get(Counters.ACTIVE).size())) .expandedTitle(expandedTitle.toString()).expandedBody(expandedBody.toString()) .clickIntent(launchIntent)); }
From source file:com.google.android.car.kitchensink.cluster.InstrumentClusterFragment.java
private void startNavActivity() { CarInstrumentClusterManager clusterManager; try {/*ww w.ja v a2s . com*/ clusterManager = (CarInstrumentClusterManager) mCarApi .getCarManager(android.car.Car.CAR_INSTRUMENT_CLUSTER_SERVICE); } catch (CarNotConnectedException e) { Log.e(TAG, "Failed to get CarInstrumentClusterManager", e); Toast.makeText(getContext(), "Failed to get CarInstrumentClusterManager", Toast.LENGTH_LONG).show(); return; } // Implicit intent Intent intent = new Intent(Intent.ACTION_MAIN); intent.addCategory(CarInstrumentClusterManager.CATEGORY_NAVIGATION); try { clusterManager.startActivity(intent); } catch (android.car.CarNotConnectedException e) { Log.e(TAG, "Failed to startActivity in cluster", e); Toast.makeText(getContext(), "Failed to start activity in cluster", Toast.LENGTH_LONG).show(); return; } }
From source file:kinsleykajiva.co.zw.cutstudentapp.Settinngs.java
private void addShortcut() { Intent shortcutIntent = new Intent(getApplicationContext(), Settinngs.class); shortcutIntent.setAction(Intent.ACTION_MAIN); Intent addIntent = new Intent(); addIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent); addIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, "C.U.T Student"); //addIntent.putExtra("duplicate", false); addIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, Intent.ShortcutIconResource.fromContext(getApplicationContext(), R.drawable.logo)); addIntent.setAction("com.android.launcher.action.INSTALL_SHORTCUT"); getApplicationContext().sendBroadcast(addIntent); }
From source file:eu.chainfire.geolog.service.BackgroundService.java
@SuppressLint("NewApi") @Override/* ww w . j a v a2 s . co m*/ public void onCreate() { super.onCreate(); Debug.log("Service created"); if (thread == null) { Debug.log("Launching thread"); thread = new ServiceThread(); thread.setContext(getApplicationContext()); thread.start(); } PowerManager pm = (PowerManager) getSystemService(POWER_SERVICE); wakelock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "GeoLog Wakelock"); Intent i = new Intent(); i.setAction(Intent.ACTION_MAIN); i.addCategory(Intent.CATEGORY_LAUNCHER); i.setClass(this, MainActivity.class); i.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION | Intent.FLAG_ACTIVITY_NEW_TASK); notificationIntent = PendingIntent.getActivity(this, 0, i, 0); notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); notificationBuilder = (new Notification.Builder(this)).setSmallIcon(R.drawable.ic_stat_service) .setContentIntent(notificationIntent).setWhen(System.currentTimeMillis()).setAutoCancel(false) .setOngoing(true).setContentTitle(getString(R.string.service_title)) .setContentText(getString(R.string.service_waiting)); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { notificationBuilder.setShowWhen(false); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { /* quick turn off, maybe ? if added, make sure to add a button to preferences to disable these buttons notificationBuilder. setPriority(Notification.PRIORITY_MAX). addAction(0, "A", notificationIntent). addAction(0, "B", notificationIntent). addAction(0, "C", notificationIntent); */ } updateNotification(); }