當前位置: 首頁>>代碼示例>>Java>>正文


Java Activity.startActivityForResult方法代碼示例

本文整理匯總了Java中android.app.Activity.startActivityForResult方法的典型用法代碼示例。如果您正苦於以下問題:Java Activity.startActivityForResult方法的具體用法?Java Activity.startActivityForResult怎麽用?Java Activity.startActivityForResult使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.app.Activity的用法示例。


在下文中一共展示了Activity.startActivityForResult方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: photoCapture

import android.app.Activity; //導入方法依賴的package包/類
public static Uri photoCapture(Activity activity, int requstCode) {
    Uri mCaptureUri = null;
    if (android.os.Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED)) {
        try {
            mCaptureUri = Uri.fromFile(new File(getFileDir(), "pic_" + String.valueOf(System.currentTimeMillis()) +
                    ".jpg"));
            Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
            intent.putExtra(MediaStore.EXTRA_OUTPUT, mCaptureUri);
            intent.putExtra("return-data", true);
            activity.startActivityForResult(intent, requstCode);
            // IntentUtil.openActivityAnim(SubmitActivity.this);
        } catch (ActivityNotFoundException e) {
            e.printStackTrace();
        }
    } else {
        Toast.makeText(activity, "請插入SD卡", Toast.LENGTH_SHORT).show();
    }
    return mCaptureUri;
}
 
開發者ID:zhonglikui,項目名稱:cardinalsSample,代碼行數:20,代碼來源:PhotoCaptureUtil.java

示例2: openFilePicker

import android.app.Activity; //導入方法依賴的package包/類
@TargetApi(Build.VERSION_CODES.KITKAT)
public static void openFilePicker(Activity activity) {
    Intent i = new Intent(Intent.ACTION_CREATE_DOCUMENT);
    i.addCategory(Intent.CATEGORY_OPENABLE);
    i.setType("audio/*");
    i.putExtra("android.content.extra.SHOW_ADVANCED", true);
    activity.startActivityForResult(i, SAFUtil.REQUEST_SAF_PICK_FILE);
}
 
開發者ID:h4h13,項目名稱:RetroMusicPlayer,代碼行數:9,代碼來源:SAFUtil.java

示例3: importBookmarks

import android.app.Activity; //導入方法依賴的package包/類
/**
 * This method starts open document system activity.
 * @param activity
 */
@TargetApi(Build.VERSION_CODES.KITKAT)
public static void importBookmarks(Activity activity) {
    // choose a file via the system's file browser
    Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
    // show only results that can be "opened", such as a file
    intent.addCategory(Intent.CATEGORY_OPENABLE);
    // filter to show only plain text
    intent.setType(MIME_TYPE);

    activity.startActivityForResult(intent, READ_REQUEST_CODE);
}
 
開發者ID:nfdz,項目名稱:foco,代碼行數:16,代碼來源:ImportExportUtils.java

示例4: startImagePicker

import android.app.Activity; //導入方法依賴的package包/類
public static void startImagePicker(Activity activity, boolean showCamera,
                                    boolean clear, boolean crop,
                                    boolean multiMode, int selectLimit,
                                    @ImageDataSource.LoaderType int loadType,
                                    CropImageView.Style style /*圖片剪切框的形狀*/) {
    ImagePicker imagePicker = ImagePicker.getInstance();
    imagePicker.setImageLoader(new GlideImageLoader());
    imagePicker.setCrop(crop);
    imagePicker.setMultiMode(multiMode);
    imagePicker.setShowCamera(showCamera);
    imagePicker.setSelectLimit(selectLimit);
    imagePicker.setOutPutX(800);
    imagePicker.setOutPutY(800);
    imagePicker.setFocusWidth(600);
    imagePicker.setFocusHeight(600);
    imagePicker.setLoadType(loadType);
    imagePicker.setStyle(style);
    Intent intent = new Intent(activity, ImageGridActivity.class);
    intent.putExtra(ImageGridActivity.CLEAR_SELECTOR, clear);
    activity.startActivityForResult(intent, REQUEST_CODE);
}
 
