本文整理汇总了Java中android.support.v7.app.AppCompatActivity.startActivityForResult方法的典型用法代码示例。如果您正苦于以下问题:Java AppCompatActivity.startActivityForResult方法的具体用法?Java AppCompatActivity.startActivityForResult怎么用?Java AppCompatActivity.startActivityForResult使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v7.app.AppCompatActivity
的用法示例。
在下文中一共展示了AppCompatActivity.startActivityForResult方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: signIn
import android.support.v7.app.AppCompatActivity; //导入方法依赖的package包/类
public static void signIn(AppCompatActivity activity) {
String defaultWebClientId = activity.getString(R.string.default_web_client_id);
GoogleSignInOptions googleSignInOptions = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestIdToken(defaultWebClientId)
.requestEmail()
.build();
GoogleSignInClient googleSignInClient = GoogleSignIn.getClient(activity, googleSignInOptions);
Intent signInIntent = googleSignInClient.getSignInIntent();
activity.startActivityForResult(signInIntent, AppConstants.GOOGLE_SIGN_IN);
}
示例2: open
import android.support.v7.app.AppCompatActivity; //导入方法依赖的package包/类
public static void open(AppCompatActivity context, View fab, String title, CharSequence content) {
Intent intent = getIntent(context, title, content, null, "OK");
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(context, fab, "morph_transition");
context.startActivityForResult(intent, 1, options.toBundle());
} else
context.startActivityForResult(intent, 1);
}
示例3: openCameraGalleryChooser
import android.support.v7.app.AppCompatActivity; //导入方法依赖的package包/类
/**
* カメラかギャラリーを選択する画面を表示
*/
public void openCameraGalleryChooser(AppCompatActivity activity) {
// カメラ
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
if (takePictureIntent.resolveActivity(activity.getPackageManager()) != null) {
// 参考
// https://akira-watson.com/android/camera-intent.html
// https://inthecheesefactory.com/blog/how-to-share-access-to-file-with-fileprovider-on-android-nougat
try {
photoFile = createImageFile();
} catch (IOException ex) {
ex.printStackTrace();
}
if (photoFile != null) {
Uri photoUri = getPhotoUri(activity, photoFile);
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoUri);
}
}
// ギャラリー
Intent contentSelectionIntent = new Intent(Intent.ACTION_GET_CONTENT);
contentSelectionIntent.addCategory(Intent.CATEGORY_OPENABLE);
// 複数mimetype設定
// https://stackoverflow.com/a/42582490
contentSelectionIntent.setType("*/*");
contentSelectionIntent.putExtra(Intent.EXTRA_MIME_TYPES, fileChooserParams.getAcceptTypes());
contentSelectionIntent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, fileChooserParams.getMode() == FileChooserParams.MODE_OPEN_MULTIPLE);
Intent chooserIntent = Intent.createChooser(contentSelectionIntent, "pick image");
Intent[] intentArray = new Intent[]{takePictureIntent};
chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, intentArray);
activity.startActivityForResult(chooserIntent, INPUT_FILE_REQUEST_CODE);
}