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:org.appspot.apprtc.CallActivity.java
void handleIntent(Intent intent) { if (intent == null || intent.getAction() == null) { return;//from w w w .j a v a2 s. co 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 {//from w w w.j ava2s . 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 {//from w w w . j a v a 2 s .co m 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: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 {//from w ww .j a v a 2 s . co m showDialog(DIALOG_NO_FILE_MANAGER); } }
From source file:org.kiwix.kiwixmobile.KiwixMobileActivity.java
public void manageZimFiles(int tab) { refreshBookmarks();/*from w ww. ja v a 2s. c o m*/ final Intent target = new Intent(this, ZimManageActivity.class); target.setAction(Intent.ACTION_GET_CONTENT); // The MIME data type filter target.setType("//"); target.putExtra(ZimManageActivity.TAB_EXTRA, tab); // Only return URIs that can be opened with ContentResolver target.addCategory(Intent.CATEGORY_OPENABLE); // Force use of our file selection component. // (Note may make sense to just define a custom intent instead) startActivityForResult(target, REQUEST_FILE_SELECT); }
From source file:org.de.jmg.learn.MainActivity.java
@SuppressLint("InlinedApi") public void SaveVokAs(boolean blnUniCode, boolean blnNew) throws Exception { boolean blnActionCreateDocument = false; try {//ww w .j ava 2 s . 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.dish.browser.activity.BrowserActivity.java
@Override /**//from w ww . j a v a 2 s . c om * opens a file chooser * param ValueCallback is the message from the WebView indicating a file chooser * should be opened */ public void openFileChooser(ValueCallback<Uri> uploadMsg) { mUploadMessage = uploadMsg; Intent i = new Intent(Intent.ACTION_GET_CONTENT); i.addCategory(Intent.CATEGORY_OPENABLE); i.setType("*/*"); startActivityForResult(Intent.createChooser(i, getString(R.string.title_file_chooser)), 1); }
From source file:com.dish.browser.activity.BrowserActivity.java
@Override public void showFileChooser(ValueCallback<Uri[]> filePathCallback) { if (mFilePathCallback != null) { mFilePathCallback.onReceiveValue(null); }/*from www . j a v a 2 s . c o 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//ww w . j a va 2 s.co m * @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); }