開發者ID:angcyo,項目名稱:RLibrary,代碼行數:22,代碼來源:ImagePickerHelper.java

示例5: cropPicture

import android.app.Activity; //導入方法依賴的package包/類
/***
 * 裁剪圖片
 * @param activity Activity
 * @param uri 圖片的Uri
 */
public static void cropPicture(Activity activity, Uri uri) {
	Intent innerIntent = new Intent("com.android.camera.action.CROP");
	innerIntent.setDataAndType(uri, "image/*");
	innerIntent.putExtra("crop", "true");// 才能出剪輯的小方框,不然沒有剪輯功能,隻能選取圖片
	innerIntent.putExtra("aspectX", 1); // 放大縮小比例的X
	innerIntent.putExtra("aspectY", 1);// 放大縮小比例的X   這裏的比例為:   1:1
	innerIntent.putExtra("outputX", 320);  //這個是限製輸出圖片大小
	innerIntent.putExtra("outputY", 320); 
	innerIntent.putExtra("return-data", true);
	// 切圖大小不足輸出,無黑框
	innerIntent.putExtra("scale", true);
	innerIntent.putExtra("scaleUpIfNeeded", true);
	File imageFile = new File(getImagePath(activity.getApplicationContext()));
	innerIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(imageFile));
	innerIntent.putExtra("outputFormat", Bitmap.CompressFormat.JPEG.toString());
	activity.startActivityForResult(innerIntent, REQUEST_CROP_IMAGE);
}
 
開發者ID:SoulEaterVTT,項目名稱:KotlinStudy,代碼行數:23,代碼來源:FaceUtil.java

示例6: startActivityForResult

import android.app.Activity; //導入方法依賴的package包/類
/**
 * Safe Start activity for result with ActivityOptionsCompats
 *
 * @param a           current activity
 * @param i           intent to launch
 * @param requestCode requestCcde
 * @param options     ActivityOptionsCompat
 */
public static void startActivityForResult(Activity a,
                                          Intent i,
                                          int requestCode,
                                          ActivityOptionsCompat options) {
    if (a == null) {
        return;
    }
    if (options != null) {
        a.startActivityForResult(
                i,
                requestCode,
                options.toBundle()
        );
    } else {
        a.startActivityForResult(
                i,
                requestCode);
    }
}
 
開發者ID:yajnesh,項目名稱:AndroidGeneralUtils,代碼行數:28,代碼來源:ActivityUtil.java

示例7: openSAF

import android.app.Activity; //導入方法依賴的package包/類
public static void openSAF(Activity context) {

        Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
        context.startActivityForResult(intent, 42);
    }
 
開發者ID:htqqdd,項目名稱:music_player,代碼行數:6,代碼來源:menu_util.java

示例8: startForResultActivity

