List of usage examples for android.content Intent CATEGORY_OPENABLE
String CATEGORY_OPENABLE
To view the source code for android.content Intent CATEGORY_OPENABLE.
Click Source Link
From source file:com.github.chenxiaolong.dualbootpatcher.FileUtils.java
private static void setCommonOpenOptions(Intent intent, String mimeType) { intent.addCategory(Intent.CATEGORY_OPENABLE); intent.setType(mimeType); }
From source file:com.owncloud.android.ui.dialog.UploadSourceDialogFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { String[] allTheItems = { getString(R.string.actionbar_upload_files), getString(R.string.actionbar_upload_from_apps) }; AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle(R.string.actionbar_upload); builder.setItems(allTheItems, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int item) { if (item == 0) { Intent action = new Intent(getActivity(), UploadFilesActivity.class); action.putExtra(UploadFilesActivity.EXTRA_ACCOUNT, ((FileActivity) getActivity()).getAccount()); //startActivityForResult(action, ACTION_SELECT_MULTIPLE_FILES); // this flow seems broken; // Actionbarsherlock, maybe? getActivity().startActivityForResult(action, ACTION_SELECT_MULTIPLE_FILES); } else if (item == 1) { Intent action = new Intent(Intent.ACTION_GET_CONTENT); action = action.setType("*/*").addCategory(Intent.CATEGORY_OPENABLE); //Intent.EXTRA_ALLOW_MULTIPLE is only supported on api level 18+, Jelly Bean if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { action.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true); }//from ww w . j a v a2s. c o m //startActivityForResult( // this flow seems broken; // Actionbarsherlock, maybe? getActivity().startActivityForResult( Intent.createChooser(action, getString(R.string.upload_chooser_title)), ACTION_SELECT_CONTENT_FROM_APPS); } } }); return builder.create(); }
From source file:com.wodify.cordova.plugin.filepicker.FilePicker.java
/** * Pick file from device./* w w w.jav a 2 s. c om*/ */ public void pickFile() { Intent intent = new Intent(); // Any type of file may be picked intent.setType("*/*"); intent.setAction(Intent.ACTION_GET_CONTENT); intent.addCategory(Intent.CATEGORY_OPENABLE); if (this.cordova != null) { this.cordova.startActivityForResult((CordovaPlugin) this, Intent.createChooser(intent, "Pick File"), 0); } }
From source file:com.github.chenxiaolong.dualbootpatcher.FileUtils.java
private static void setCommonSaveOptions(Intent intent, String mimeType, String defaultName) { intent.addCategory(Intent.CATEGORY_OPENABLE); intent.setType(mimeType);//from ww w .j a v a 2 s . c o m intent.putExtra(Intent.EXTRA_TITLE, defaultName); }
From source file:com.nextome.geojsonviewer.MainActivity.java
public void openFilePicker(View v) { Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT); intent.addCategory(Intent.CATEGORY_OPENABLE); intent.setType("application/octet-stream"); startActivityForResult(intent, READ_REQUEST_CODE); }
From source file:com.mantz_it.rfanalyzer.SettingsFragment.java
@Override public boolean onPreferenceClick(Preference preference) { // FileSource file: if (preference.getKey().equals(getString(R.string.pref_filesource_file))) { try {//from w ww . ja v a 2 s.c o m Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType("*/*"); intent.addCategory(Intent.CATEGORY_OPENABLE); startActivityForResult(Intent.createChooser(intent, "Select a file (8-bit complex IQ samples)"), FILESOURCE_RESULT_CODE); // No error so far... let's dismiss the text input dialog: Dialog dialog = ((EditTextPreference) preference).getDialog(); if (dialog != null) dialog.dismiss(); return true; } catch (ActivityNotFoundException e) { Toast.makeText(SettingsFragment.this.getActivity(), "No file browser is installed!", Toast.LENGTH_LONG).show(); // Note that there is still the text dialog visible for the user to input a file path... so no more error handling necessary } return false; } // Show Log: else if (preference.getKey().equals(getString(R.string.pref_showLog))) { try { String logfile = ((EditTextPreference) findPreference(getString(R.string.pref_logfile))).getText(); Uri uri = Uri.fromFile(new File(logfile)); Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(uri, "text/plain"); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); this.startActivity(intent); return true; } catch (ActivityNotFoundException e) { Toast.makeText(SettingsFragment.this.getActivity(), "No text viewer is installed!", Toast.LENGTH_LONG).show(); } return false; } return false; }
From source file:org.alfresco.mobile.android.platform.intent.BaseActionUtils.java
/** * Allow to pick file with other apps./*from www. j a v a 2 s . co m*/ * * @return Activity for Result. */ public static void actionPickFile(Fragment f, int requestCode) { Intent i = new Intent(Intent.ACTION_GET_CONTENT); i.setType("*/*"); i.addCategory(Intent.CATEGORY_OPENABLE); f.startActivityForResult(Intent.createChooser(i, f.getText(R.string.content_app_pick_file)), requestCode); }
From source file:com.commonsware.android.documents.consumer.ConsumerFragment.java
@TargetApi(Build.VERSION_CODES.KITKAT) private void open() { Intent i = new Intent().setType("*/*").setAction(Intent.ACTION_OPEN_DOCUMENT) .addCategory(Intent.CATEGORY_OPENABLE); startActivityForResult(i, REQUEST_OPEN); }
From source file:org.sufficientlysecure.keychain.util.FileHelper.java
/** Opens the preferred installed file manager on Android and shows a toast * if no manager is installed. */ private static void openDocumentPreKitKat(Fragment fragment, Uri last, String mimeType, boolean multiple, int requestCode) { Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.addCategory(Intent.CATEGORY_OPENABLE); if (Build.VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN_MR2) { intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, multiple); }/*from ww w . ja v a 2s .c o m*/ intent.setData(last); intent.setType(mimeType); try { fragment.startActivityForResult(intent, requestCode); } catch (ActivityNotFoundException e) { // No compatible file manager was found. Toast.makeText(fragment.getActivity(), R.string.no_filemanager_installed, Toast.LENGTH_SHORT).show(); } }
From source file:com.commonsware.android.documents.consumer.ConsumerFragment.java
private void get() { Intent i = new Intent().setType("image/png").setAction(Intent.ACTION_GET_CONTENT) .addCategory(Intent.CATEGORY_OPENABLE); startActivityForResult(i, REQUEST_GET); }