List of usage examples for android.app Activity startActivityForResult
public void startActivityForResult(@RequiresPermission Intent intent, int requestCode)
From source file:Main.java
public static void getPhotoFromCamera(Activity context, int requestCode, Uri imageUri) { Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); intent.setAction(MediaStore.ACTION_IMAGE_CAPTURE); intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri); // set the image file name context.startActivityForResult(intent, requestCode); }
From source file:Main.java
public static void openSetting(Activity activity, int requestCode) { Intent intent = new Intent("/"); ComponentName cm = new ComponentName("com.android.settings", "com.android.settings.WirelessSettings"); intent.setComponent(cm);/*from w ww . j ava 2s . c o m*/ intent.setAction(Intent.ACTION_VIEW); activity.startActivityForResult(intent, requestCode); }
From source file:Main.java
public static void choiceAvatarFromGalleryWithCrop(Activity context) { Intent intent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI); intent.setType("image/*"); //intent.setAction(Intent.ACTION_GET_CONTENT); context.startActivityForResult(intent, SELECT_IMAGE_GALLERY_REQUEST_CODE); //if (Build.VERSION.SDK_INT < 19) { // Intent intentPikc = new Intent(); // intentPikc.setType("image/*"); // intentPikc.setAction(Intent.ACTION_GET_CONTENT); // context.startActivityForResult(intentPikc, SELECT_IMAGE_GALLERY_REQUEST_CODE); // } else { // Intent intentKitKat = new Intent(Intent.ACTION_GET_CONTENT); // intentKitKat.setType("image/*"); // context.startActivityForResult(intentKitKat, SELECT_KITKAT_IMAGE_GALLERY_REQUEST_CODE); // }//from w w w .ja v a 2s . c o m // Intent intent = new Intent(); // intent.setType("image/*"); // Intent intent = new Intent( // Intent.ACTION_GET_CONTENT, // MediaStore.Images.Media.INTERNAL_CONTENT_URI); // intent.setType("image/*"); //// Intent intent = new Intent(Intent.ACTION_PICK, //// android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI); //// intent.setAction(Intent.ACTION_GET_CONTENT); // context.startActivityForResult(intent, SELECT_IMAGE_GALLERY_REQUEST_CODE); // Intent intent = new Intent(); // intent.setType("image/*"); // intent.setAction(Intent.ACTION_GET_CONTENT); // context.startActivityForResult(Intent.createChooser(intent, "Select Picture"), SELECT_IMAGE_GALLERY_REQUEST_CODE); }
From source file:Main.java
public static void openNetSetting(Activity act) { Intent intent = new Intent(); ComponentName cm = new ComponentName("com.android.settings", "com.android.settings.WirelessSettings"); intent.setComponent(cm);//from ww w .j a v a 2 s . c o m intent.setAction("android.intent.action.VIEW"); act.startActivityForResult(intent, 0); }
From source file:Main.java
public static void takePicture(Activity mActivity, String imagePath) { Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); if (null != imagePath && !imagePath.isEmpty()) { intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(new File(imagePath))); }/* www . ja va2 s.c o m*/ mActivity.startActivityForResult(intent, BBS_REQUEST_CAMERA); }
From source file:com.yalin.fidoclient.api.UAFClientApi.java
public static void doDiscover(Activity activity, int requestCode) { if (activity == null) { throw new IllegalArgumentException(); }/*from w ww . j a va 2 s .c om*/ Intent intent = UAFIntent.getDiscoverIntent(); activity.startActivityForResult(intent, requestCode); }
From source file:id.nci.stm_9.FileHelper.java
/** * Opens the preferred installed file manager on Android and shows a toast if no manager is * installed.//from w w w . j a v a 2 s. co m * * @param activity * @param filename * default selected file, not supported by all file managers * @param mimeType * can be text/plain for example * @param requestCode * requestCode used to identify the result coming back from file manager to * onActivityResult() in your activity */ public static void openFile(Activity activity, String filename, String mimeType, int requestCode) { Intent intent = buildFileIntent(filename, mimeType); try { activity.startActivityForResult(intent, requestCode); } catch (ActivityNotFoundException e) { // No compatible file manager was found. Toast.makeText(activity, R.string.no_filemanager_installed, Toast.LENGTH_SHORT).show(); } }
From source file:Main.java
public static void startAR(Activity activity, Class<?> c, int requestCode, BasicNameValuePair... name) { Intent intent = new Intent(); intent.setClass(activity, c);/*from w ww . j a va 2 s . co m*/ for (int i = 0; i < name.length; i++) { intent.putExtra(name[i].getName(), name[i].getValue()); } activity.startActivityForResult(intent, requestCode); }
From source file:com.android.common.util.IntentUtils.java
/** * Take camera, this photo data will be returned in onActivityResult() * * @param activity/* w w w .ja v a2s . c o m*/ * @param requestCode */ public static void takeCamera(Activity activity, int requestCode) { Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); activity.startActivityForResult(intent, requestCode); }
From source file:br.org.funcate.dynamicforms.markers.MarkersUtilities.java
/** * Opens Marker in new sketch mode, supplying a file to save to. * <p/>/* w ww .ja v a 2 s . c o m*/ * <p>If position data are supplied, they should be used to create a properties file. * * @param context the context to use. * @param image the image file to save to. * @param gpsLocation the position of the sketch or <code>null</code>. * @param requestCode if > 0, then the activity is started for a result (in which case the * Context needs to be an activity.. */ public static void launch(Context context, File image, double[] gpsLocation, int requestCode) { if (MarkersUtilities.appInstalled(context)) { Intent sketchIntent = prepareIntent(context, image, gpsLocation); if (requestCode < 0) { context.startActivity(sketchIntent); } else { if (context instanceof Activity) { Activity activity = (Activity) context; activity.startActivityForResult(sketchIntent, requestCode); } } } else { MarkersUtilities.openMarketToInstall(context); } }