List of usage examples for android.content Intent ACTION_GET_CONTENT
String ACTION_GET_CONTENT
To view the source code for android.content Intent ACTION_GET_CONTENT.
Click Source Link
From source file:android_network.hetnet.vpn_service.ActivitySettings.java
private Intent getIntentOpenHosts() { Intent intent;/*ww w .jav a 2s . c om*/ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) intent = new Intent(Intent.ACTION_GET_CONTENT); else intent = new Intent(Intent.ACTION_OPEN_DOCUMENT); intent.addCategory(Intent.CATEGORY_OPENABLE); intent.setType("*/*"); // text/plain return intent; }
From source file:com.owncloud.android.ui.activity.FileDisplayActivity.java
@Override protected Dialog onCreateDialog(int id) { Dialog dialog = null;// w w w . j a v a2 s .com AlertDialog.Builder builder; switch (id) { case DIALOG_SHORT_WAIT: { ProgressDialog working_dialog = new ProgressDialog(this); working_dialog.setMessage(getResources().getString(R.string.wait_a_moment)); working_dialog.setIndeterminate(true); working_dialog.setCancelable(false); dialog = working_dialog; break; } case DIALOG_CHOOSE_UPLOAD_SOURCE: { String[] items = null; String[] allTheItems = { getString(R.string.actionbar_upload_files), getString(R.string.actionbar_upload_from_apps), getString(R.string.actionbar_failed_instant_upload) }; String[] commonItems = { getString(R.string.actionbar_upload_files), getString(R.string.actionbar_upload_from_apps) }; if (InstantUploadActivity.IS_ENABLED) items = allTheItems; else items = commonItems; builder = new AlertDialog.Builder(this); builder.setTitle(R.string.actionbar_upload); builder.setItems(items, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int item) { if (item == 0) { // if (!mDualPane) { Intent action = new Intent(FileDisplayActivity.this, UploadFilesActivity.class); action.putExtra(UploadFilesActivity.EXTRA_ACCOUNT, FileDisplayActivity.this.getAccount()); startActivityForResult(action, ACTION_SELECT_MULTIPLE_FILES); // } else { // TODO create and handle new fragment // LocalFileListFragment // } } else if (item == 1) { Intent action = new Intent(Intent.ACTION_GET_CONTENT); action = action.setType("*/*").addCategory(Intent.CATEGORY_OPENABLE); startActivityForResult( Intent.createChooser(action, getString(R.string.upload_chooser_title)), ACTION_SELECT_CONTENT_FROM_APPS); } else if (item == 2 && InstantUploadActivity.IS_ENABLED) { Intent action = new Intent(FileDisplayActivity.this, InstantUploadActivity.class); action.putExtra(FileUploader.KEY_ACCOUNT, FileDisplayActivity.this.getAccount()); startActivity(action); } } }); dialog = builder.create(); break; } case DIALOG_SSL_VALIDATOR: { dialog = SslValidatorDialog.newInstance(this, mLastSslUntrustedServerResult, this); break; } case DIALOG_CERT_NOT_SAVED: { builder = new AlertDialog.Builder(this); builder.setMessage(getResources().getString(R.string.ssl_validator_not_saved)); builder.setCancelable(false); builder.setPositiveButton(R.string.common_ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); }; }); dialog = builder.create(); break; } default: dialog = null; } return dialog; }
From source file:org.sogrey.frame.utils.FileUtil.java
/** * app/* w w w .j a v a2 s .c o m*/ * * @param context * * @author Sogrey * @date 2015-11-27?1:56:55 */ public static void openFolder(Context context, String path) { // Intent intent = new Intent(Intent.ACTION_GET_CONTENT); // Uri uri = Uri.parse(path); // intent.setDataAndType(uri, "text/csv"); // try { // context.startActivity(Intent.createChooser(intent, "Open folder")); // } catch (Exception e) { // } // File root = new File(path); // Uri uri = Uri.fromFile(root); // Intent intent = new Intent(); // intent.setAction(android.content.Intent.ACTION_VIEW); // intent.setData(uri); // context.startActivity(intent); // Intent intent = new Intent(); // String videoPath = path;// // File file = new File(videoPath); // Uri uri = Uri.fromFile(file); // intent.setData(uri); // intent.setAction(android.content.Intent.ACTION_VIEW);// "com.xxx.xxx" // ??? // try { // context.startActivity(intent); // } catch (ActivityNotFoundException e) { // e.printStackTrace(); // } // Intent i = new Intent(Intent.ACTION_GET_CONTENT); // // i.setAction(android.content.Intent.ACTION_VIEW); // File file = new File(path); // i.setDataAndType(Uri.fromFile(file), "file/*"); // try { // context.startActivity(i); // } catch (Exception e) { // } // Intent intent = new Intent(); // File file = new File(path); // intent.setAction(android.content.Intent.ACTION_VIEW); // // intent.setData(Uri.fromFile(file)); // intent.setDataAndType(Uri.fromFile(file), "file/*"); // try { // context.startActivity(intent); // } catch (Exception e) { // } Intent intent = new Intent(Intent.ACTION_GET_CONTENT); // intent.setType("*/*"); intent.setType(ContactsContract.Contacts.CONTENT_ITEM_TYPE); File file = new File(path); intent.setData(Uri.fromFile(file)); // intent.setDataAndType(Uri.fromFile(file), "*/*"); intent.addCategory(Intent.CATEGORY_OPENABLE); try { context.startActivity(intent); } catch (ActivityNotFoundException ex) { ToastUtil.showToast(context, "?"); } }
From source file:com.android.gallery3d.filtershow.FilterShowActivity.java
public void pickImage() { Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); startActivityForResult(Intent.createChooser(intent, getString(R.string.select_image)), SELECT_PICTURE); }
From source file:org.appspot.apprtc.CallActivity.java
void handleIntent(Intent intent) { if (intent == null || intent.getAction() == null) { return;//w w w . j a v a 2 s . c o m } if (intent.hasExtra(WebsocketService.EXTRA_ADDRESS)) { mServer = intent.getStringExtra(WebsocketService.EXTRA_ADDRESS); } if (intent.getAction().equals(ACTION_SHARE_FILE)) { User user = (User) intent.getSerializableExtra(WebsocketService.EXTRA_USER); mFileRecipient = user.Id; Intent i; if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) { i = new Intent(); i.setAction(Intent.ACTION_GET_CONTENT); i.setType("*/*"); } else { i = new Intent(Intent.ACTION_OPEN_DOCUMENT); i.addCategory(Intent.CATEGORY_OPENABLE); i.addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION); i.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); i.setType("*/*"); } startActivityForResult(i, FILE_CODE); } else if (intent.getAction().equals(ACTION_HANG_UP)) { User user = (User) intent.getSerializableExtra(WebsocketService.EXTRA_USER); if (mAdditionalPeers.containsKey(user.Id)) { mAdditionalPeers.get(user.Id).getRemoteViews().setId(""); updateRemoteViewList(mAdditionalPeers.get(user.Id).getRemoteViews()); mAdditionalPeers.get(user.Id).close(); mAdditionalPeers.remove(user.Id); } else if (mPeerId.equals(user.Id)) { onCallHangUp(); } } else if (intent.getAction().equals(ACTION_TOGGLE_VIDEO)) { User user = (User) intent.getSerializableExtra(WebsocketService.EXTRA_USER); boolean enabled = intent.getBooleanExtra(CallActivity.EXTRA_VIDEO_CALL, true); if (mAdditionalPeers.containsKey(user.Id)) { mAdditionalPeers.get(user.Id).setVideoEnabled(enabled); } else if (mPeerId.equals(user.Id)) { onToggleVideo(); } } else if (intent.getAction().equals(ACTION_TOGGLE_MIC)) { User user = (User) intent.getSerializableExtra(WebsocketService.EXTRA_USER); boolean enabled = intent.getBooleanExtra(CallActivity.EXTRA_MIC_ENABLED, true); if (mAdditionalPeers.containsKey(user.Id)) { mAdditionalPeers.get(user.Id).setAudioEnabled(enabled); } else if (mPeerId.equals(user.Id)) { onToggleMic(); } } else if (intent.getAction().equals(ACTION_SEND_MESSAGE)) { User user = (User) intent.getSerializableExtra(WebsocketService.EXTRA_USER); String messageText = intent.getStringExtra(CallActivity.EXTRA_MESSAGE); if (mService != null) { SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); fmt.setTimeZone(TimeZone.getTimeZone("GMT")); String time = fmt.format(new Date()); mService.sendChatMessage(time, mService.getAccountName(), "Self", messageText, user.Id, mService.getCurrentRoomName()); } } else if (intent.getAction().equals(ACTION_NEW_CALL)) { String signaling = intent.getStringExtra(EXTRA_SIGNALING); if (signaling != null) { mSignaling = signaling; } if (mSignaling.equals("xmpp")) { mOwnJid = intent.getStringExtra(BroadcastTypes.EXTRA_ACCOUNT_JID); mPeerId = intent.getStringExtra(BroadcastTypes.EXTRA_JID); mPeerName = mPeerId; initiator = true; signalingParameters = new SignalingParameters(WebsocketService.getIceServers(), initiator, "", "", "", null, null); } else { User user = (User) intent.getSerializableExtra(WebsocketService.EXTRA_USER); if (intent.hasExtra(WebsocketService.EXTRA_USERACTION)) { if (mConferenceId == null) { SessionIdentifierGenerator gen = new SessionIdentifierGenerator(); mConferenceId = mOwnId + "_" + gen.nextSessionId(); } } if (mPeerId.length() == 0) { callUser(user); } else if (!mPeerId.equals(user.Id)) { // don't call if already in call AdditionalPeerConnection additionalPeerConnection = new AdditionalPeerConnection(this, this, this, true, user.Id, WebsocketService.getIceServers(), peerConnectionParameters, rootEglBase, localRender, getRemoteRenderScreen(user.Id, user.displayName, getUrl(user.buddyPicture)), peerConnectionClient.getMediaStream(), "", peerConnectionClient.getPeerConnectionFactory()); mAdditionalPeers.put(user.Id, additionalPeerConnection); updateVideoView(); } } } else if (intent.getAction().equals(WebsocketService.ACTION_ADD_ALL_CONFERENCE)) { ArrayList<User> users = getUsers(); for (User user : users) { boolean added = false; if (!mPeerId.equals(user.Id) && !mAdditionalPeers.containsKey(user.Id) && (mOwnId.compareTo(user.Id) < 0)) { AdditionalPeerConnection additionalPeerConnection = new AdditionalPeerConnection(this, this, this, true, user.Id, WebsocketService.getIceServers(), peerConnectionParameters, rootEglBase, localRender, getRemoteRenderScreen(user.Id, user.displayName, getUrl(user.buddyPicture)), peerConnectionClient.getMediaStream(), mConferenceId, peerConnectionClient.getPeerConnectionFactory()); mAdditionalPeers.put(user.Id, additionalPeerConnection); updateVideoView(); added = true; } } if (mConferenceId == null) { SessionIdentifierGenerator gen = new SessionIdentifierGenerator(); mConferenceId = mOwnId + "_" + gen.nextSessionId(); } } else if (intent.getAction().equals(WebsocketService.ACTION_ADD_CONFERENCE_USER)) { User user = (User) intent.getSerializableExtra(WebsocketService.EXTRA_USER); String conferenceId = intent.getStringExtra(WebsocketService.EXTRA_CONFERENCE_ID); mOwnId = intent.getStringExtra(WebsocketService.EXTRA_OWN_ID); String userId = intent.getStringExtra(WebsocketService.EXTRA_ID); if (mConferenceId == null) { mConferenceId = conferenceId; } boolean added = false; if ((!mPeerId.equals(userId) && !mAdditionalPeers.containsKey(userId) && (mOwnId.compareTo(userId) < 0))) { if (user != null) { Log.d(TAG, "Calling conference: " + user.displayName); } if (peerConnectionClient.getMediaStream() != null) { String displayName = getString(R.string.unknown); String imgUrl = ""; if (user != null) { displayName = user.displayName; imgUrl = getUrl(user.buddyPicture); } AdditionalPeerConnection additionalPeerConnection = new AdditionalPeerConnection(this, this, this, true, userId, WebsocketService.getIceServers(), peerConnectionParameters, rootEglBase, localRender, getRemoteRenderScreen(userId, displayName, imgUrl), peerConnectionClient.getMediaStream(), mConferenceId, peerConnectionClient.getPeerConnectionFactory()); mAdditionalPeers.put(userId, additionalPeerConnection); updateVideoView(); added = true; } else if (mPeerId.length() == 0) { // show the call as incoming String displayName = getString(R.string.unknown); String imgUrl = ""; if (user != null) { displayName = user.displayName; imgUrl = getUrl(user.buddyPicture); } mPeerId = userId; mPeerName = displayName; ThumbnailsCacheManager.LoadImage(imgUrl, remoteUserImage, displayName, true, true); initiator = true; signalingParameters = new SignalingParameters(WebsocketService.getIceServers(), initiator, "", "", "", null, null); } else { mQueuedPeers.add(user); } } } else if (intent.getAction().equals(WebsocketService.ACTION_REMOTE_ICE_CANDIDATE)) { SerializableIceCandidate candidate = (SerializableIceCandidate) intent .getParcelableExtra(WebsocketService.EXTRA_CANDIDATE); String id = intent.getStringExtra(WebsocketService.EXTRA_ID); String token = intent.getStringExtra(WebsocketService.EXTRA_TOKEN); if (token != null && token.length() != 0) { if (mTokenPeers.containsKey(candidate.from)) { IceCandidate ic = new IceCandidate(candidate.sdpMid, candidate.sdpMLineIndex, candidate.sdp); mTokenPeers.get(candidate.from).addRemoteIceCandidate(ic); } } else if (mAdditionalPeers.containsKey(candidate.from)) { IceCandidate ic = new IceCandidate(candidate.sdpMid, candidate.sdpMLineIndex, candidate.sdp); mAdditionalPeers.get(candidate.from).addRemoteIceCandidate(ic); } else if (id.equals(mSdpId)) { onRemoteIceCandidate(candidate, id, candidate.from); } } else if (intent.getAction().equals(WebsocketService.ACTION_REMOTE_DESCRIPTION)) { SerializableSessionDescription sdp = (SerializableSessionDescription) intent .getSerializableExtra(WebsocketService.EXTRA_REMOTE_DESCRIPTION); String token = intent.getStringExtra(WebsocketService.EXTRA_TOKEN); String id = intent.getStringExtra(WebsocketService.EXTRA_ID); String conferenceId = intent.getStringExtra(WebsocketService.EXTRA_CONFERENCE_ID); String signaling = intent.getStringExtra(EXTRA_SIGNALING); String ownJid = intent.getStringExtra(BroadcastTypes.EXTRA_ACCOUNT_JID); mSid = intent.getStringExtra(BroadcastTypes.EXTRA_SID); User user = (User) intent.getSerializableExtra(WebsocketService.EXTRA_USER); if (mConferenceId == null && conferenceId != null && conferenceId.length() != 0) { mConferenceId = conferenceId; } /*else if (conferenceId != null && mConferenceId != null && !mConferenceId.equals(conferenceId)) { // already in a conference, reject the invite return; }*/ if (ownJid != null) { mOwnJid = ownJid; } if (signaling != null && signaling.equals("xmpp")) { mSignaling = signaling; } if (token != null && token.length() != 0) { if (mTokenPeers.containsKey(sdp.from)) { mTokenPeers.get(sdp.from) .setRemoteDescription(new SessionDescription(sdp.type, sdp.description)); } } else if (mPeerId.length() == 0 || mPeerId.equals(sdp.from)) { mSdpId = id; mPeerId = sdp.from; String imgUrl = ""; if (user != null) { mPeerName = user.displayName; imgUrl = getUrl(user.buddyPicture); } else { mPeerName = getString(R.string.unknown); } ThumbnailsCacheManager.LoadImage(imgUrl, remoteUserImage, mPeerName, true, true); if (peerConnectionClient.isConnected()) { onRemoteDescription(sdp, token, id, conferenceId, "", "", ""); } else { mRemoteSdp = sdp; mToken = token; } } else { if (mAdditionalPeers.containsKey(sdp.from)) { mAdditionalPeers.get(sdp.from) .setRemoteDescription(new SessionDescription(sdp.type, sdp.description)); } else { if (iceConnected && peerConnectionClient.getMediaStream() != null) { addToCall(sdp, user); } else { mQueuedRemoteConnections.add(new RemoteConnection(sdp, user)); } } } } }
From source file:com.fvd.nimbus.PaintActivity.java
void setCustomBackground(DrawView v) { Intent fileChooserIntent = new Intent(); fileChooserIntent.addCategory(Intent.CATEGORY_OPENABLE); fileChooserIntent.setType("image/*"); fileChooserIntent.setAction(Intent.ACTION_GET_CONTENT); startActivityForResult(Intent.createChooser(fileChooserIntent, "Select Picture"), 1); //overridePendingTransition( R.anim.slide_in_up, R.anim.slide_out_up ); overridePendingTransition(R.anim.carbon_slide_in, R.anim.carbon_slide_out); }
From source file:com.fvd.nimbus.PaintActivity.java
public void getPicture() { try {/* www.j a v a2 s . c o m*/ showProgress(true); Intent fileChooserIntent = new Intent(); fileChooserIntent.addCategory(Intent.CATEGORY_OPENABLE); fileChooserIntent.setType("image/*"); fileChooserIntent.setAction(Intent.ACTION_GET_CONTENT); startActivityForResult(Intent.createChooser(fileChooserIntent, "Select Picture"), TAKE_PICTURE); } catch (Exception e) { appSettings.appendLog("main:onClick " + e.getMessage()); showProgress(false); } }
From source file:com.apptentive.android.sdk.module.messagecenter.view.MessageCenterActivityContent.java
@Override public void onAttachImage() { try {/* w w w. ja va 2s . com*/ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {//prior Api level 19 Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); Intent chooserIntent = Intent.createChooser(intent, null); viewActivity.startActivityForResult(chooserIntent, Constants.REQUEST_CODE_PHOTO_FROM_SYSTEM_PICKER); } else { Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT); intent.addCategory(Intent.CATEGORY_OPENABLE); intent.setType("image/*"); Intent chooserIntent = Intent.createChooser(intent, null); viewActivity.startActivityForResult(chooserIntent, Constants.REQUEST_CODE_PHOTO_FROM_SYSTEM_PICKER); } imagePickerLaunched = true; } catch (Exception e) { e.printStackTrace(); imagePickerLaunched = false; Log.d("can't launch image picker"); } }
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 w w w .j ava 2s .c o 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.fsck.k9.activity.Accounts.java
private void onImport() { Intent i = new Intent(Intent.ACTION_GET_CONTENT); i.addCategory(Intent.CATEGORY_OPENABLE); i.setType("*/*"); PackageManager packageManager = getPackageManager(); List<ResolveInfo> infos = packageManager.queryIntentActivities(i, 0); if (infos.size() > 0) { startActivityForResult(Intent.createChooser(i, null), ACTIVITY_REQUEST_PICK_SETTINGS_FILE); } else {/* w w w. ja v a2 s . c o m*/ showDialog(DIALOG_NO_FILE_MANAGER); } }