List of usage examples for android.content Intent createChooser
public static Intent createChooser(Intent target, CharSequence title)
From source file:com.bushstar.kobocoin_android_wallet.ui.RequestCoinsFragment.java
private void handleShare() { final Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); intent.putExtra(Intent.EXTRA_TEXT, determineKobocoinRequestStr(false)); startActivity(Intent.createChooser(intent, getString(R.string.request_coins_share_dialog_title))); }
From source file:com.amaze.carbonfilemanager.fragments.preference_fragments.Preffrag.java
@Override public boolean onPreferenceClick(Preference preference) { final String[] sort; MaterialDialog.Builder builder;/* w w w . j ava 2s . c o m*/ switch (preference.getKey()) { case "columns": sort = getResources().getStringArray(R.array.columns); builder = new MaterialDialog.Builder(getActivity()); builder.theme(utilsProvider.getAppTheme().getMaterialDialogTheme()); builder.title(R.string.gridcolumnno); int current = Integer.parseInt(sharedPref.getString("columns", "-1")); current = current == -1 ? 0 : current; if (current != 0) current = current - 1; builder.items(sort).itemsCallbackSingleChoice(current, new MaterialDialog.ListCallbackSingleChoice() { @Override public boolean onSelection(MaterialDialog dialog, View view, int which, CharSequence text) { sharedPref.edit().putString("columns", "" + (which != 0 ? sort[which] : "" + -1)).commit(); dialog.dismiss(); return true; } }); builder.build().show(); return true; case "theme": sort = getResources().getStringArray(R.array.theme); current = Integer.parseInt(sharedPref.getString("theme", "0")); builder = new MaterialDialog.Builder(getActivity()); //builder.theme(utilsProvider.getAppTheme().getMaterialDialogTheme()); builder.items(sort).itemsCallbackSingleChoice(current, new MaterialDialog.ListCallbackSingleChoice() { @Override public boolean onSelection(MaterialDialog dialog, View view, int which, CharSequence text) { utilsProvider.getThemeManager().setAppTheme(AppTheme.fromIndex(which)).save(); Log.d("theme", AppTheme.fromIndex(which).name()); dialog.dismiss(); restartPC(getActivity()); return true; } }); builder.title(R.string.theme); builder.build().show(); return true; case "sidebar_folders_enable": sharedPref.edit().putBoolean(PREFERENCE_SHOW_SIDEBAR_FOLDERS, !sharedPref.getBoolean(PREFERENCE_SHOW_SIDEBAR_FOLDERS, true)).apply(); return true; case "sidebar_quickaccess_enable": sharedPref.edit().putBoolean(PREFERENCE_SHOW_SIDEBAR_QUICKACCESSES, !sharedPref.getBoolean(PREFERENCE_SHOW_SIDEBAR_QUICKACCESSES, true)).apply(); return true; case PREFERENCE_SHOW_HIDDENFILES: setEnabledShortcuts(); return false; case PREFERENCE_ROOTMODE: setEnabledShortcuts(); /* boolean b = sharedPref.getBoolean("rootmode", false); if (b) { if (MainActivity.shellInteractive.isRunning()) { rootmode.setChecked(true); } else { rootmode.setChecked(false); Toast.makeText(getActivity(), getResources().getString(R.string.rootfailure), Toast.LENGTH_LONG).show(); } } else { rootmode.setChecked(false); } */ return false; case "feedback": Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto", "vishalmeham2@gmail.com", null)); emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Feedback : Amaze File Manager"); startActivity(Intent.createChooser(emailIntent, getResources().getString(feedback))); return false; case PREFERENCE_KEY_ABOUT: startActivity(new Intent(getActivity(), AboutActivity.class)); return false; case "plus_pic": if (gplus.isChecked()) { boolean b = MainActivityHelper.checkAccountsPermission(getActivity()); if (!b) MainActivityHelper.requestAccountsPermission(getActivity()); } return false; /*FROM HERE BE FRAGMENTS*/ case "colors": ((PreferencesActivity) getActivity()).selectItem(PreferencesActivity.COLORS_PREFERENCE); return true; case "sidebar_folders": ((PreferencesActivity) getActivity()).selectItem(PreferencesActivity.FOLDERS_PREFERENCE); return true; case "sidebar_quickaccess": ((PreferencesActivity) getActivity()).selectItem(PreferencesActivity.QUICKACCESS_PREFERENCE); return true; case "advancedsearch": ((PreferencesActivity) getActivity()).selectItem(PreferencesActivity.ADVANCEDSEARCH_PREFERENCE); return true; } return false; }
From source file:aerizostudios.com.cropshop.MainActivity.java
@Override public void onMenuItemClick(View clickedView, int position) { if (position == 1) { AlertDialog.Builder alert = new AlertDialog.Builder(this); LayoutInflater inflater = (LayoutInflater) getApplicationContext() .getSystemService(Context.LAYOUT_INFLATER_SERVICE); View v = inflater.inflate(R.layout.photo_quality, null); alert.setView(v);// ww w . j a va 2s . c om alert.setTitle("Select Photo Quality"); alert.setPositiveButton("OKAY", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (normal.isChecked()) { prefs = getSharedPreferences(prefName, MODE_PRIVATE); SharedPreferences.Editor editor = prefs.edit(); editor.putInt("res", 300); editor.commit(); } else { prefs = getSharedPreferences(prefName, MODE_PRIVATE); SharedPreferences.Editor editor = prefs.edit(); editor.putInt("res", 400); editor.commit(); } prefs = getSharedPreferences(prefName, MODE_PRIVATE); quality = prefs.getInt("res", 0); } }); alert.setNegativeButton("CANCEL", null); AlertD = alert.create(); AlertD.show(); normal = (RadioButton) AlertD.findViewById(R.id.normalQuality); high = (RadioButton) AlertD.findViewById(R.id.highQuality); Log.d("alert pref", "alert pref" + quality); if (quality == 300) normal.setChecked(true); else high.setChecked(true); } if (position == 2) { Uri uri = Uri.parse("market://details?id=" + getPackageName()); Intent myAppLinkToMarket = new Intent(Intent.ACTION_VIEW, uri); try { startActivity(myAppLinkToMarket); } catch (ActivityNotFoundException e) { Toast.makeText(this, " unable to find market app", Toast.LENGTH_LONG).show(); } } if (position == 3) { try { Intent i = new Intent(Intent.ACTION_SEND); i.setType("text/plain"); i.putExtra(Intent.EXTRA_SUBJECT, "CROP SHOP"); String sAux = "\nHey friends, Check out this COOL APP - CropShop - No Crop for Whatsapp and" + " Instagram. This app helps you post images on Whatsapp and Instagram without any need " + "of cropping them. It also adds Blur Effect to the Photos like Iphone and also" + " Instagram filters." + "This app allows you to share the photos" + " directly to Instagram,Facebook and Whatsapp from the App.\n" + "Download this app from the play store.\n"; sAux = sAux + "https://play.google.com/store/apps/details?id=aerizostudios.com.cropshop \n\n"; i.putExtra(Intent.EXTRA_TEXT, sAux); startActivity(Intent.createChooser(i, "choose one")); } catch (Exception e) { //e.toString(); } } if (position == 4) { startActivity(new Intent(this, Feedback.class)); } }
From source file:com.logilite.vision.camera.CameraLauncher.java
/** * Get image from photo library.//from w w w . ja va 2s .c o m * * @param quality Compression quality hint (0-100: 0=low quality & high compression, 100=compress of max quality) * @param srcType The album to get image from. * @param returnType Set the type of image to return. */ // TODO: Images selected from SDCARD don't display correctly, but from CAMERA ALBUM do! public void getImage(int srcType, int returnType) { Intent intent = new Intent(); String title = GET_PICTURE; if (this.mediaType == PICTURE) { intent.setType("image/*"); } else if (this.mediaType == VIDEO) { intent.setType("video/*"); title = GET_VIDEO; } else if (this.mediaType == ALLMEDIA) { // I wanted to make the type 'image/*, video/*' but this does not work on all versions // of android so I had to go with the wildcard search. intent.setType("*/*"); title = GET_All; } intent.setAction(Intent.ACTION_GET_CONTENT); intent.addCategory(Intent.CATEGORY_OPENABLE); if (this.cordova != null) { this.cordova.startActivityForResult((CordovaPlugin) this, Intent.createChooser(intent, new String(title)), (srcType + 1) * 16 + returnType + 1); } }
From source file:com.crossconnect.activity.notemanager.NoteManagerPersonalNotesFragment.java
@Override public void onListItemClick(ListView l, View v, int pos, long id) { //If it is the add new note row if (pos == mAdapter.getCount() - 1) { Intent intent = new Intent(getActivity(), PersonalNotesActivity.class); // intent.putExtra(PersonalNotesEditorFragment.NOTE_BUNDLE_ID,0); startActivity(intent);//ww w . ja v a 2s .co m return; } final int position = pos; //Get the corresponding resource final Note note = mAdapter.getItem(position); final ActionItem openAction = new ActionItem(); openAction.setTitle("Open"); openAction.setIcon(getResources().getDrawable(R.drawable.ic_action_search)); final ActionItem deleteAction = new ActionItem(); deleteAction.setTitle("Delete"); deleteAction.setIcon(getResources().getDrawable(R.drawable.ic_action_delete)); final ActionItem shareAction = new ActionItem(); shareAction.setTitle("Share"); shareAction.setIcon(getResources().getDrawable(R.drawable.ic_action_share)); final QuickActionHorizontal mQuickAction = new QuickActionHorizontal(v); final String text = "blah"; openAction.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Log.d(TAG, "Opening Personal Note ID:" + note.getId()); //Open the note pass the id to it Intent intent = new Intent(getActivity(), PersonalNotesActivity.class); intent.putExtra(PersonalNotesEditorFragment.NOTE_BUNDLE_ID, note.getId()); startActivity(intent); mQuickAction.dismiss(); } }); deleteAction.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // BibleText bibleText = new SwordBibleText( note.getBook(), note.getChapter(), getActivity().getIntent().getExtras().getString("Translation")); //TODO: should use this ID instead of key but will do for now need TABLE change //notesService.removeNote(note.getId()); notesService.removeNote(note.getId()); getLoaderManager().restartLoader(0, null, NoteManagerPersonalNotesFragment.this); mAdapter.notifyDataSetChanged(); mQuickAction.dismiss(); } }); mQuickAction.addActionItem(openAction); mQuickAction.addActionItem(deleteAction); shareAction.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { String text = note.getText(); Toast.makeText(getActivity(), "Share " + text, Toast.LENGTH_SHORT).show(); Intent sendMailIntent = new Intent(Intent.ACTION_SEND); sendMailIntent.putExtra(Intent.EXTRA_SUBJECT, "CrossConnect Notes"); sendMailIntent.setType("text/plain"); getActivity().startActivity(Intent.createChooser(sendMailIntent, "Share using...")); mQuickAction.dismiss(); } }); mQuickAction.addActionItem(shareAction); mQuickAction.setAnimStyle(QuickActionVertical.ANIM_AUTO); mQuickAction.setOnDismissListener(new OnDismissListener() { @Override public void onDismiss() { } }); mQuickAction.show(); Log.i(TAG, "Item clicked: " + id); }
From source file:com.roamprocess1.roaming4world.ui.messages.MessageActivity.java
private void showFileChooser() { Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType("image/*"); intent.addCategory(Intent.CATEGORY_OPENABLE); try {/*from w ww.j av a2 s.c o m*/ startActivityForResult(Intent.createChooser(intent, "Select a File to Upload"), FILE_SELECT_CODE); } catch (android.content.ActivityNotFoundException ex) { // Potentially direct the user to the Market with a Dialog Toast.makeText(this, "Please install a File Manager.", Toast.LENGTH_SHORT).show(); } }
From source file:cc.metapro.openct.myclass.ClassActivity.java
private void showFilerChooser() { Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType("image/*"); intent.addCategory(Intent.CATEGORY_OPENABLE); try {/*from www . ja v a 2 s . c o m*/ startActivityForResult(Intent.createChooser(intent, getString(R.string.select_schedule_file)), FILE_SELECT_CODE); } catch (ActivityNotFoundException ex) { Toast.makeText(this, R.string.fail_file_chooser, Toast.LENGTH_LONG).show(); } }
From source file:ch.blinkenlights.android.vanilla.MediaUtils.java
/** * Creates and sends a share intent across the system. * @param ctx context to execute resolving on. * @param song the song to share.// w w w . ja v a 2 s .c o m */ public static void shareMedia(Context ctx, Song song) { if (song == null || song.path == null) return; Uri uri = null; try { uri = FileProvider.getUriForFile(ctx, ctx.getApplicationContext().getPackageName() + ".fileprovider", new File(song.path)); } catch (IllegalArgumentException e) { Toast.makeText(ctx, R.string.share_failed, Toast.LENGTH_SHORT).show(); } if (uri == null) return; // Fileprovider failed, we can not continue. Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("audio/*"); intent.putExtra(Intent.EXTRA_STREAM, uri); try { ctx.startActivity(Intent.createChooser(intent, ctx.getString(R.string.sendto))); } catch (ActivityNotFoundException e) { Toast.makeText(ctx, R.string.no_receiving_apps, Toast.LENGTH_SHORT).show(); } }
From source file:com.code.android.vibevault.ShowDetailsScreen.java
/** Handle user's long-click selection. * *//*from ww w. j a v a2s . c om*/ @Override public boolean onContextItemSelected(MenuItem item) { AdapterContextMenuInfo menuInfo = (AdapterContextMenuInfo) item.getMenuInfo(); if (menuInfo != null) { ArchiveSongObj selSong = (ArchiveSongObj) trackList.getAdapter().getItem(menuInfo.position); switch (item.getItemId()) { case (VibeVault.STREAM_CONTEXT_ID): // Start streaming. int track = pService.enqueue(selSong); pService.playSongFromPlaylist(track); break; case (VibeVault.DOWNLOAD_SONG): selSong.setDownloadShow(show); dService.addSong(selSong); break; case (VibeVault.ADD_SONG_TO_QUEUE): pService.enqueue(selSong); break; case (VibeVault.EMAIL_LINK): final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.setType("plain/text"); emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Great song on archive.org: " + selSong.toString()); emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "Hey,\n\nI found a song you should listen to. It's called " + selSong.toString() + " and it's off of " + selSong.getShowTitle() + ". You can get it here: " + selSong.getLowBitRate() + "\n\nSent using VibeVault for Android."); startActivity(Intent.createChooser(emailIntent, "Send mail...")); break; default: return false; } return true; } return false; }