List of usage examples for android.content Intent addCategory
public @NonNull Intent addCategory(String category)
From source file:com.tt.jobtracker.MainActivity.java
@Override public void onBackPressed() { if (Shared.onbackpress == true) { if (back_pressed + 2000 > System.currentTimeMillis()) { // super.onBackPressed(); Intent startMain = new Intent(Intent.ACTION_MAIN); startMain.addCategory(Intent.CATEGORY_HOME); startMain.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(startMain);// w ww. ja v a 2 s . c o m } else { Toast.makeText(getBaseContext(), "Press once again to exit!", Toast.LENGTH_SHORT).show(); back_pressed = System.currentTimeMillis(); } } else { super.onBackPressed(); } }
From source file:no.nordicsemi.android.nrftoolbox.dfu.DfuActivity.java
/** * Called when Select File was pressed// ww w .j a v a 2s . c o m * * @param view * a button that was pressed */ public void onSelectFileClicked(final View view) { final Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType("application/octet-stream"); intent.addCategory(Intent.CATEGORY_OPENABLE); if (intent.resolveActivity(getPackageManager()) != null) { // file browser has been found on the device startActivityForResult(intent, SELECT_FILE_REQ); } else { // there is no any file browser app, let's try to download one final View customView = getLayoutInflater().inflate(R.layout.app_file_browser, null); final ListView appsList = (ListView) customView.findViewById(android.R.id.list); appsList.setAdapter(new FileBrowserAppsAdapter(this)); appsList.setChoiceMode(ListView.CHOICE_MODE_SINGLE); appsList.setItemChecked(0, true); new AlertDialog.Builder(this).setTitle(R.string.dfu_alert_no_filebrowser_title).setView(customView) .setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int which) { dialog.dismiss(); } }).setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int which) { final int pos = appsList.getCheckedItemPosition(); if (pos >= 0) { final String query = getResources() .getStringArray(R.array.dfu_app_file_browser_action)[pos]; final Intent storeIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(query)); startActivity(storeIntent); } } }).show(); } }
From source file:com.farmerbb.notepad.activity.MainActivity.java
@TargetApi(Build.VERSION_CODES.KITKAT) private void reallyExportNotes() { String filename = ""; try {/*from w w w .j a v a2s. c om*/ filename = loadNoteTitle(filesToExport[fileBeingExported].toString()); } catch (IOException e) { /* Gracefully fail */ } Intent intent = new Intent(Intent.ACTION_CREATE_DOCUMENT); intent.addCategory(Intent.CATEGORY_OPENABLE); intent.setType("text/plain"); intent.putExtra(Intent.EXTRA_TITLE, generateFilename(filename)); try { startActivityForResult(intent, EXPORT); } catch (ActivityNotFoundException e) { showToast(R.string.error_exporting_notes); } }
From source file:com.zertinteractive.wallpaper.activities.DetailActivity.java
public void setAsWallpaperMore() { String path = Environment.getExternalStorageDirectory().toString(); File file = new File(path, "/" + TEMP_WALLPAPER_DIR + "/" + TEMP_WALLPAPER_NAME + ".png"); Uri uri = Uri.fromFile(file);/*from w w w . ja v a2s . co m*/ Intent intent = new Intent(Intent.ACTION_ATTACH_DATA); intent.addCategory(Intent.CATEGORY_DEFAULT); intent.setDataAndType(uri, "image/png"); intent.putExtra("mimeType", "image/png"); startActivity(Intent.createChooser(intent, "Set as : Mood Wallpaper")); // WallpaperManager myWallpaperManager // = WallpaperManager.getInstance(getApplicationContext()); // try { // myWallpaperManager.setBitmap(((BitmapDrawable) imageView.getDrawable()).getBitmap()); // } catch (IOException e) { // // TODO Auto-generated catch block // e.printStackTrace(); // } }
From source file:io.teak.sdk.Teak.java
@Override public void onReceive(Context inContext, Intent intent) { final Context context = inContext.getApplicationContext(); if (!Teak.isEnabled()) { Log.e(LOG_TAG, "Teak is disabled, ignoring onReceive()."); return;//from w w w . j a v a 2s .c o m } String action = intent.getAction(); if (GCM_RECEIVE_INTENT_ACTION.equals(action)) { final TeakNotification notif = TeakNotification.remoteNotificationFromIntent(context, intent); if (notif == null) { return; } // Send Notification Received Metric Session.whenUserIdIsReadyRun(new Session.SessionRunnable() { @Override public void run(Session session) { HashMap<String, Object> payload = new HashMap<>(); payload.put("app_id", session.appConfiguration.appId); payload.put("user_id", session.userId()); payload.put("platform_id", notif.teakNotifId); new Request("/notification_received", payload, session).run(); } }); } else if (action.endsWith(TeakNotification.TEAK_NOTIFICATION_OPENED_INTENT_ACTION_SUFFIX)) { Bundle bundle = intent.getExtras(); // Cancel any updates pending TeakNotification.cancel(context, bundle.getInt("platformId")); // Launch the app if (!bundle.getBoolean("noAutolaunch")) { if (Teak.isDebug) { Log.d(LOG_TAG, "Notification (" + bundle.getString("teakNotifId") + ") opened, auto-launching app."); } Intent launchIntent = context.getPackageManager() .getLaunchIntentForPackage(context.getPackageName()); launchIntent.addCategory("android.intent.category.LAUNCHER"); launchIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP); launchIntent.putExtras(bundle); if (bundle.getString("deepLink") != null) { launchIntent.setData(Uri.parse(bundle.getString("deepLink"))); } context.startActivity(launchIntent); } else { if (Teak.isDebug) { Log.d(LOG_TAG, "Notification (" + bundle.getString("teakNotifId") + ") opened, NOT auto-launching app (noAutoLaunch flag present, and set to true)."); } } // Send broadcast if (Teak.localBroadcastManager != null) { Intent broadcastEvent = new Intent(TeakNotification.LAUNCHED_FROM_NOTIFICATION_INTENT); broadcastEvent.putExtras(bundle); Teak.localBroadcastManager.sendBroadcast(broadcastEvent); } } else if (action.endsWith(TeakNotification.TEAK_NOTIFICATION_CLEARED_INTENT_ACTION_SUFFIX)) { Bundle bundle = intent.getExtras(); TeakNotification.cancel(context, bundle.getInt("platformId")); } }
From source file:com.example.android.home.Home.java
/** * Loads the list of installed applications in mApplications. *//*w w w . j av a2s. c o m*/ private void loadApplications(boolean isLaunching) { if (isLaunching && mApplications != null) { return; } PackageManager manager = getPackageManager(); Intent mainIntent = new Intent(Intent.ACTION_MAIN, null); mainIntent.addCategory(Intent.CATEGORY_LAUNCHER); final List<ResolveInfo> apps = manager.queryIntentActivities(mainIntent, 0); Collections.sort(apps, new ResolveInfo.DisplayNameComparator(manager)); if (apps != null) { final int count = apps.size(); if (mApplications == null) { mApplications = new ArrayList<ApplicationInfo>(count); } mApplications.clear(); for (int i = 0; i < count; i++) { //for (int i = 0; i < 6; i++) { // show only 6 apps ApplicationInfo application = new ApplicationInfo(); ResolveInfo info = apps.get(i); application.title = info.loadLabel(manager); application.setActivity( new ComponentName(info.activityInfo.applicationInfo.packageName, info.activityInfo.name), Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); Log.v("Home APP", "package neme= " + info.activityInfo.applicationInfo.packageName); Log.v("Home APP", "neme= " + info.activityInfo.name); Log.v("Home APP", "title= " + application.title); application.icon = info.activityInfo.loadIcon(manager); // TODO // Replace Icons //if((application.title+"").equals("Calculator")) application.icon = getResources().getDrawable(R.drawable.ic_launcher_home_big); // Add Application if ((application.title + "").equals("Browser")) mApplications.add(application); if ((application.title + "").equals("Phone")) mApplications.add(application); if ((application.title + "").equals("People")) mApplications.add(application); if ((application.title + "").equals("Messaging")) mApplications.add(application); if ((application.title + "").equals("Settings")) mApplications.add(application); } // Took from http://hi-android.info/src/index.html // ********************* ADD Call Log ApplicationInfo application = new ApplicationInfo(); application.title = "Call Log"; application.icon = getResources().getDrawable(R.drawable.ic_launcher_home); application.setActivity( new ComponentName("com.android.contacts", "com.android.contacts.RecentCallsListActivity"), Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); mApplications.add(application); } }
From source file:com.anjalimacwan.MainActivity.java
private void checkForAndroidWear() { // Notepad Plugin for Android Wear sends intent with "plugin_install_complete" extra, // in order to verify that the main Notepad app is installed correctly if (getIntent().hasExtra("plugin_install_complete")) { if (getSupportFragmentManager().findFragmentByTag("WearPluginDialogFragmentAlt") == null) { DialogFragment wearDialog = new WearPluginDialogFragmentAlt(); wearDialog.show(getSupportFragmentManager(), "WearPluginDialogFragmentAlt"); }/*from w w w .jav a2 s . c om*/ SharedPreferences pref = getSharedPreferences(getPackageName() + "_preferences", Context.MODE_PRIVATE); SharedPreferences.Editor editor = pref.edit(); editor.putBoolean("show_wear_dialog", false); editor.apply(); } else { boolean hasAndroidWear = false; @SuppressWarnings("unused") PackageInfo pInfo; try { pInfo = getPackageManager().getPackageInfo("com.google.android.wearable.app", 0); hasAndroidWear = true; } catch (PackageManager.NameNotFoundException e) { /* Gracefully fail */ } if (hasAndroidWear) { try { pInfo = getPackageManager().getPackageInfo("com.anjalimacwan.wear", 0); Intent intent = new Intent(Intent.ACTION_MAIN); intent.setComponent(ComponentName .unflattenFromString("com.anjalimacwan.wear/com.anjalimacwan.wear.MobileMainActivity")); intent.addCategory(Intent.CATEGORY_LAUNCHER); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); } catch (PackageManager.NameNotFoundException e) { SharedPreferences pref = getSharedPreferences(getPackageName() + "_preferences", Context.MODE_PRIVATE); if (pref.getBoolean("show_wear_dialog", true) && getSupportFragmentManager().findFragmentByTag("WearPluginDialogFragment") == null) { DialogFragment wearDialog = new WearPluginDialogFragment(); wearDialog.show(getSupportFragmentManager(), "WearPluginDialogFragment"); } } catch (ActivityNotFoundException e) { /* Gracefully fail */ } } } }
From source file:net.bytten.comicviewer.ComicViewerActivity.java
public void loadAuthorLink() { Intent browser = new Intent(); browser.setAction(Intent.ACTION_VIEW); browser.addCategory(Intent.CATEGORY_BROWSABLE); browser.setData(comicDef.getAuthorLinkUrl()); startActivity(browser);//from www . j a v a2 s. c o m }
From source file:net.bytten.comicviewer.ComicViewerActivity.java
public void donate() { Intent browser = new Intent(); browser.setAction(Intent.ACTION_VIEW); browser.addCategory(Intent.CATEGORY_BROWSABLE); browser.setData(comicDef.getDonateUrl()); startActivity(browser);//from w w w . j ava 2 s .c o m }
From source file:net.bytten.comicviewer.ComicViewerActivity.java
public void developerWebsite() { Intent browser = new Intent(); browser.setAction(Intent.ACTION_VIEW); browser.addCategory(Intent.CATEGORY_BROWSABLE); browser.setData(comicDef.getDeveloperUrl()); startActivity(browser);// ww w. ja va 2 s .c om }