Example usage for android.app Activity startActivityForResult

List of usage examples for android.app Activity startActivityForResult

Introduction

In this page you can find the example usage for android.app Activity startActivityForResult.

Prototype

public void startActivityForResult(@RequiresPermission Intent intent, int requestCode) 

Source Link

Document

Same as calling #startActivityForResult(Intent,int,Bundle) with no options.

Usage

From source file:com.coinblesk.client.utils.UIUtils.java

private static void enableBluetooth(Activity activity) {
    if (!isBluetoothEnabled(activity)) {
        Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
        activity.startActivityForResult(enableBtIntent, 1);
        Intent exchangeRateChanged = new Intent(Constants.EXCHANGE_RATE_CHANGED_ACTION);
        LocalBroadcastManager.getInstance(activity).sendBroadcast(exchangeRateChanged);
    }//from   w w  w  .j  av a 2s  .  c om
}

From source file:com.example.maxuan.photoutils.ViewPagerActivity.java

public static void BrowserPhotos(Activity activity, ArrayList<Photo> photos, int index, int maxCount,
        SparseArray<Photo> selectedPhotos) {
    Intent intent = new Intent(activity, ViewPagerActivity.class);
    Bundle bundle = new Bundle();
    bundle.putSparseParcelableArray("selectedPhotos", selectedPhotos);
    bundle.putParcelableArrayList("photos", photos);
    bundle.putInt("position", index);
    bundle.putInt("maxCount", index);
    intent.putExtra("data", bundle);
    activity.startActivityForResult(intent, REQUEST_PAGE_SELECT_CODE);
}

From source file:com.keepassdroid.EntryActivity.java

public static void Launch(Activity act, PwEntry pw, int pos) {
    Intent i;/*from   w w w  .  j av a 2s  . c  o  m*/

    if (pw instanceof PwEntryV4) {
        i = new Intent(act, EntryActivityV4.class);
    } else {
        i = new Intent(act, EntryActivity.class);
    }

    i.putExtra(KEY_ENTRY, Types.UUIDtoBytes(pw.getUUID()));
    i.putExtra(KEY_REFRESH_POS, pos);

    act.startActivityForResult(i, 0);
}

From source file:net.vivekiyer.GAL.CorporateAddressBook.java

/**
 * Launches the preferences activity//from  ww w.j ava  2  s.  c om
 */
public static void showConfiguration(Activity parentActivity) {
    final Intent myIntent = new Intent();
    myIntent.setClassName("net.vivekiyer.GAL", //$NON-NLS-1$
            "net.vivekiyer.GAL.Configure"); //$NON-NLS-1$
    parentActivity.startActivityForResult(myIntent, DISPLAY_CONFIGURATION_REQUEST);
}

From source file:Main.java

/**
 * Enable bluetooth and get the adapter object
 * @return A BluetoothAdapter instance/*from   w ww.ja va  2s  . c o m*/
 */
public static BluetoothAdapter getLeAdapter(Activity _this) {
    // Initializes Bluetooth adapter.
    final BluetoothManager bluetoothLeManager = (BluetoothManager) _this
            .getSystemService(Context.BLUETOOTH_SERVICE);
    final BluetoothAdapter bluetoothLeAdapter = bluetoothLeManager.getAdapter();

    // Ensures Bluetooth is available on the device and it is enabled. If not,
    // displays a dialog requesting user permission to mEnableCharacteristic Bluetooth.
    // TODO / FIXME currently this bugs if the user doesn't have BT enabled,
    // TODO / FIXME since it just returns null and doesn't check the result later.
    if (bluetoothLeAdapter == null || !bluetoothLeAdapter.isEnabled()) {
        Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
        _this.startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);
        return null;
    } else {
        return bluetoothLeAdapter;
    }
}

From source file:com.readystatesoftware.ghostlog.MainActivity.java

private static void setupTagFilterPreference(final Activity activity, Preference preference) {
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity);
    preference.setSummary(prefs.getString(activity.getString(R.string.pref_tag_filter), null));
    preference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override/* ww w .  j  a  v a 2s  . co m*/
        public boolean onPreferenceClick(Preference preference) {
            Intent intent = new Intent(activity, TagFilterListActivity.class);
            activity.startActivityForResult(intent, CODE_TAG_FILTER);
            return true;
        }
    });
}

From source file:de.k3b.android.toGoZip.SettingsActivity.java

/**
 * public api to start settings-activity
 *///from  w  w  w.  j  av  a2  s .  c  o m
public static void startActivityForResult(Activity activity, int requestCode) {
    final Intent i = new Intent(activity, SettingsActivity.class);

    if (Global.debugEnabled) {
        Log.d(Global.LOG_CONTEXT, "SettingsActivity.show(startActivity='" + i + "')");
    }

    if (requestCode == 0) {
        activity.startActivity(i);
    } else {
        activity.startActivityForResult(i, requestCode);
    }

}

From source file:com.microsoft.rightsmanagement.ui.EmailActivity.java

/**
 * Show UI./*from ww  w . j  av a2s .co  m*/
 * 
 * @param requestCode the request code to be returned when activity completes
 * @param parentActivity the parent activity
 * @param emailActivityCompletionCallback the email activity completion callback
 */
public static void show(int requestCode, Activity parentActivity,
        CompletionCallback<String> emailActivityCompletionCallback) {
    Logger.ms(TAG, "show");
    parentActivity = validateActivityInputParameter(parentActivity);
    emailActivityCompletionCallback = validateCompletionCallbackInputParameter(emailActivityCompletionCallback);
    int requestCallbackId = emailActivityCompletionCallback.hashCode();
    sCallbackManager.putWaitingRequest(requestCallbackId, emailActivityCompletionCallback);
    Intent intent = new Intent(parentActivity, EmailActivity.class);
    intent.putExtra(REQUEST_CALLBACK_ID, requestCallbackId);
    intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
    parentActivity.startActivityForResult(intent, requestCode);
    Logger.me(TAG, "show");
}

From source file:br.com.brolam.cloudvision.ui.NoteVisionActivity.java

/**
 * Incluir um NoteVision e seu contedo/*from   w w w  .  ja v  a  2s.c  om*/
 * @param activity informar uma atividade vlida
 * @param requestCod informar o cdigo de requisio da atividade {@see Activity.onActivityResult}
 */
public static void newNoteVision(Activity activity, int requestCod) {
    Intent intent = new Intent(activity, NoteVisionActivity.class);
    activity.startActivityForResult(intent, requestCod);

}

From source file:com.king.base.util.SystemUtils.java

/**
 * ?//from  ww  w  .  j  a  v  a2 s .com
 *
 * @param activity
 * @param path
 * @param requestCode
 */
public static void imageCapture(Activity activity, String path, int requestCode) {
    Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    if (!TextUtils.isEmpty(path)) {
        Uri uri = null;
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
            uri = FileProvider.getUriForFile(activity, activity.getPackageName() + ".fileProvider",
                    new File(path));
        } else {
            uri = Uri.fromFile(new File(path));
        }
        intent.putExtra(MediaStore.EXTRA_OUTPUT, uri);
    }
    activity.startActivityForResult(intent, requestCode);
}