List of usage examples for android.content Intent resolveActivity
public ComponentName resolveActivity(@NonNull PackageManager pm)
From source file:com.davidmascharka.lips.MainActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. switch (item.getItemId()) { case R.id.action_reset: resetDatafile();//from www .java 2 s .c o m break; case R.id.action_select_building: showSelectBuildingDialog(); break; case R.id.action_select_room_size: new SelectRoomSizeDialogFragment().show(getSupportFragmentManager(), "RoomSize"); break; case R.id.action_display_map: displayMap = !displayMap; item.setChecked(displayMap); ((GridView) findViewById(R.id.gridView)).setDisplayMap(displayMap); break; case R.id.action_select_map: // Launch an intent to select the map the user wants to display Intent selectMapIntent = new Intent(); selectMapIntent.setAction(Intent.ACTION_GET_CONTENT); selectMapIntent.setType("image/*"); selectMapIntent.addCategory(Intent.CATEGORY_OPENABLE); if (selectMapIntent.resolveActivity(getPackageManager()) != null) { startActivityForResult(selectMapIntent, GET_MAP_REQUEST); } break; case R.id.action_start_tracker: Intent intent = new Intent(this, TrackerActivity.class); startActivity(intent); break; default: super.onOptionsItemSelected(item); break; } return true; }
From source file:com.simadanesh.isatis.ScreenSlideActivity.java
void dispatchTakePictureIntentOrShowPicture() { ReadingListDetail detail = CommonPlace.currentReadingListDetails.get(mPager.getCurrentItem()); if (detail.PicturePath == null || detail.PicturePath.equals("")) { Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); // Ensure that there's a camera activity to handle the intent if (takePictureIntent.resolveActivity(this.getPackageManager()) != null) { // Create the File where the photo should go File photoFile = null; try { photoFile = createImageFile(); } catch (IOException ex) { ex.toString();//w w w .jav a2s.c o m // Error occurred while creating the File } // Continue only if the File was successfully created if (photoFile != null) { takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photoFile)); startActivityForResult(takePictureIntent, REQUEST_IMAGE_CAPTURE); } } } else { Intent intent = new Intent(); intent.setAction(android.content.Intent.ACTION_VIEW); //intent.setDataAndType(Uri.fromFile(file), "image/*"); intent.setDataAndType(Uri.fromFile(new File(detail.PicturePath)), "image/*"); startActivity(intent); } }
From source file:com.teeptrak.controller.MainActivity.java
private void openFileChooser(int aFileType) { final Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType(aFileType == FILE_TYPE_ZIP ? DfuService.MIME_TYPE_ZIP : MIME_TYPE_TEXT); //intent.setType(DfuService.MIME_TYPE_ZIP); intent.addCategory(Intent.CATEGORY_OPENABLE); if (intent.resolveActivity(getPackageManager()) != null) { // file browser has been found on the device startActivityForResult(intent, REQUEST_SELECT_FILE); }//from w w w .j a v a 2 s .c o m //else //{ // there is no any file browser app, let's try to download one // final View customView = getLayoutInflater().inflate(R.layout.app_file_browser, null); // final ListView appsList = (ListView) customView.findViewById(android.R.id.list); // appsList.setAdapter(new FileBrowserAppsAdapter(this)); // appsList.setChoiceMode(ListView.CHOICE_MODE_SINGLE); // appsList.setItemChecked(0, true); // new AlertDialog.Builder(this).setTitle(R.string.dfu_alert_no_filebrowser_title).setView(customView) // .setNegativeButton(R.string.no, new DialogInterface.OnClickListener() { // @Override // public void onClick(final DialogInterface dialog, final int which) { // dialog.dismiss(); // } // }).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { // @Override // public void onClick(final DialogInterface dialog, final int which) { // final int pos = appsList.getCheckedItemPosition(); // if (pos >= 0) { // final String query = getResources().getStringArray(R.array.dfu_app_file_browser_action)[pos]; // final Intent storeIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(query)); // startActivity(storeIntent); // } // } // }).show(); //} }
From source file:org.apache.cordova.camera.CameraLauncher.java
/** * Take a picture with the camera.//from ww w .j a v a2 s . co m * When an image is captured or the camera view is cancelled, the result is returned * in CordovaActivity.onActivityResult, which forwards the result to this.onActivityResult. * * The image can either be returned as a base64 string or a URI that points to the file. * To display base64 string in an img tag, set the source to: * img.src="data:image/jpeg;base64,"+result; * or to display URI in an img tag * img.src=result; * * @param quality Compression quality hint (0-100: 0=low quality & high compression, 100=compress of max quality) * @param returnType Set the type of image to return. */ public void takePicture(int returnType, int encodingType) { // Save the number of images currently on disk for later this.numPics = queryImgDB(whichContentStore()).getCount(); // Let's use the intent and see what happens Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); // Specify file so that large image is captured and returned File photo = createCaptureFile(encodingType); intent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, Uri.fromFile(photo)); this.imageUri = Uri.fromFile(photo); if (this.cordova != null) { // Let's check to make sure the camera is actually installed. (Legacy Nexus 7 code) PackageManager mPm = this.cordova.getActivity().getPackageManager(); if (intent.resolveActivity(mPm) != null) { this.cordova.startActivityForResult((CordovaPlugin) this, intent, (CAMERA + 1) * 16 + returnType + 1); } else { LOG.d(LOG_TAG, "Error: You don't have a default camera. Your device may not be CTS complaint."); } } // else // LOG.d(LOG_TAG, "ERROR: You must use the CordovaInterface for this to work correctly. Please implement it in your activity"); }
From source file:com.nextgis.ngm_clink_monitoring.fragments.CreateObjectFragment.java
protected void showCameraActivity(GISApplication app) { Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); // Ensure that there's a camera activity to handle the intent if (null != cameraIntent.resolveActivity(getActivity().getPackageManager())) { try {/* ww w. j ava2s .c om*/ String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.US).format(new Date()); File tempFile = new File(app.getDataDir(), FoclConstants.TEMP_PHOTO_FILE_PREFIX + timeStamp + ".jpg"); if (!tempFile.exists() && tempFile.createNewFile() || tempFile.exists() && tempFile.delete() && tempFile.createNewFile()) { mTempPhotoPath = tempFile.getAbsolutePath(); Log.d(TAG, "mTempPhotoPath: " + mTempPhotoPath); cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(tempFile)); startActivityForResult(cameraIntent, REQUEST_TAKE_PHOTO); } } catch (IOException e) { Toast.makeText(getActivity(), e.getLocalizedMessage(), Toast.LENGTH_LONG).show(); } } }
From source file:com.remobile.camera.CameraLauncher.java
/** * Take a picture with the camera.//from w ww . ja va 2 s. co m * When an image is captured or the camera view is cancelled, the result is returned * in CordovaActivity.onActivityResult, which forwards the result to this.onActivityResult. * <p/> * The image can either be returned as a base64 string or a URI that points to the file. * To display base64 string in an img tag, set the source to: * img.src="data:image/jpeg;base64,"+result; * or to display URI in an img tag * img.src=result; * * @param quality Compression quality hint (0-100: 0=low quality & high compression, 100=compress of max quality) * @param returnType Set the type of image to return. */ public void takePicture(int returnType, int encodingType) { // Save the number of images currently on disk for later this.numPics = queryImgDB(whichContentStore()).getCount(); // Let's use the intent and see what happens Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); // Specify file so that large image is captured and returned File photo = createCaptureFile(encodingType); intent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, Uri.fromFile(photo)); this.imageUri = Uri.fromFile(photo); if (this.cordova != null) { // Let's check to make sure the camera is actually installed. (Legacy Nexus 7 code) PackageManager mPm = this.cordova.getActivity().getPackageManager(); if (intent.resolveActivity(mPm) != null) { this.cordova.startActivityForResult((CordovaPlugin) this, intent, (CAMERA + 1) * 16 + returnType + 1); } else { FLog.d(LOG_TAG, "Error: You don't have a default camera. Your device may not be CTS complaint."); } } // else // FLog.d(LOG_TAG, "ERROR: You must use the CordovaInterface for this to work correctly. Please implement it in your activity"); }
From source file:com.segma.trim.MainActivity.java
private void photoFromCamera() { Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); // Ensure that there's a camera activity to handle the intent if (takePictureIntent.resolveActivity(getPackageManager()) != null) { // Create the File where the photo should go File photoFile = null;/* w ww .ja v a2 s .c om*/ try { photoFile = createImageFile(); } catch (IOException ex) { // Error occurred while creating the File Toast.makeText(getApplicationContext(), WARNING_CAMERA_IMPORT_ERROR, Toast.LENGTH_LONG).show(); } // Continue only if the File was successfully created if (photoFile != null) { takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photoFile)); startActivityForResult(takePictureIntent, REQUEST_CODE_CAMERA); } } }
From source file:dentex.youtube.downloader.ShareActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { super.onOptionsItemSelected(item); switch (item.getItemId()) { case R.id.menu_donate: startActivity(new Intent(this, DonateActivity.class)); return true; case R.id.menu_settings: startActivity(new Intent(this, SettingsActivity.class)); return true; case R.id.menu_about: startActivity(new Intent(this, AboutActivity.class)); return true; case R.id.menu_dm: Intent viewIntent = new Intent(android.app.DownloadManager.ACTION_VIEW_DOWNLOADS); if (viewIntent.resolveActivity(getPackageManager()) != null) { startActivity(viewIntent);//from w w w.j a v a 2 s .com } else { Toast.makeText(this, getString(R.string.no_downloads_sys_app), Toast.LENGTH_LONG).show(); } return true; case R.id.menu_tutorials: startActivity(new Intent(this, TutorialsActivity.class)); return true; default: return super.onOptionsItemSelected(item); } }
From source file:com.stfalcon.contentmanager.ContentManager.java
/** * Pick image or video content from storage or google acc * * @param content image or video// w ww .j a va 2s . co m */ public void pickContent(Content content) { savedTask = CONTENT_PICKER; savedContent = content; if (isStoragePermissionGranted(activity, fragment)) { this.targetFile = createFile(content); if (Build.VERSION.SDK_INT < 19) { Intent photoPickerIntent = new Intent(Intent.ACTION_PICK); photoPickerIntent.setType(content.toString()); if (fragment == null) { activity.startActivityForResult(photoPickerIntent, CONTENT_PICKER); } else { fragment.startActivityForResult(photoPickerIntent, CONTENT_PICKER); } } else { Intent photoPickerIntent = new Intent(Intent.ACTION_GET_CONTENT); photoPickerIntent.setType(content.toString()); photoPickerIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); photoPickerIntent.addCategory(Intent.CATEGORY_OPENABLE); if (photoPickerIntent.resolveActivity(activity.getPackageManager()) != null) { if (fragment == null) { activity.startActivityForResult(photoPickerIntent, CONTENT_PICKER); } else { fragment.startActivityForResult(photoPickerIntent, CONTENT_PICKER); } } } } }
From source file:com.becapps.easydownloader.ShareActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { super.onOptionsItemSelected(item); switch (item.getItemId()) { case R.id.menu_settings: startActivity(new Intent(this, SettingsActivity.class)); return true; case R.id.menu_dm: Intent viewIntent = new Intent(android.app.DownloadManager.ACTION_VIEW_DOWNLOADS); if (viewIntent.resolveActivity(getPackageManager()) != null) { startActivity(viewIntent);/*from w w w. ja v a 2 s. c o m*/ } else { Toast.makeText(this, getString(R.string.no_downloads_sys_app), Toast.LENGTH_LONG).show(); } return true; case R.id.menu_tutorials: startActivity(new Intent(this, TutorialsActivity.class)); return true; default: return super.onOptionsItemSelected(item); } }