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:com.material.katha.wifidirectmp3.DeviceDetailFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { filelist();// w ww. ja va 2 s . com FileInputStream inputStream = null; try { inputStream = getActivity().openFileInput("myfile"); } catch (FileNotFoundException e) { e.printStackTrace(); } InputStreamReader inputStreamReader = new InputStreamReader(inputStream); mContentView = inflater.inflate(R.layout.device_detail, null); Log.d("katha", "2"); mContentView.findViewById(R.id.btn_connect).setOnClickListener(new View.OnClickListener() { // @Override public void onClick(View v) { s_count = 0; c_count = 0; WifiP2pConfig config = new WifiP2pConfig(); config.deviceAddress = device.deviceAddress; config.wps.setup = WpsInfo.PBC; if (progressDialog != null && progressDialog.isShowing()) { progressDialog.dismiss(); } progressDialog = ProgressDialog.show(getActivity(), "Press back to cancel", "Connecting to :" + device.deviceName, true, true); // // new DialogInterface.OnCancelListener() { // // @Override // public void onCancel(DialogInterface dialog) { // ((DeviceActionListener) getActivity()).cancelDisconnect(); // } // } devicename = device.deviceName; Toast.makeText(getActivity(), devicename, Toast.LENGTH_LONG).show(); ((DeviceListFragment.DeviceActionListener) getActivity()).connect(config); } }); mContentView.findViewById(R.id.btn_disconnect).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ((DeviceListFragment.DeviceActionListener) getActivity()).disconnect(); s_count = 0; c_count = 0; DeviceListFragment.state = "avail"; } }); mContentView.findViewById(R.id.btn_resume).setClickable(false); mContentView.findViewById(R.id.btn_resume).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (pause % 2 == 0) { pause++; Toast.makeText(getActivity(), "Paused !!!", Toast.LENGTH_SHORT).show(); Button b = (Button) v.findViewById(R.id.btn_resume); b.setClickable(false); b.setVisibility(View.GONE); b.setText("Resume"); } else { pause++; pd.show(); Toast.makeText(getActivity(), "Resumed !!!", Toast.LENGTH_SHORT).show(); Button b = (Button) v.findViewById(R.id.btn_resume); b.setClickable(false); b.setVisibility(View.GONE); b.setText("Resume"); } } }); mContentView.findViewById(R.id.btn_start_client).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // // Allow user to pick an image from Gallery or other // // registered apps // ///////////////////////////////// // ContentResolver cr = getActivity().getContentResolver(); // InputStream is = null; // int fsize = 0; //// try { //// is=cr.openInputStream(Uri.parse(new File("/data/data/com.material.katha.wifidirectmp3/app_Shared/Screenshot_2016-04-11-08-25-12.png").toString())); //// // is = cr.openInputStream(uri); //// fsize = is.available(); //// //// // Log.d(WiFiDirectActivity.TAG,"File size is:"+is.available()+" "+f.getName()+"uri "+uri + "f "+ f+ "file name " +f.getName()); //// } catch (FileNotFoundException e) { //// e.printStackTrace(); //// } catch (IOException e) { //// e.printStackTrace(); //// } // // //Log.d("katha", fileext + "fileext"); // //;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;change fileext = abc.substring(abc.lastIndexOf('.')); // // /*progressDialog = new ProgressDialog(getActivity()); // progressDialog.setMessage("Sending file:"+abc); // progressDialog.show(); // */ // // // progressDialog = ProgressDialog.show(getActivity(), "Sending","Copying file :" + fileext, true, true); // // makeText(getActivity(), fileext, LENGTH_LONG).show(); // TextView statusText = (TextView) mContentView.findViewById(R.id.status_text); // // statusText.setText("Sending: " + uri); // // String devicename = "abc"; // devicename = device.deviceName; // // Toast.makeText(getActivity(),devicename,Toast.LENGTH_LONG).show(); // // // Log.d("WiFiDirectActivity", "Intent----------- " + Uri.parse(new File("DCIM/Camera/IMG_20160118_090231.jpg").toString())); // Intent serviceIntent = new Intent(getActivity(), FileTransferService.class); // serviceIntent.setAction(FileTransferService.ACTION_SEND_FILE); // //Log.d("WiFiDirectActivity", "Action" + FileTransferService.ACTION_SEND_FILE + "\n\n\n\n"); // ////////////////////serviceIntent.putExtra(FileTransferService.EXTRAS_FILE_PATH, uri.toString()); // //serviceIntent.putExtra(FileTransferService.EXTRAS_FILE_PATH,"DCIM/Camera/IMG_20160118_090231.jpg"); // // //serviceIntent.putExtra(FileTransferService.FILE_SIZE, fsize); // // serviceIntent.putExtra(FileTransferService.device_name,devicename); // serviceIntent.putExtra(FileTransferService.EXTRAS_GROUP_OWNER_PORT, 8988); // String localip = getDottedDecimalIP(getLocalIPAddress()); // Log.d("WiFiDirectActivity", "DEVICE_NAME: " + devicename); // serviceIntent.putExtra(FileTransferService.DEVICE_NAME, devicename); // // if (localip.equals("192.168.49.1")) { // Log.d("WiFiDirectActivity", "Flag is 0."); // // devicename = device.deviceName; // serviceIntent.putExtra(FileTransferService.EXTRAS_GROUP_OWNER_ADDRESS, client_ip); // serviceIntent.putExtra(FileTransferService.Client_add, client_ip); // ; // } else { // Log.d("WiFiDirectActivity", "Flag is 1."); // //devicename = device.deviceName; // // Toast.makeText(getActivity(),devicename,Toast.LENGTH_LONG).show(); // serviceIntent.putExtra(FileTransferService.EXTRAS_GROUP_OWNER_ADDRESS, // info.groupOwnerAddress.getHostAddress()); // serviceIntent.putExtra(FileTransferService.Client_add, localip); // // } // getActivity().startService(serviceIntent); // Log.d("WiFiDirectActivity","here"); ////////////////////////////////// if (!info.groupOwnerAddress.getHostAddress().equals("")) { Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType("*/*"); startActivityForResult(intent, CHOOSE_FILE_RESULT_CODE); } } }); return mContentView; }
From source file:mgks.os.webview.MainActivity.java
@SuppressLint({ "SetJavaScriptEnabled", "WrongViewCast" }) @Override/*from ww w . j a v a 2 s. c om*/ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Log.w("READ_PERM = ", Manifest.permission.READ_EXTERNAL_STORAGE); Log.w("WRITE_PERM = ", Manifest.permission.WRITE_EXTERNAL_STORAGE); //Prevent the app from being started again when it is still alive in the background if (!isTaskRoot()) { finish(); return; } setContentView(R.layout.activity_main); asw_view = findViewById(R.id.msw_view); final SwipeRefreshLayout pullfresh = findViewById(R.id.pullfresh); if (ASWP_PULLFRESH) { pullfresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { pull_fresh(); pullfresh.setRefreshing(false); } }); asw_view.getViewTreeObserver() .addOnScrollChangedListener(new ViewTreeObserver.OnScrollChangedListener() { @Override public void onScrollChanged() { if (asw_view.getScrollY() == 0) { pullfresh.setEnabled(true); } else { pullfresh.setEnabled(false); } } }); } else { pullfresh.setRefreshing(false); pullfresh.setEnabled(false); } if (ASWP_PBAR) { asw_progress = findViewById(R.id.msw_progress); } else { findViewById(R.id.msw_progress).setVisibility(View.GONE); } asw_loading_text = findViewById(R.id.msw_loading_text); Handler handler = new Handler(); //Launching app rating request if (ASWP_RATINGS) { handler.postDelayed(new Runnable() { public void run() { get_rating(); } }, 1000 * 60); //running request after few moments } //Getting basic device information get_info(); //Getting GPS location of device if given permission if (ASWP_LOCATION && !check_permission(1)) { ActivityCompat.requestPermissions(MainActivity.this, new String[] { Manifest.permission.ACCESS_FINE_LOCATION }, loc_perm); } get_location(); //Webview settings; defaults are customized for best performance WebSettings webSettings = asw_view.getSettings(); if (!ASWP_OFFLINE) { webSettings.setJavaScriptEnabled(ASWP_JSCRIPT); } webSettings.setSaveFormData(ASWP_SFORM); webSettings.setSupportZoom(ASWP_ZOOM); webSettings.setGeolocationEnabled(ASWP_LOCATION); webSettings.setAllowFileAccess(true); webSettings.setAllowFileAccessFromFileURLs(true); webSettings.setAllowUniversalAccessFromFileURLs(true); webSettings.setUseWideViewPort(true); webSettings.setDomStorageEnabled(true); asw_view.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { return true; } }); asw_view.setHapticFeedbackEnabled(false); asw_view.setDownloadListener(new DownloadListener() { @Override public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimeType, long contentLength) { if (!check_permission(2)) { ActivityCompat.requestPermissions(MainActivity.this, new String[] { Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.READ_EXTERNAL_STORAGE }, file_perm); } else { DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url)); request.setMimeType(mimeType); String cookies = CookieManager.getInstance().getCookie(url); request.addRequestHeader("cookie", cookies); request.addRequestHeader("User-Agent", userAgent); request.setDescription(getString(R.string.dl_downloading)); request.setTitle(URLUtil.guessFileName(url, contentDisposition, mimeType)); request.allowScanningByMediaScanner(); request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED); request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, URLUtil.guessFileName(url, contentDisposition, mimeType)); DownloadManager dm = (DownloadManager) getSystemService(DOWNLOAD_SERVICE); assert dm != null; dm.enqueue(request); Toast.makeText(getApplicationContext(), getString(R.string.dl_downloading2), Toast.LENGTH_LONG) .show(); } } }); if (Build.VERSION.SDK_INT >= 21) { getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); getWindow().setStatusBarColor(getResources().getColor(R.color.colorPrimaryDark)); asw_view.setLayerType(View.LAYER_TYPE_HARDWARE, null); webSettings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW); } else if (Build.VERSION.SDK_INT >= 19) { asw_view.setLayerType(View.LAYER_TYPE_HARDWARE, null); } asw_view.setVerticalScrollBarEnabled(false); asw_view.setWebViewClient(new Callback()); //Rendering the default URL aswm_view(ASWV_URL, false); asw_view.setWebChromeClient(new WebChromeClient() { //Handling input[type="file"] requests for android API 16+ public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType, String capture) { if (ASWP_FUPLOAD) { asw_file_message = uploadMsg; Intent i = new Intent(Intent.ACTION_GET_CONTENT); i.addCategory(Intent.CATEGORY_OPENABLE); i.setType(ASWV_F_TYPE); if (ASWP_MULFILE) { i.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true); } startActivityForResult(Intent.createChooser(i, getString(R.string.fl_chooser)), asw_file_req); } } //Handling input[type="file"] requests for android API 21+ public boolean onShowFileChooser(WebView webView, ValueCallback<Uri[]> filePathCallback, FileChooserParams fileChooserParams) { if (check_permission(2) && check_permission(3)) { if (ASWP_FUPLOAD) { if (asw_file_path != null) { asw_file_path.onReceiveValue(null); } asw_file_path = filePathCallback; Intent takePictureIntent = null; if (ASWP_CAMUPLOAD) { takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); if (takePictureIntent.resolveActivity(MainActivity.this.getPackageManager()) != null) { File photoFile = null; try { photoFile = create_image(); takePictureIntent.putExtra("PhotoPath", asw_cam_message); } catch (IOException ex) { Log.e(TAG, "Image file creation failed", ex); } if (photoFile != null) { asw_cam_message = "file:" + photoFile.getAbsolutePath(); takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photoFile)); } else { takePictureIntent = null; } } } Intent contentSelectionIntent = new Intent(Intent.ACTION_GET_CONTENT); if (!ASWP_ONLYCAM) { contentSelectionIntent.addCategory(Intent.CATEGORY_OPENABLE); contentSelectionIntent.setType(ASWV_F_TYPE); if (ASWP_MULFILE) { contentSelectionIntent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true); } } 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, getString(R.string.fl_chooser)); chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, intentArray); startActivityForResult(chooserIntent, asw_file_req); } return true; } else { get_file(); return false; } } //Getting webview rendering progress @Override public void onProgressChanged(WebView view, int p) { if (ASWP_PBAR) { asw_progress.setProgress(p); if (p == 100) { asw_progress.setProgress(0); } } } // overload the geoLocations permissions prompt to always allow instantly as app permission was granted previously public void onGeolocationPermissionsShowPrompt(String origin, GeolocationPermissions.Callback callback) { if (Build.VERSION.SDK_INT < 23 || check_permission(1)) { // location permissions were granted previously so auto-approve callback.invoke(origin, true, false); } else { // location permissions not granted so request them ActivityCompat.requestPermissions(MainActivity.this, new String[] { Manifest.permission.ACCESS_FINE_LOCATION }, loc_perm); } } }); if (getIntent().getData() != null) { String path = getIntent().getDataString(); /* If you want to check or use specific directories or schemes or hosts Uri data = getIntent().getData(); String scheme = data.getScheme(); String host = data.getHost(); List<String> pr = data.getPathSegments(); String param1 = pr.get(0); */ aswm_view(path, false); } }
From source file:org.thezero.qrfi.SuperAwesomeCardFragment.java
public void selectFromGallery() { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) { Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); startActivityForResult(intent, GALLERY_INTENT_CALLED); } else {/*from w w w . j av a 2s.c om*/ Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.addCategory(Intent.CATEGORY_OPENABLE); intent.setType("image/*"); startActivityForResult(intent, GALLERY_KITKAT_INTENT_CALLED); } }
From source file:com.app.sample.chatting.activity.chat.ChatActivity.java
/** * ?/*from www. j a v a 2 s. co m*/ */ private void goToAlbum() { Intent intent; if (Build.VERSION.SDK_INT < 19) { intent = new Intent(); intent.setAction(Intent.ACTION_GET_CONTENT); intent.setType("image/*"); startActivityForResult(Intent.createChooser(intent, ""), REQUEST_CODE_GETIMAGE_BYSDCARD); } else { intent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI); intent.setType("image/*"); startActivityForResult(Intent.createChooser(intent, ""), REQUEST_CODE_GETIMAGE_BYSDCARD); } }
From source file:org.mdc.chess.MDChess.java
private static boolean hasFenProvider(PackageManager manager) { Intent i = new Intent(Intent.ACTION_GET_CONTENT); i.setType("application/x-chess-fen"); List<ResolveInfo> resolvers = manager.queryIntentActivities(i, 0); return (resolvers != null) && (resolvers.size() > 0); }
From source file:org.csploit.android.plugins.LoginCracker.java
public void onCreate(Bundle savedInstanceState) { SharedPreferences themePrefs = getSharedPreferences("THEME", 0); Boolean isDark = themePrefs.getBoolean("isDark", false); if (isDark)//ww w . j a v a 2 s . c o m setTheme(R.style.DarkTheme); else setTheme(R.style.AppTheme); super.onCreate(savedInstanceState); if (!System.getCurrentTarget().hasOpenPorts()) new FinishDialog(getString(R.string.warning), getString(R.string.no_open_ports), this).show(); final ArrayList<String> ports = new ArrayList<String>(); for (Port port : System.getCurrentTarget().getOpenPorts()) ports.add(Integer.toString(port.getNumber())); mProtocolAdapter = new ProtocolAdapter(); mPortSpinner = (Spinner) findViewById(R.id.portSpinner); mPortSpinner.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, ports)); mPortSpinner.setOnItemSelectedListener(new OnItemSelectedListener() { public void onItemSelected(AdapterView<?> adapter, View view, int position, long id) { String port = (String) adapter.getItemAtPosition(position); int protocolIndex = mProtocolAdapter.getIndexByPort(port); if (protocolIndex != -1) mProtocolSpinner.setSelection(protocolIndex); } public void onNothingSelected(AdapterView<?> arg0) { } }); mProtocolSpinner = (Spinner) findViewById(R.id.protocolSpinner); mProtocolSpinner.setAdapter(new ProtocolAdapter()); mProtocolSpinner.setOnItemSelectedListener(new OnItemSelectedListener() { public void onItemSelected(AdapterView<?> adapter, View view, int position, long id) { int portIndex = mProtocolAdapter.getPortIndexByProtocol(position); if (portIndex != -1) mPortSpinner.setSelection(portIndex); } public void onNothingSelected(AdapterView<?> arg0) { } }); mCharsetSpinner = (Spinner) findViewById(R.id.charsetSpinner); mCharsetSpinner.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, CHARSETS)); mCharsetSpinner.setOnItemSelectedListener(new OnItemSelectedListener() { public void onItemSelected(AdapterView<?> adapter, View view, int position, long id) { if (CHARSETS_MAPPING[position] == null) { new InputDialog(getString(R.string.custom_charset), getString(R.string.enter_chars_wanted), LoginCracker.this, new InputDialogListener() { @Override public void onInputEntered(String input) { input = input.trim(); if (!input.isEmpty()) mCustomCharset = "aA1" + input; else { mCustomCharset = null; mCharsetSpinner.setSelection(0); } } }).show(); } else mCustomCharset = null; } public void onNothingSelected(AdapterView<?> arg0) { } }); mUserSpinner = (Spinner) findViewById(R.id.userSpinner); mUserSpinner.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, USERNAMES)); mUserSpinner.setOnItemSelectedListener(new OnItemSelectedListener() { public void onItemSelected(AdapterView<?> adapter, View view, int position, long id) { String user = (String) adapter.getItemAtPosition(position); if (user != null && user.equals("-- ADD --")) { new InputDialog(getString(R.string.add_username), getString(R.string.enter_username), LoginCracker.this, new InputDialogListener() { @Override public void onInputEntered(String input) { USERNAMES = Arrays.copyOf(USERNAMES, USERNAMES.length + 1); USERNAMES[USERNAMES.length - 1] = "-- ADD --"; USERNAMES[USERNAMES.length - 2] = input; mUserSpinner.setAdapter(new ArrayAdapter<String>(LoginCracker.this, android.R.layout.simple_spinner_item, USERNAMES)); mUserSpinner.setSelection(USERNAMES.length - 2); } }).show(); } } public void onNothingSelected(AdapterView<?> arg0) { } }); mMaxSpinner = (Spinner) findViewById(R.id.maxSpinner); mMaxSpinner.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, LENGTHS)); mMinSpinner = (Spinner) findViewById(R.id.minSpinner); mMinSpinner.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, LENGTHS)); mStartButton = (FloatingActionButton) findViewById(R.id.startFAB); mStatusText = (TextView) findViewById(R.id.statusText); mProgressBar = (ProgressBar) findViewById(R.id.progressBar); mActivity = (ProgressBar) findViewById(R.id.activity); mProgressBar.setMax(100); mReceiver = new AttemptReceiver(); mStartButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (mRunning) { setStoppedState(); } else { setStartedState(); } } }); mWordlistPicker = new Intent(); mWordlistPicker.addCategory(Intent.CATEGORY_OPENABLE); mWordlistPicker.setType("text/*"); mWordlistPicker.setAction(Intent.ACTION_GET_CONTENT); if (Build.VERSION.SDK_INT >= 11) mWordlistPicker.putExtra(Intent.EXTRA_LOCAL_ONLY, true); }
From source file:com.cordova.photo.CameraLauncher.java
/** * Get image from photo library.//w w w.j a v a 2 s . c om * * @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. * @param encodingType */ // TODO: Images selected from SDCARD don't display correctly, but from CAMERA ALBUM do! // TODO: Images from kitkat filechooser not going into crop function public void getImage(int srcType, int returnType, int encodingType) { Intent intent = new Intent(); String title = GET_PICTURE; croppedUri = null; if (this.mediaType == PICTURE) { intent.setType("image/*"); if (this.allowEdit) { intent.setAction(Intent.ACTION_PICK); intent.putExtra("crop", "true"); if (targetWidth > 0) { intent.putExtra("outputX", targetWidth); } if (targetHeight > 0) { intent.putExtra("outputY", targetHeight); } if (targetHeight > 0 && targetWidth > 0 && targetWidth == targetHeight) { intent.putExtra("aspectX", 1); intent.putExtra("aspectY", 1); } File photo = createCaptureFile(encodingType); croppedUri = Uri.fromFile(photo); intent.putExtra(MediaStore.EXTRA_OUTPUT, croppedUri); } else { intent.setAction(Intent.ACTION_GET_CONTENT); intent.addCategory(Intent.CATEGORY_OPENABLE); } } else if (this.mediaType == VIDEO) { intent.setType("video/*"); title = GET_VIDEO; intent.setAction(Intent.ACTION_GET_CONTENT); intent.addCategory(Intent.CATEGORY_OPENABLE); } 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); } if (this.activity != null) { this.activity.startActivityForResult(Intent.createChooser(intent, new String(title)), (srcType + 1) * 16 + returnType + 1); } }
From source file:org.linphone.ContactEditorFragment.java
private void pickImage() { imageToUploadUri = null;//from w w w . ja v a2s .c o m final List<Intent> cameraIntents = new ArrayList<Intent>(); final Intent captureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); File file = new File(Environment.getExternalStorageDirectory(), getString(R.string.temp_photo_name)); imageToUploadUri = Uri.fromFile(file); captureIntent.putExtra("crop", "true"); captureIntent.putExtra("outputX", 256); captureIntent.putExtra("outputY", 256); captureIntent.putExtra("aspectX", 0); captureIntent.putExtra("aspectY", 0); captureIntent.putExtra("scale", true); captureIntent.putExtra("return-data", false); captureIntent.putExtra(MediaStore.EXTRA_OUTPUT, imageToUploadUri); cameraIntents.add(captureIntent); final Intent galleryIntent = new Intent(); galleryIntent.setType("image/*"); galleryIntent.setAction(Intent.ACTION_GET_CONTENT); final Intent chooserIntent = Intent.createChooser(galleryIntent, getString(R.string.image_picker_title)); chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, cameraIntents.toArray(new Parcelable[] {})); startActivityForResult(chooserIntent, ADD_PHOTO); }
From source file:com.raspi.chatapp.ui.chatting.ChatActivity.java
public void sendLibraryImage(View view) { // hide the popup View v = findViewById(R.id.popup_layout); if (v != null) { v.setVisibility(View.GONE); attachPopup = false;//from w ww .j a v a 2 s . c o m } // when clicking attack the user should at first select an application to // choose the image with and then choose an image. // this intent is for getting the image Intent getIntent = new Intent(Intent.ACTION_GET_CONTENT); getIntent.setType("image/*"); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) getIntent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true); // and this for getting the application to get the image with Intent pickIntent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI); pickIntent.setType("image/*"); // and this finally is for opening the chooserIntent for opening the // getIntent for returning the image uri. Yep, thanks android Intent chooserIntent = Intent.createChooser(getIntent, getResources().getString(R.string.select_image)); chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, new Intent[] { pickIntent }); startActivityForResult(chooserIntent, SEND_LIBRARY_IMAGE_REQUEST_CODE); // nope I don't want to be asked for a pwd when selected the image getSharedPreferences(Constants.PREFERENCES, 0).edit().putBoolean(Constants.PWD_REQUEST, false).apply(); }
From source file:org.apache.cordova.AndroidChromeClient.java
public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType, String capture) { mUploadMessage = uploadMsg;//w ww.j a v a2 s . co m Intent i = new Intent(Intent.ACTION_GET_CONTENT); i.addCategory(Intent.CATEGORY_OPENABLE); i.setType("*/*"); this.cordova.getActivity().startActivityForResult(Intent.createChooser(i, "File Browser"), FILECHOOSER_RESULTCODE); }