import android.app.Activity; //導入方法依賴的package包/類
public static void startForResultActivity(Activity context, Class<?> forwardActivity, int requestCode, Bundle bundle, Boolean isFinish, int animin, int animout) {
    Intent intent = new Intent(context, forwardActivity);
    //intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    if (bundle != null)
        intent.putExtras(bundle);
    context.startActivityForResult(intent, requestCode);
    if (isFinish) {
        context.finish();
    }
    try {
        context.overridePendingTransition(animin, animout);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
開發者ID:zhou-you,項目名稱:RxEasyHttp,代碼行數:16,代碼來源:AppTools.java

示例9: launch

import android.app.Activity; //導入方法依賴的package包/類
public static void launch(Activity context, String pname, String expire, String price, String pdescription, String orderId) {
    Intent intent = new Intent(context, PaySucceedActivity.class);
    intent.putExtra("pname", pname);
    intent.putExtra("expire", expire);
    intent.putExtra("price", price);
    intent.putExtra("payType", pdescription);
    intent.putExtra("orderId", orderId);
    context.startActivityForResult(intent, 17);
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:10,代碼來源:PaySucceedActivity.java

示例10: openPhotoCutter

import android.app.Activity; //導入方法依賴的package包/類
public static void openPhotoCutter(Activity activity, Uri uri) {
    Intent intent = new Intent("com.android.camera.action.CROP");
    intent.setDataAndType(uri, "image/*");
    intent.putExtra("crop", "true");
    intent.putExtra("aspectX", 1);
    intent.putExtra("aspectY", 1);
    intent.putExtra("outputX", 192);
    intent.putExtra("outputY", 192);
    intent.putExtra("return-data", true);
    intent.putExtra("outputFormat", Bitmap.CompressFormat.JPEG.toString());
    activity.startActivityForResult(intent, Types.TYPE_SAVE_PROFILE);
}
 
開發者ID:SailFlorve,項目名稱:RunHDU,代碼行數:13,代碼來源:ImageUtil.java

示例11: startActivity

import android.app.Activity; //導入方法依賴的package包/類
public static void startActivity(Activity context, String url) {
    if (!TextUtils.isEmpty(url)) {
        Intent i = new Intent(context, SportPlayActivity.class);
        i.putExtra("VIDEO_URL", url);
        PlayerManager.getInstance().prepareFullScreen();
        context.startActivityForResult(i, 1);
    }
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:9,代碼來源:SportPlayActivity.java

示例12: openSetting

import android.app.Activity; //導入方法依賴的package包/類
/**
 * 打開網絡設置界麵
 */
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);
    intent.setAction(Intent.ACTION_VIEW);
    activity.startActivityForResult(intent, requestCode);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:12,代碼來源:NetUtils.java

示例13: startSingleSignOn

import android.app.Activity; //導入方法依賴的package包/類
private boolean startSingleSignOn(Activity activity, String applicationId, String[]
        permissions, int activityCode) {
    boolean didSucceed = true;
    Intent intent = new Intent();
    intent.setClassName(ssoPackageName, ssoActivityName);
    intent.putExtra(UMSsoHandler.APPKEY, applicationId);
    String redirectUrl = SocializeConfig.getSocializeConfig().getSinaCallbackUrl();
    if (!TextUtils.isEmpty(redirectUrl)) {
        REDIRECT_URL = redirectUrl;
    }
    intent.putExtra("redirectUri", REDIRECT_URL);
    if (permissions.length > 0) {
        intent.putExtra("scope", TextUtils.join(",", permissions));
    }
    if (!validateAppSignatureForIntent(activity, intent)) {
        return false;
    }
    try {
        activity.startActivityForResult(intent, activityCode);
    } catch (ActivityNotFoundException e) {
        didSucceed = false;
    }
    if (this.isAlive) {
        this.isAlive = isServiceAlive(activity);
        if (this.isAlive) {
            activity.getApplication().unbindService(this.mServiceConnection);
        }
    }
    return didSucceed;
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:31,代碼來源:SinaSsoHandler.java

示例14: start

import android.app.Activity; //導入方法依賴的package包/類
/**
 * 便捷啟動當前activity
 *
 * @param activity 啟動當前activity的activity
 */
public static void start(Activity activity, List<ColumnBean> selectedList, List<ColumnBean> optionalList) {
    Intent intent = new Intent(activity, ColumnActivity.class);
    Bundle bundle = new Bundle();
    bundle.putSerializable("selectedList_key", (Serializable) selectedList);
    bundle.putSerializable("optionalList_key", (Serializable) optionalList);
    intent.putExtras(bundle);
    activity.startActivityForResult(intent, MainActivity.REQUEST_CODE_COLUMN);
    activity.overridePendingTransition(R.anim.column_show, R.anim.column_bottom);
}
 
開發者ID:6ag,項目名稱:LiuAGeAndroid,代碼行數:15,代碼來源:ColumnActivity.java

示例15: startAssitActivity

import android.app.Activity; //導入方法依賴的package包/類
protected void startAssitActivity(Activity activity, IUiListener iUiListener) {
    AssistActivity.setApiObject(this);
    int i = sRequestCode;
    sRequestCode = i + 1;
    this.mActivityIntent.putExtra("key_request_code", i);
    this.mTaskList.add(new ApiTask(i, iUiListener));
    activity.startActivityForResult(getAssitIntent(activity), Constants.REQUEST_API);
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:9,代碼來源:BaseApi.java


注:本文中的android.app.Activity.startActivityForResult方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。