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.app.basarnas.fcm.MyFirebaseMessagingService.java
private void launch_activity(Class cls) { Intent i = new Intent(); i.putExtra(Config.JSON_DATA_NOTIFICATION, jsonDataNotification); i.setAction(Intent.ACTION_MAIN); i.setClass(this, cls); i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(i);// w ww .j av a 2 s . c o m }
From source file:com.amaze.filemanager.services.ExtractService.java
@Override public int onStartCommand(Intent intent, int flags, int startId) { Bundle b = new Bundle(); b.putInt("id", startId); epath = PreferenceManager.getDefaultSharedPreferences(this).getString("extractpath", ""); mNotifyManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); String file = intent.getStringExtra("zip"); eentries = intent.getBooleanExtra("entries1", false); if (eentries) { entries = intent.getStringArrayListExtra("entries"); }/*from w w w .j a va2 s . c o m*/ b.putString("file", file); DataPackage intent1 = new DataPackage(); intent1.setName(file); intent1.setTotal(0); intent1.setDone(0); intent1.setId(startId); intent1.setP1(0); intent1.setCompleted(false); hash1.put(startId, intent1); Intent notificationIntent = new Intent(this, MainActivity.class); notificationIntent.setAction(Intent.ACTION_MAIN); notificationIntent.putExtra("openprocesses", true); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0); mBuilder = new NotificationCompat.Builder(cd); mBuilder.setContentIntent(pendingIntent); mBuilder.setContentTitle(getResources().getString(R.string.extracting)) .setContentText(new File(file).getName()).setSmallIcon(R.drawable.ic_doc_compressed); hash.put(startId, true); new Doback().execute(b); return START_STICKY; }
From source file:com.harshad.linconnectclient.ApplicationSettingsActivity.java
private void setupSimplePreferencesScreen() { addPreferencesFromResource(R.xml.pref_application); applicationCategory = (PreferenceCategory) findPreference("header_application"); // Listen for check/uncheck all tap findPreference("pref_all").setOnPreferenceChangeListener(new OnPreferenceChangeListener() { @Override// w ww. ja va2s.c o m public boolean onPreferenceChange(Preference arg0, Object arg1) { for (int i = 0; i < applicationCategory.getPreferenceCount(); i++) { // Uncheck or check all items ((CheckBoxPreference) (applicationCategory.getPreference(i))).setChecked((Boolean) arg1); } return true; } }); class ApplicationTask extends AsyncTask<String, Void, List<ApplicationInfo>> { private PackageManager packageManager; @Override protected void onPreExecute() { progressDialog = ProgressDialog.show(ApplicationSettingsActivity.this, null, "Loading...", true); } @Override protected List<ApplicationInfo> doInBackground(String... notif) { packageManager = getApplicationContext().getPackageManager(); // Comparator used to sort applications by name class CustomComparator implements Comparator<ApplicationInfo> { @Override public int compare(ApplicationInfo arg0, ApplicationInfo arg1) { return arg0.loadLabel(packageManager).toString() .compareTo(arg1.loadLabel(packageManager).toString()); } } // Get installed applications Intent mainIntent = new Intent(Intent.ACTION_MAIN, null); mainIntent.addCategory(Intent.CATEGORY_LAUNCHER); List<ApplicationInfo> appList = getApplicationContext().getPackageManager() .getInstalledApplications(PackageManager.GET_META_DATA); // Sort by application name Collections.sort(appList, new CustomComparator()); return appList; } @Override protected void onPostExecute(List<ApplicationInfo> result) { // Add each application to screen for (ApplicationInfo appInfo : result) { CheckBoxPreference c = new CheckBoxPreference(ApplicationSettingsActivity.this); c.setTitle(appInfo.loadLabel(packageManager).toString()); c.setSummary(appInfo.packageName); c.setIcon(appInfo.loadIcon(packageManager)); c.setKey(appInfo.packageName); c.setChecked(true); c.setOnPreferenceChangeListener(new OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference arg0, Object arg1) { // On tap, show an enabled/disabled notification on the desktop Object[] notif = new Object[3]; if (arg1.toString().equals("true")) { notif[0] = arg0.getTitle().toString() + " notifications enabled"; notif[1] = "via LinConnect"; notif[2] = arg0.getIcon(); } else { notif[0] = arg0.getTitle().toString() + " notifications disabled"; notif[1] = "via LinConnect"; notif[2] = arg0.getIcon(); } new TestTask().execute(notif); return true; } }); applicationCategory.addPreference(c); } progressDialog.dismiss(); } } new ApplicationTask().execute(); }
From source file:com.yekertech.tvbarsetting.MainFragment.java
private void loadMenuItem() { int i = 0;//w w w. ja v a 2 s . c om mRowsAdapter = new ArrayObjectAdapter(new ListRowPresenter()); ArrayObjectAdapter listRowAdapter = new ArrayObjectAdapter(new MenuItemPresenter()); Intent intentDisp = new Intent(Intent.ACTION_MAIN); intentDisp.setClass(this.getActivity(), DisplayActivity.class); Intent intentBt = new Intent(Intent.ACTION_MAIN); intentBt.setComponent(new ComponentName("com.android.settings", "com.android.settings.SubSettings")); intentBt.putExtra(":settings:show_fragment", "com.android.settings.bluetooth.BluetoothSettings"); intentBt.putExtra(":settings:show_fragment_title", "Bluetooth"); Intent intentNetwork = new Intent(Intent.ACTION_MAIN); intentNetwork.setClass(this.getActivity(), NetworkActivity.class); Intent intentSound = new Intent(Intent.ACTION_MAIN); intentSound.setClass(this.getActivity(), SoundActivity.class); Intent intentCommon = new Intent(Intent.ACTION_MAIN); intentCommon.setClass(this.getActivity(), AboutActivity.class); Intent intentAbout = new Intent(Intent.ACTION_MAIN); intentAbout.setClass(this.getActivity(), AboutActivity.class); listRowAdapter.add(new MenuItem.Builder().id(i++).title("?").backgroundColor(0xff2daae6) .imageResourceId(this.getActivity(), R.drawable.ic_settings_display).intent(intentDisp).build()); listRowAdapter.add(new MenuItem.Builder().id(i++).title("").backgroundColor(0xffe6b41e) .imageResourceId(this.getActivity(), R.drawable.ic_settings_sound_on).intent(intentSound).build()); listRowAdapter.add(new MenuItem.Builder().id(i++).title("?").backgroundColor(0xff329696) .imageResourceId(this.getActivity(), R.drawable.ic_settings_bluetooth).intent(intentBt).build()); listRowAdapter.add(new MenuItem.Builder().id(i++).title("").backgroundColor(0xfff08c23) .imageResourceId(this.getActivity(), R.drawable.ic_settings_ethernet).intent(intentNetwork) .build()); listRowAdapter.add(new MenuItem.Builder().id(i++).title("").backgroundColor(0xff737ddc) .imageResourceId(this.getActivity(), R.drawable.ic_settings_app_icon).intent(intentCommon).build()); listRowAdapter.add(new MenuItem.Builder().id(i++).title("").backgroundColor(0xfff55a46) .imageResourceId(this.getActivity(), R.drawable.ic_settings_about).intent(intentAbout).build()); HeaderItem header = new HeaderItem(0, ""); mRowsAdapter.add(new ListRow(listRowAdapter)); setAdapter(mRowsAdapter); }
From source file:com.amaze.filemanager.asynchronous.services.ExtractService.java
@Override public int onStartCommand(Intent intent, int flags, final int startId) { String file = intent.getStringExtra(KEY_PATH_ZIP); String extractPath = intent.getStringExtra(KEY_PATH_EXTRACT); String[] entries = intent.getStringArrayExtra(KEY_ENTRIES_ZIP); mNotifyManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context); accentColor = ((AppConfig) getApplication()).getUtilsProvider().getColorPreference() .getCurrentUserColorPreferences(this, sharedPreferences).accent; Intent notificationIntent = new Intent(this, MainActivity.class); notificationIntent.setAction(Intent.ACTION_MAIN); notificationIntent.putExtra(MainActivity.KEY_INTENT_PROCESS_VIEWER, true); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0); customSmallContentViews = new RemoteViews(getPackageName(), R.layout.notification_service_small); customBigContentViews = new RemoteViews(getPackageName(), R.layout.notification_service_big); Intent stopIntent = new Intent(TAG_BROADCAST_EXTRACT_CANCEL); PendingIntent stopPendingIntent = PendingIntent.getBroadcast(context, 1234, stopIntent, PendingIntent.FLAG_UPDATE_CURRENT); NotificationCompat.Action action = new NotificationCompat.Action(R.drawable.ic_zip_box_grey600_36dp, getString(R.string.stop_ftp), stopPendingIntent); mBuilder = new NotificationCompat.Builder(context, NotificationConstants.CHANNEL_NORMAL_ID); mBuilder.setContentIntent(pendingIntent).setSmallIcon(R.drawable.ic_zip_box_grey600_36dp) .setContentIntent(pendingIntent).setCustomContentView(customSmallContentViews) .setCustomBigContentView(customBigContentViews).setCustomHeadsUpContentView(customSmallContentViews) .setStyle(new NotificationCompat.DecoratedCustomViewStyle()).addAction(action).setOngoing(true) .setColor(accentColor);//from ww w . j ava2 s . c o m NotificationConstants.setMetadata(getApplicationContext(), mBuilder, NotificationConstants.TYPE_NORMAL); startForeground(NotificationConstants.EXTRACT_ID, mBuilder.build()); initNotificationViews(); long totalSize = getTotalSize(file); progressHandler.setSourceSize(1); progressHandler.setTotalSize(totalSize); progressHandler.setProgressListener((speed) -> publishResults(speed, false, false)); super.onStartCommand(intent, flags, startId); super.progressHalted(); new DoWork(this, progressHandler, file, extractPath, entries).execute(); return START_STICKY; }
From source file:com.launcher.silverfish.launcher.LauncherActivity.java
private void autoSortApplications() { // Set up both SQL helper and package manager LauncherSQLiteHelper sql = new LauncherSQLiteHelper((App) getApplication()); 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, Long> pkg_categoryId = PackagesCategories.setCategories(getApplicationContext(), availableActivities);/*from w w w .java 2 s. c om*/ // Then add all the apps to their corresponding tabs at once sql.addAppsToTab(pkg_categoryId); }
From source file:com.chale22.ico01.fragments.FragmentExtras.java
private void actIcons() { String pkg = getResources().getString(R.string.pkg); Intent iconfrag = new Intent(Intent.ACTION_MAIN); iconfrag.setComponent(new ComponentName(pkg, pkg + ".IconActivity")); try {/*from ww w. jav a 2s .c o m*/ startActivity(iconfrag); } catch (RuntimeException icons) { icons.printStackTrace(); } }
From source file:org.frc836.database.DBSyncService.java
@Override public void onCreate() { super.onCreate(); // loadTimestamp(); initSync = !loadTimestamp();/*w w w. j a v a2s. c o m*/ password = ""; mTimerTask = new Handler(); dataTask = new SyncDataTask(); password = Prefs.getSavedPassword(getApplicationContext()); outgoing = new ArrayList<Map<String, String>>(); utils = new HttpUtils(); DBSyncService.version = getString(R.string.VersionID); mTimerTask.post(dataTask); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.ic_launcher).setContentTitle(getString(R.string.service_notify_title)) .setContentText(getString(R.string.service_notify_text)).setOngoing(true).setWhen(0); Intent notifyIntent = new Intent(this, DashboardActivity.class); notifyIntent.setAction(Intent.ACTION_MAIN); notifyIntent.addCategory(Intent.CATEGORY_LAUNCHER); notifyIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); PendingIntent intent = PendingIntent.getActivity(this, 0, notifyIntent, PendingIntent.FLAG_CANCEL_CURRENT); mBuilder.setContentIntent(intent); ((NotificationManager) getSystemService(NOTIFICATION_SERVICE)).notify(notifyID, mBuilder.build()); }
From source file:org.catrobat.catroid.utils.StatusBarNotificationManager.java
public int createCopyNotification(Context context, String programName) { if (context == null || programName == null) { return -1; }/*from ww w.ja v a 2s . c o m*/ initNotificationManager(context); Intent copyIntent = new Intent(context, MainMenuActivity.class); copyIntent.setAction(Intent.ACTION_MAIN).setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP) .putExtra(EXTRA_PROJECT_NAME, programName); PendingIntent pendingIntent = PendingIntent.getActivity(context, notificationId, copyIntent, PendingIntent.FLAG_CANCEL_CURRENT); NotificationData data = new NotificationData(context, pendingIntent, R.drawable.ic_stat, programName, R.string.notification_copy_title_pending, R.string.notification_title_open, R.string.notification_copy_pending, R.string.notification_copy_finished); int id = createNotification(context, data); showOrUpdateNotification(id, 0); return id; }
From source file:com.rp.podemu.SettingsActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_settings); sharedPref = this.getSharedPreferences("PODEMU_PREFS", Context.MODE_PRIVATE); //String[] controlledApp = new String[appsRunning.size()]; //Drawable[] icons = new Drawable[appsRunning.size()]; //pm.getApplicationInfo(r.baseActivity.getPackageName(), PackageManager.GET_META_DATA); //Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); //startActivity(intent); Intent intent = new Intent(Intent.ACTION_MAIN, null); intent.addCategory(Intent.CATEGORY_APP_MUSIC); PackageManager pm = getPackageManager(); String text = ""; List<ResolveInfo> packages = pm.queryIntentActivities(intent, 0); //get a list of installed apps. //List<ApplicationInfo> packages = pm.getInstalledApplications(PackageManager.GET_META_DATA); //using hashset so that there will be no duplicate packages, //if no duplicate packages then there will be no duplicate apps HashSet<String> packageNames = new HashSet<String>(0); appInfos = new ArrayList<ApplicationInfo>(0); //getting package names and adding them to the hashset for (ResolveInfo resolveInfo : packages) { packageNames.add(resolveInfo.activityInfo.packageName); }//from ww w .ja va2s . c o m // used just for tests /* ApplicationInfo dummyApp = new ApplicationInfo(); dummyApp.name="select application"; dummyApp.processName="dummy"; appInfos.add(dummyApp); */ for (String packageName : PodEmuIntentFilter.getAppList()) { try { appInfos.add(pm.getApplicationInfo(packageName, PackageManager.GET_META_DATA)); } catch (PackageManager.NameNotFoundException e) { //Do Nothing } } //now we have unique packages in the hashset, so get their application infos //and add them to the arraylist for (String packageName : packageNames) { try { appInfos.add(pm.getApplicationInfo(packageName, PackageManager.GET_META_DATA)); } catch (PackageManager.NameNotFoundException e) { //Do Nothing } } text += "Apps count: " + appInfos.size() + "\n"; for (ApplicationInfo appInfo : appInfos) { //if (packageInfo.) { appInfo.name = (String) appInfo.loadLabel(pm); text += appInfo.loadLabel(pm) + "\n"; //text += packageInfo. //text += "\n"; } } //TextView textView = (TextView) findViewById(R.id.ctrlAppTitle); //textView.setText(text); //LauncherApps launcherApps=new LauncherApps(); //List<LauncherActivityInfo> activities=launcherApps.getActivityList(null, android.os.Process.myUserHandle()); //List<LauncherActivityInfo> activities=LauncherApps().getActivityList(null, android.os.Process.myUserHandle()); baudRateList.add(9600); baudRateList.add(14400); baudRateList.add(19200); baudRateList.add(28800); baudRateList.add(38400); baudRateList.add(56000); baudRateList.add(57600); baudRateList.add(115200); try { PackageInfo pInfo = getPackageManager().getPackageInfo(getPackageName(), 0); String version = pInfo.versionName; TextView versionHint = (TextView) findViewById(R.id.versionHint); versionHint.setText(getResources().getString(R.string.version_hint) + version); } catch (PackageManager.NameNotFoundException e) { // do nothing } }