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:ca.rmen.android.poetassistant.main.reader.ReaderFragment.java
@TargetApi(Build.VERSION_CODES.KITKAT) private void saveAs() { Intent intent = new Intent(Intent.ACTION_CREATE_DOCUMENT); intent.addCategory(Intent.CATEGORY_OPENABLE); intent.setType("text/plain"); PoemFile poemFile = mPoemPrefs.getSavedPoem(); final String fileName; if (poemFile != null) { fileName = poemFile.name;/*from www .j av a 2 s . co m*/ } else { fileName = PoemFile.generateFileName(mBinding.tvText.getText().toString()); } if (!TextUtils.isEmpty(fileName)) intent.putExtra(Intent.EXTRA_TITLE, fileName); startActivityForResult(intent, ACTION_FILE_SAVE_AS); }
From source file:com.sxt.chat.activity.NotifycationActivity.java
private void startGalleryApp() { Intent intent = new Intent(); intent.setType("image/*"); intent.addCategory(Intent.CATEGORY_OPENABLE); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) { intent.setAction(Intent.ACTION_GET_CONTENT); } else {//w w w. j a v a 2s . co m intent.setAction(Intent.ACTION_OPEN_DOCUMENT); } intent = Intent.createChooser(intent, ""); startActivityForResult(intent, REQUEST_CODE_GALLERY); }
From source file:com.polyvi.xface.extension.camera.XCameraExt.java
public void getImage() { Intent intent = new Intent(); String title = GET_PICTURE;/*w w w . j av a 2 s .co m*/ if (mMediaType == PICTURE) { intent.setType("image/*"); } else if (mMediaType == VIDEO) { intent.setType("video/*"); title = GET_VIDEO; } else if (mMediaType == ALLMEDIA) { intent.setType("*/*"); title = GET_All; } intent.setAction(Intent.ACTION_GET_CONTENT); intent.addCategory(Intent.CATEGORY_OPENABLE); // ?? mExtensionContext.getSystemContext().startActivityForResult(this, Intent.createChooser(intent, new String(title)), PHOTO_REQUEST_CODE); }
From source file:com.commonsware.android.diceware.PassphraseFragment.java
@TargetApi(Build.VERSION_CODES.KITKAT) private void open() { Intent i = new Intent().setType("text/plain").setAction(Intent.ACTION_OPEN_DOCUMENT) .addCategory(Intent.CATEGORY_OPENABLE); startActivityForResult(i, REQUEST_OPEN); }
From source file:org.adaway.ui.lists.ListsFragment.java
/** * Import user lists backup file by showing a file picker. */// ww w . jav a 2s . c o m private void importLists() { Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType("*/*"); intent.addCategory(Intent.CATEGORY_OPENABLE); // Start file picker activity try { this.startActivityForResult(intent, ImportExportHelper.REQUEST_CODE_IMPORT); } catch (ActivityNotFoundException exception) { // Show dialog to install file picker FragmentManager fragmentManager = this.getFragmentManager(); if (fragmentManager != null) { ActivityNotFoundDialogFragment .newInstance(R.string.no_file_manager_title, R.string.no_file_manager, "market://details?id=org.openintents.filemanager", "OI File Manager") .show(fragmentManager, "notFoundDialog"); } } }
From source file:org.gnucash.android.ui.common.BaseDrawerActivity.java
/** * Handler for the navigation drawer items * *///from www .j a v a2s . c o m protected void onDrawerMenuItemClicked(int itemId) { switch (itemId) { case R.id.nav_item_open: { //Open... files if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { //use the storage access framework Intent openDocument = new Intent(Intent.ACTION_OPEN_DOCUMENT); openDocument.addCategory(Intent.CATEGORY_OPENABLE); openDocument.setType("*/*"); startActivityForResult(openDocument, REQUEST_OPEN_DOCUMENT); } else { AccountsActivity.startXmlFileChooser(this); } } break; case R.id.nav_item_favorites: { //favorite accounts Intent intent = new Intent(this, AccountsActivity.class); intent.putExtra(AccountsActivity.EXTRA_TAB_INDEX, AccountsActivity.INDEX_FAVORITE_ACCOUNTS_FRAGMENT); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); startActivity(intent); } break; case R.id.nav_item_reports: { Intent intent = new Intent(this, ReportsActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); startActivity(intent); } break; /* //todo: Re-enable this when Budget UI is complete case R.id.nav_item_budgets: startActivity(new Intent(this, BudgetsActivity.class)); break; */ case R.id.nav_item_scheduled_actions: { //show scheduled transactions Intent intent = new Intent(this, ScheduledActionsActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); startActivity(intent); } break; case R.id.nav_item_export: AccountsActivity.openExportFragment(this); break; case R.id.nav_item_settings: //Settings activity startActivity(new Intent(this, PreferenceActivity.class)); break; case R.id.nav_item_help: SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); prefs.edit().putBoolean(UxArgument.SKIP_PASSCODE_SCREEN, true).apply(); UserVoice.launchUserVoice(this); break; } mDrawerLayout.closeDrawer(mNavigationView); }
From source file:it.rignanese.leo.slimfacebook.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // setup the sharedPreferences savedPreferences = PreferenceManager.getDefaultSharedPreferences(this); //setup the theme //int savedThemeId = Integer.parseInt(savedPreferences.getString("pref_key_theme8", "2131361965"));//get the last saved theme id //setTheme(savedThemeId);//this refresh the theme if necessary // TODO fix the change of status bar setContentView(R.layout.activity_main);//load the layout // setup the refresh layout swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_container); swipeRefreshLayout.setColorSchemeResources(R.color.officialBlueFacebook, R.color.darkBlueSlimFacebookTheme);// set the colors swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override/*from w ww . j a v a 2s. c o m*/ public void onRefresh() { refreshPage();//reload the page swipeRefresh = true; } }); // setup the webView webViewFacebook = (WebView) findViewById(R.id.webView); setUpWebViewDefaults(webViewFacebook);//set the settings goHome();//load homepage //WebViewClient that is the client callback. webViewFacebook.setWebViewClient(new WebViewClient() {//advanced set up // when there isn't a connetion public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) { String summary = "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" /></head><body><h1 " + "style='text-align:center; padding-top:15%;'>" + getString(R.string.titleNoConnection) + "</h1> <h3 style='text-align:center; padding-top:1%; font-style: italic;'>" + getString(R.string.descriptionNoConnection) + "</h3> <h5 style='text-align:center; padding-top:80%; opacity: 0.3;'>" + getString(R.string.awards) + "</h5></body></html>"; webViewFacebook.loadData(summary, "text/html; charset=utf-8", "utf-8");//load a custom html page noConnectionError = true; swipeRefreshLayout.setRefreshing(false); //when the page is loaded, stop the refreshing } // when I click in a external link public boolean shouldOverrideUrlLoading(WebView view, String url) { if (url == null || url.contains("facebook.com")) { //url is ok return false; } else { if (url.contains("https://scontent")) { //TODO add the possibility to download and share directly Toast.makeText(getApplicationContext(), getString(R.string.downloadOrShareWithBrowser), Toast.LENGTH_LONG).show(); //TODO get bitmap from url Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); startActivity(intent); return true; } //if the link doesn't contain 'facebook.com', open it using the browser startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url))); return true; } } //START management of loading @Override public void onPageStarted(WebView view, String url, Bitmap favicon) { //TODO when I push on messages, open messanger // if(url!=null){ // if (url.contains("soft=messages") || url.contains("facebook.com/messages")) { // Toast.makeText(getApplicationContext(),"Open Messanger", // Toast.LENGTH_SHORT).show(); // startActivity(new Intent(getPackageManager().getLaunchIntentForPackage("com.facebook.orca")));//messanger // } // } // show you progress image if (!swipeRefresh) { final MenuItem refreshItem = optionsMenu.findItem(R.id.refresh); refreshItem.setActionView(R.layout.circular_progress_bar); } swipeRefresh = false; super.onPageStarted(view, url, favicon); } @Override public void onPageFinished(WebView view, String url) { // hide your progress image final MenuItem refreshItem = optionsMenu.findItem(R.id.refresh); refreshItem.setActionView(null); super.onPageFinished(view, url); swipeRefreshLayout.setRefreshing(false); //when the page is loaded, stop the refreshing } //END management of loading }); //WebChromeClient for handling all chrome functions. webViewFacebook.setWebChromeClient(new WebChromeClient() { //to upload files //thanks to gauntface //https://github.com/GoogleChrome/chromium-webview-samples public boolean onShowFileChooser(WebView webView, ValueCallback<Uri[]> filePathCallback, WebChromeClient.FileChooserParams fileChooserParams) { if (mFilePathCallback != null) { mFilePathCallback.onReceiveValue(null); } mFilePathCallback = filePathCallback; Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); if (takePictureIntent.resolveActivity(getBaseContext().getPackageManager()) != null) { // Create the File where the photo should go File photoFile = null; try { photoFile = createImageFile(); takePictureIntent.putExtra("PhotoPath", mCameraPhotoPath); } catch (IOException ex) { // Error occurred while creating the File } // Continue only if the File was successfully created if (photoFile != null) { mCameraPhotoPath = "file:" + photoFile.getAbsolutePath(); takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photoFile)); } else { takePictureIntent = null; } } Intent contentSelectionIntent = new Intent(Intent.ACTION_GET_CONTENT); contentSelectionIntent.addCategory(Intent.CATEGORY_OPENABLE); contentSelectionIntent.setType("image/*"); Intent[] intentArray; if (takePictureIntent != null) { intentArray = new Intent[] { takePictureIntent }; } else { intentArray = new Intent[0]; } Intent chooserIntent = new Intent(Intent.ACTION_CHOOSER); chooserIntent.putExtra(Intent.EXTRA_INTENT, contentSelectionIntent); chooserIntent.putExtra(Intent.EXTRA_TITLE, "Image Chooser"); chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, intentArray); startActivityForResult(chooserIntent, INPUT_FILE_REQUEST_CODE); return true; } }); }
From source file:com.commonsware.android.diceware.PassphraseFragment.java
private void get() { Intent i = new Intent().setType("text/plain").setAction(Intent.ACTION_GET_CONTENT) .addCategory(Intent.CATEGORY_OPENABLE); startActivityForResult(i, REQUEST_GET); }
From source file:fileops.FileChooser.java
@Override public boolean onOptionsItemSelected(MenuItem item) { // TODO Menu Item Selection Action switch (item.getItemId()) { case R.id.action_add: createFolder();// w w w . j a v a 2s . c o m break; case R.id.action_settings: Intent i = new Intent(getActivity().getApplicationContext(), Settings.class); startActivity(i); break; case R.id.action_refresh: fill(currentDir); break; case R.id.action_upload: Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType("*/*"); intent.addCategory(Intent.CATEGORY_OPENABLE); try { startActivityForResult(Intent.createChooser(intent, "Select a File to Upload"), 0); } catch (android.content.ActivityNotFoundException ex) { // Potentially direct the user to the Market with a Dialog Toast.makeText(getActivity(), "Please install a File Manager.", 1000).show(); } } return super.onOptionsItemSelected(item); }
From source file:org.skt.runtime.original.CameraLauncher.java
/** * Get image from photo library.//from ww w. ja va 2 s . com * * @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); this.ctx.startActivityForResult((Plugin) this, Intent.createChooser(intent, new String(title)), (srcType + 1) * 16 + returnType + 1); }