List of usage examples for android.content Intent EXTRA_TITLE
String EXTRA_TITLE
To view the source code for android.content Intent EXTRA_TITLE.
Click Source Link
From source file:com.owncloud.android.ui.activity.ReceiveExternalFilesActivity.java
/** * Suggest a filename based on the extras in the intent. * Show soft keyboard when no filename could be suggested. * * @param alertDialog AlertDialog//from w w w.j av a 2s. co m * @param input EditText The view where to place the filename in. */ private void setFileNameFromIntent(AlertDialog alertDialog, EditText input) { String subject = getIntent().getStringExtra(Intent.EXTRA_SUBJECT); String title = getIntent().getStringExtra(Intent.EXTRA_TITLE); String fileName = subject != null ? subject : title; input.setText(fileName); input.selectAll(); if (fileName == null) { // Show soft keyboard Window window = alertDialog.getWindow(); if (window != null) window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE); } }
From source file:eu.faircode.adblocker.ActivitySettings.java
private Intent getIntentCreateExport() { Intent intent;//w w w. j a va2 s .co m if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) { if (Util.isPackageInstalled("org.openintents.filemanager", this)) { intent = new Intent("org.openintents.action.PICK_DIRECTORY"); } else { intent = new Intent(Intent.ACTION_VIEW); intent.setData( Uri.parse("https://play.google.com/store/apps/details?id=org.openintents.filemanager")); } } else { intent = new Intent(Intent.ACTION_CREATE_DOCUMENT); intent.addCategory(Intent.CATEGORY_OPENABLE); intent.setType("*/*"); // text/xml intent.putExtra(Intent.EXTRA_TITLE, "adblocker_" + new SimpleDateFormat("yyyyMMdd").format(new Date().getTime()) + ".xml"); } return intent; }
From source file:com.master.metehan.filtereagle.ActivityMain.java
private Intent getIntentLogcat() { Intent intent;// w w w . j a va 2 s . c o m if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) { if (Util.isPackageInstalled("org.openintents.filemanager", this)) { intent = new Intent("org.openintents.action.PICK_DIRECTORY"); } else { intent = new Intent(Intent.ACTION_VIEW); intent.setData( Uri.parse("https://play.google.com/store/apps/details?id=org.openintents.filemanager")); } } else { intent = new Intent(Intent.ACTION_CREATE_DOCUMENT); intent.addCategory(Intent.CATEGORY_OPENABLE); intent.setType("text/plain"); intent.putExtra(Intent.EXTRA_TITLE, "logcat.txt"); } return intent; }
From source file:org.planetmono.dcuploader.ActivityUploader.java
@SuppressWarnings("unchecked") @Override/*ww w . j ava 2s. c om*/ public void onCreate(Bundle savedState) { super.onCreate(savedState); initViews(); if (formLocation) queryLocation(true); if (savedState != null) { if (savedState.containsKey("tempfile")) tempFile = new File(savedState.getString("tempfile")); if (savedState.containsKey("target")) resolveTarget(savedState.getString("target")); if (savedState.containsKey("tempfiles")) tempFiles = savedState.getStringArrayList("tempfiles"); if (savedState.containsKey("contents")) { contents = new ArrayList<Uri>(); String[] carr = savedState.getStringArray("contents"); for (String s : carr) contents.add(Uri.parse(s)); } } postfix = "from <a href=\"http://palladium.planetmono.org/dcuploader\">DCUploader</a>"; Button uploadVisit = (Button) findViewById(R.id.upload_visit); if (passThrough || target == null) uploadVisit.setEnabled(false); else uploadVisit.setEnabled(true); /* populate data by getting STREAM parameter */ Intent i = getIntent(); Bundle b = i.getExtras(); String action = i.getAction(); if (action.equals(Intent.ACTION_SEND) || action.equals(Intent.ACTION_SEND_MULTIPLE)) { called = true; if (i.hasExtra(Intent.EXTRA_STREAM)) { Object o = b.get(Intent.EXTRA_STREAM); /* quick and dirty. any better idea? */ try { contents.add((Uri) o); } catch (Exception e1) { try { contents = (ArrayList<Uri>) ((ArrayList<Uri>) o).clone(); } catch (Exception e2) { } } boolean exceeded = false; if (contents.size() > 5) { exceeded = true; do { contents.remove(5); } while (contents.size() > 5); } galleryChanged = true; updateImageButtons(); resetThumbnails(); updateGallery(); if (exceeded) Toast.makeText(this, " 5 . 5 ??? ? ?.", Toast.LENGTH_LONG).show(); } if (i.hasExtra(Intent.EXTRA_TEXT)) { ((EditText) findViewById(R.id.upload_text)).setText(b.getString(Intent.EXTRA_TEXT)); } } else if (action.equals("share")) { called = true; /* HTC web browser uses non-standard intent */ ((EditText) findViewById(R.id.upload_text)).setText(b.getString(Intent.EXTRA_TITLE)); } else if (action.equals(Intent.ACTION_VIEW)) { Uri uri = i.getData(); if (i.getCategories().contains(Intent.CATEGORY_BROWSABLE)) { passThrough = true; Pattern p = Pattern.compile("id=([\\-a-zA-Z0-9_]+)"); Matcher m = p.matcher(uri.toString()); if (m.find()) { resolveTarget(m.group(1)); } else { passThrough = false; } if (uri.getHost().equals(Application.HOST_DCMYS)) { destination = Application.DESTINATION_DCMYS; postfix = "from dc.m.dcmys.kr w/ <a href=\"http://palladium.planetmono.org/dcuploader\">DCUploader</a>"; } else if (uri.getHost().equals(Application.HOST_MOOLZO)) { destination = Application.DESTINATION_MOOLZO; postfix = "- From m.oolzo.com w/ <a href=\"http://palladium.planetmono.org/dcuploader\">DCUploader</a>"; } else if (uri.getHost().equals(Application.HOST_DCINSIDE)) { destination = Application.DESTINATION_DCINSIDE; } setDefaultImage(); } } reloadConfigurations(); }
From source file:android_network.hetnet.vpn_service.ActivitySettings.java
private Intent getIntentCreateExport() { Intent intent;/*w ww. ja v a 2s . c o m*/ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) { if (Util.isPackageInstalled("org.openintents.filemanager", this)) { intent = new Intent("org.openintents.action.PICK_DIRECTORY"); } else { intent = new Intent(Intent.ACTION_VIEW); intent.setData( Uri.parse("https://play.google.com/store/apps/details?id=org.openintents.filemanager")); } } else { intent = new Intent(Intent.ACTION_CREATE_DOCUMENT); intent.addCategory(Intent.CATEGORY_OPENABLE); intent.setType("*/*"); // text/xml intent.putExtra(Intent.EXTRA_TITLE, "netguard_" + new SimpleDateFormat("yyyyMMdd").format(new Date().getTime()) + ".xml"); } return intent; }
From source file:com.ubuntuone.android.files.activity.FilesActivity.java
private void onFileClicked(final String resourcePath, final String resourceState, final String filename, final String data) { Log.d(TAG, "onFileClicked() data=" + data); final boolean isStateIdle = (resourceState == null); boolean isDownloading, isFailedDownload; isDownloading = isFailedDownload = false; if (!isStateIdle) { isDownloading = ResourceState.STATE_GETTING.equals(resourceState); isFailedDownload = ResourceState.STATE_GETTING_FAILED.equals(resourceState); }//from w w w . ja va 2 s .c o m final boolean validTarget = MetaUtilities.isValidUriTarget(data); Log.d(TAG, String.format("isStateIdle=%s, validTarget=%s", String.valueOf(isStateIdle), String.valueOf(validTarget))); if (validTarget && isStateIdle) { // File exists and is not being downloaded. if (data.startsWith(ContentResolver.SCHEME_CONTENT)) { Log.d(TAG, "opening file from content uri"); final Intent intent = new Intent(Intent.ACTION_VIEW); final Uri uri = Uri.parse(data); intent.setDataAndType(uri, FileUtilities.getMime(filename)); final Intent chooser = new Intent(Intent.ACTION_VIEW); chooser.putExtra(Intent.EXTRA_INTENT, intent); chooser.putExtra(Intent.EXTRA_TITLE, getText(R.string.dialog_open_with_title)); try { startActivity(intent); } catch (ActivityNotFoundException e) { UIUtil.showToast(this, R.string.toast_no_suitable_activity); } } else { Log.d(TAG, "opening file directly"); File file = null; try { Log.d(TAG, "opening " + data); if (data.startsWith(ContentResolver.SCHEME_FILE)) { file = new File(URI.create(data)); } else { file = new File(data); } } catch (Exception e) { Log.e(TAG, "file uri is empty", e); } if (file != null && file.exists()) { Log.d(TAG, "Resource exists, opening: " + file.getAbsolutePath()); Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(Uri.fromFile(file), FileUtilities.getMime(data)); Intent chooser = new Intent(Intent.ACTION_VIEW); chooser.putExtra(Intent.EXTRA_INTENT, intent); chooser.putExtra(Intent.EXTRA_TITLE, getText(R.string.dialog_open_with_title)); try { startActivity(intent); } catch (ActivityNotFoundException e) { UIUtil.showToast(this, R.string.toast_no_suitable_activity); } } else { Log.d(TAG, "Setting resource as not cached: " + resourcePath); MetaUtilities.setIsCached(resourcePath, false); MetaUtilities.setStateAndData(resourcePath, null, null); UIUtil.showToast(this, R.string.toast_file_not_cached_anymore, false); mResolver.notifyChange(Nodes.CONTENT_URI, null); } } } else if (isFailedDownload) { // File does not exist or download failed. Log.d(TAG, "was: failed download or invalid"); if (NetworkUtil.isConnected(this)) { downloadFile(resourcePath); } else { UIUtil.showToast(this, R.string.toast_no_network); } } else if (isStateIdle && !validTarget) { // File removed from device, need to download. downloadFile(resourcePath); } else if (isDownloading) { UIUtil.showToast(this, "Please wait while downloading..."); } else { Log.e(TAG, "unhandled state: " + resourceState); } }
From source file:github.daneren2005.dsub.fragments.SubsonicFragment.java
protected void playExternalPlayer(Entry entry) { if (!entryExists(entry)) { Util.toast(context, R.string.download_need_download); } else {//from w w w .ja va 2s . c o m DownloadFile check = new DownloadFile(context, entry, false); File file = check.getCompleteFile(); Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(Uri.fromFile(file), "video/*"); intent.putExtra(Intent.EXTRA_TITLE, entry.getTitle()); List<ResolveInfo> intents = context.getPackageManager().queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); if (intents != null && intents.size() > 0) { startActivity(intent); } else { Util.toast(context, R.string.download_no_streaming_player); } } }
From source file:org.de.jmg.learn.MainActivity.java
@SuppressLint("InlinedApi") public void SaveVokAs(boolean blnUniCode, boolean blnNew) throws Exception { boolean blnActionCreateDocument = false; try {/*from www . j ava2s. co m*/ if (fPA.fragMain != null && fPA.fragMain.mainView != null) fPA.fragMain.EndEdit(false); if (!libString.IsNullOrEmpty(vok.getFileName()) || vok.getURI() == null || Build.VERSION.SDK_INT < 19) { boolean blnSuccess; for (int i = 0; i < 2; i++) { try { String key = "AlwaysStartExternalProgram"; int AlwaysStartExternalProgram = prefs.getInt(key, 999); lib.YesNoCheckResult res; if (AlwaysStartExternalProgram == 999 && !(vok.getURI() != null && i == 1)) { res = lib.ShowMessageYesNoWithCheckbox(this, "", getString(R.string.msgStartExternalProgram), getString(R.string.msgRememberChoice), false); if (res != null) { if (res.res == yesnoundefined.undefined) return; if (res.checked) prefs.edit().putInt(key, res.res == yesnoundefined.yes ? -1 : 0).commit(); } else { yesnoundefined par = yesnoundefined.undefined; res = new lib.YesNoCheckResult(par, true); } } else { yesnoundefined par = yesnoundefined.undefined; if (AlwaysStartExternalProgram == -1) par = yesnoundefined.yes; if (AlwaysStartExternalProgram == 0) par = yesnoundefined.no; res = new lib.YesNoCheckResult(par, true); } if ((vok.getURI() != null && i == 1) || res.res == yesnoundefined.no) { Intent intent = new Intent(this, AdvFileChooser.class); ArrayList<String> extensions = new ArrayList<>(); extensions.add(".k??"); extensions.add(".v??"); extensions.add(".K??"); extensions.add(".V??"); extensions.add(".KAR"); extensions.add(".VOK"); extensions.add(".kar"); extensions.add(".vok"); extensions.add(".dic"); extensions.add(".DIC"); if (libString.IsNullOrEmpty(vok.getFileName())) { if (vok.getURI() != null) { intent.setData(vok.getURI()); } } else { File F = new File(vok.getFileName()); Uri uri = Uri.fromFile(F); intent.setData(uri); } intent.putExtra("URIName", vok.getURIName()); intent.putStringArrayListExtra("filterFileExtension", extensions); intent.putExtra("blnUniCode", blnUniCode); intent.putExtra("DefaultDir", new File(JMGDataDirectory).exists() ? JMGDataDirectory : Environment.getExternalStorageDirectory().getPath()); intent.putExtra("selectFolder", false); intent.putExtra("blnNew", blnNew); if (_blnUniCode) _oldUniCode = yesnoundefined.yes; else _oldUniCode = yesnoundefined.no; _blnUniCode = blnUniCode; this.startActivityForResult(intent, FILE_CHOOSERADV); blnSuccess = true; } else if (Build.VERSION.SDK_INT < 19) { //org.openintents.filemanager Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setData(vok.getURI()); intent.putExtra("org.openintents.extra.WRITEABLE_ONLY", true); intent.putExtra("org.openintents.extra.TITLE", getString(R.string.SaveAs)); intent.putExtra("org.openintents.extra.BUTTON_TEXT", getString(R.string.btnSave)); intent.setType("*/*"); Intent chooser = Intent.createChooser(intent, getString(R.string.SaveAs)); if (intent.resolveActivity(context.getPackageManager()) != null) { startActivityForResult(chooser, FILE_OPENINTENT); blnSuccess = true; } else { lib.ShowToast(this, getString(R.string.InstallFilemanager)); intent.setData(null); intent.removeExtra("org.openintents.extra.WRITEABLE_ONLY"); intent.removeExtra("org.openintents.extra.TITLE"); intent.removeExtra("org.openintents.extra.BUTTON_TEXT"); startActivityForResult(chooser, FILE_OPENINTENT); blnSuccess = true; } } else { blnActionCreateDocument = true; blnSuccess = true; } } catch (Exception ex) { blnSuccess = false; Log.e("SaveAs", ex.getMessage(), ex); if (i == 1) { lib.ShowException(this, ex); } } if (blnSuccess) break; } } else if (Build.VERSION.SDK_INT >= 19) { blnActionCreateDocument = true; } if (blnActionCreateDocument) { /** * Open a file for writing and append some text to it. */ // ACTION_OPEN_DOCUMENT is the intent to choose a file via the system's // file browser. Intent intent = new Intent(Intent.ACTION_CREATE_DOCUMENT); // Create a file with the requested MIME type. String defaultURI = prefs.getString("defaultURI", ""); if (!libString.IsNullOrEmpty(defaultURI)) { String FName = ""; if (vok.getURI() != null) { String path2 = lib.dumpUriMetaData(this, vok.getURI()); if (path2.contains(":")) path2 = path2.split(":")[0]; FName = path2.substring(path2.lastIndexOf("/") + 1); } else if (!libString.IsNullOrEmpty(vok.getFileName())) { FName = new File(vok.getFileName()).getName(); } intent.putExtra(Intent.EXTRA_TITLE, FName); //defaultURI = (!defaultURI.endsWith("/")?defaultURI.substring(0,defaultURI.lastIndexOf("/")+1):defaultURI); Uri def = Uri.parse(defaultURI); intent.setData(def); } else { Log.d("empty", "empty"); //intent.setType("file/*"); } // Filter to only show results that can be "opened", such as a // file (as opposed to a list of contacts or timezones). intent.addCategory(Intent.CATEGORY_OPENABLE); // Filter to show only text files. intent.setType("*/*"); startActivityForResult(intent, EDIT_REQUEST_CODE); } } catch (Exception ex) { libLearn.gStatus = "SaveVokAs"; lib.ShowException(this, ex); } }
From source file:com.dish.browser.activity.BrowserActivity.java
@Override public void showFileChooser(ValueCallback<Uri[]> filePathCallback) { if (mFilePathCallback != null) { mFilePathCallback.onReceiveValue(null); }/*from w w w.jav a2s . co m*/ mFilePathCallback = filePathCallback; Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); if (takePictureIntent.resolveActivity(getActivity().getPackageManager()) != null) { // Create the File where the photo should go File photoFile = null; try { photoFile = Utils.createImageFile(); takePictureIntent.putExtra("PhotoPath", mCameraPhotoPath); } catch (IOException ex) { // Error occurred while creating the File Log.e(Constants.TAG, "Unable to create Image File", ex); } // 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); mActivity.startActivityForResult(chooserIntent, 1); }
From source file:im.vector.activity.RoomActivity.java
/** * * @param message/* w w w. ja va2s. c om*/ * @param mediaUrl * @param mediaMimeType */ public void createDocument(Message message, final String mediaUrl, final String mediaMimeType) { String filename = "MatrixConsole_" + System.currentTimeMillis(); MimeTypeMap mime = MimeTypeMap.getSingleton(); filename += "." + mime.getExtensionFromMimeType(mediaMimeType); if (message instanceof FileMessage) { FileMessage fileMessage = (FileMessage) message; if (null != fileMessage.body) { filename = fileMessage.body; } } mPendingMediaUrl = mediaUrl; mPendingMimeType = mediaMimeType; Intent intent = new Intent(Intent.ACTION_CREATE_DOCUMENT).addCategory(Intent.CATEGORY_OPENABLE) .setType(mediaMimeType).putExtra(Intent.EXTRA_TITLE, filename); startActivityForResult(intent, CREATE_DOCUMENT); }