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 checkPhoneSettings(Activity activity) { //Check if device supports bluetooth: if (mBluetoothAdapter == null) { //!TODO/*from w ww .j a v a 2 s . c o m*/ } else { Log.v("", "Bluetooth is supported"); //Check if bluetooth is enabled. If not, request the user to enable it. if (!mBluetoothAdapter.isEnabled()) { Log.v("", "Bluetooth is not turned on"); Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE); activity.startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT); } else { deviceMAC = getMACAddress(); } } }
From source file:Main.java
public static void pickRing(Activity activity) { Intent intent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER); intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, RingtoneManager.TYPE_NOTIFICATION); intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TITLE, "Select Tone"); if (mRingUri != null) { intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, mRingUri); } else {/*from ww w . java2 s .c o m*/ intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, (Uri) null); } activity.startActivityForResult(intent, RESULT_PICK_RING); }
From source file:Main.java
public static void openActivity(Activity activity, Class<?> pClass, Bundle pBundle, int requestCode, int enterAnim, int exitAnim) { if (null == activity) return;/*from ww w . java2 s . co m*/ Intent intent = new Intent(activity, pClass); if (pBundle != null) { intent.putExtras(pBundle); } if (requestCode < 0) { activity.startActivity(intent); } else { activity.startActivityForResult(intent, requestCode); } if (enterAnim > 0 && exitAnim > 0) { activity.overridePendingTransition(enterAnim, exitAnim); } }
From source file:com.allen.mediautil.ImageTakerHelper.java
/** * ? onActivityResult()?/*from w w w. jav a2s . c o m*/ */ public static void openAlbum(Activity activity) { Intent intentAlbum = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI); intentAlbum.setType("image/*"); activity.startActivityForResult(Intent.createChooser(intentAlbum, ""), REQUEST_ALBUM); }
From source file:de.schildbach.wallet.ui.scan.ScanActivity.java
public static void startForResult(final Activity activity, final int resultCode) { activity.startActivityForResult(new Intent(activity, ScanActivity.class), resultCode); }
From source file:Main.java
public static void openActivity(Activity activity, Class<?> pClass, String pAction, Bundle pBundle, int requestCode) { if (null == activity) return;//from w w w. ja v a2 s. co m Intent intent = new Intent(pAction); intent.setClass(activity, pClass); if (pBundle != null) { intent.putExtras(pBundle); } if (requestCode < 0) { activity.startActivity(intent); } else { activity.startActivityForResult(intent, requestCode); } }
From source file:de.domjos.schooltools.helper.Helper.java
public static void displaySpeechRecognizer(Activity activity, int req_code) { Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH); intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM); activity.startActivityForResult(intent, req_code); }
From source file:com.lvbo.template.common.Utils.PermissionUtils.java
/** * ??/*from w ww .j av a 2 s. co m*/ * * @param cxt * @param req * @return */ @TargetApi(23) public static boolean checkSettingAlertPermission(Object cxt, int req) { if (cxt instanceof Activity) { Activity activity = (Activity) cxt; if (!Settings.canDrawOverlays(activity.getBaseContext())) { Log.i(TAG, "Setting not permission"); Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION, Uri.parse("package:" + activity.getPackageName())); activity.startActivityForResult(intent, req); return false; } } else if (cxt instanceof Fragment) { Fragment fragment = (Fragment) cxt; if (!Settings.canDrawOverlays(fragment.getActivity())) { Log.i(TAG, "Setting not permission"); Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION, Uri.parse("package:" + fragment.getActivity().getPackageName())); fragment.startActivityForResult(intent, req); Context c; return false; } } else { throw new RuntimeException("cxt is net a activity or fragment"); } return true; }
From source file:Main.java
public static void start(Activity activity, Fragment fragment, Class<?> cls, Bundle extras, int req_code, int enterAnim, int exitAnim) { if (null != activity) { Intent intent = new Intent(activity, cls); if (null != extras) { intent.putExtras(extras);/*from w w w .ja v a 2 s . c o m*/ } if (REQUEST_CODE_INVALID == req_code) { activity.startActivity(intent); } else { activity.startActivityForResult(intent, req_code); } if (0 != enterAnim || 0 != exitAnim) { activity.overridePendingTransition(enterAnim, exitAnim); } } else if (null != fragment) { activity = fragment.getActivity(); if (null != activity) { Intent intent = new Intent(activity, cls); if (null != extras) { intent.putExtras(extras); } if (REQUEST_CODE_INVALID == req_code) { fragment.startActivity(intent); } else { fragment.startActivityForResult(intent, req_code); } if (0 != enterAnim || 0 != exitAnim) { activity.overridePendingTransition(enterAnim, exitAnim); } } } }
From source file:Main.java
public static void sendSchemeForResultAddMediaStack(Activity context, String mediaActivityUrl, String url, int requestCode, Bundle bundle) { Intent intent = new Intent("android.intent.action.VIEW", Uri.parse(mediaActivityUrl)); intent.addFlags(67108864);//w w w . j a v a2 s . c o m context.startActivity(intent); intent = new Intent("android.intent.action.VIEW", Uri.parse(url)); if (bundle != null) { intent.putExtras(bundle); } context.startActivityForResult(intent, requestCode); }