Java Code Examples for android.support.v4.app.ActivityCompat#startActivityForResult()

The following examples show how to use android.support.v4.app.ActivityCompat#startActivityForResult() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CategorySelectionFragment.java    From android-topeka with Apache License 2.0 6 votes vote down vote up
private void startQuizActivityWithTransition(Activity activity, View toolbar,
                                             Category category) {

    final Pair[] pairs = TransitionHelper.createSafeTransitionParticipants(activity, false,
            new Pair<>(toolbar, activity.getString(R.string.transition_toolbar)));
    @SuppressWarnings("unchecked")
    ActivityOptionsCompat sceneTransitionAnimation = ActivityOptionsCompat
            .makeSceneTransitionAnimation(activity, pairs);

    // Start the activity with the participants, animating from one to the other.
    final Bundle transitionBundle = sceneTransitionAnimation.toBundle();
    Intent startIntent = QuizActivity.getStartIntent(activity, category);
    ActivityCompat.startActivityForResult(activity,
            startIntent,
            REQUEST_CATEGORY,
            null);
}
 
Example 2
Source File: MovieLibraryFragment.java    From Mizuu with Apache License 2.0 6 votes vote down vote up
private void viewMovieDetails(int position, View view) {
    Intent intent = new Intent();
    if (mMovieLoader.getType() == MovieLibraryType.COLLECTIONS) { // Collection
        intent.putExtra("collectionId", mAdapter.getItem(position).getCollectionId());
        intent.putExtra("collectionTitle", mAdapter.getItem(position).getCollection());
        intent.setClass(mContext, MovieCollection.class);
        startActivity(intent);
    } else {
        intent.putExtra("tmdbId", mAdapter.getItem(position).getTmdbId());
        intent.setClass(mContext, MovieDetails.class);

        if (view != null) {
            Pair<View, String> pair = new Pair<>(view.findViewById(R.id.cover), "cover");
            ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(getActivity(), pair);
            ActivityCompat.startActivityForResult(getActivity(), intent, 0, options.toBundle());
        } else {
            startActivityForResult(intent, 0);
        }
    }
}
 
Example 3
Source File: AddActivity.java    From ExpressHelper with GNU General Public License v3.0 6 votes vote down vote up
public static void launch(AbsActivity mActivity, View fab) {
	Intent intent = new Intent(mActivity, AddActivity.class);
	intent.setFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
	if (!mActivity.mSets.getBoolean(Settings.KEY_DISABLE_ANIMATION, false)) {
		ActivityOptionsCompat options =
				ActivityOptionsCompat.makeSceneTransitionAnimation(
						mActivity, fab, TRANSITION_NAME_FAB
				);
		ActivityCompat.startActivityForResult(
				mActivity,
				intent,
				MainActivity.REQUEST_ADD,
				options.toBundle()
		);
	} else {
		mActivity.startActivityForResult(intent, MainActivity.REQUEST_ADD);
	}
}
 
Example 4
Source File: CategorySelectionFragment.java    From CoolSignIn with Apache License 2.0 6 votes vote down vote up
private void startQuizActivityWithTransition(Activity activity, View toolbar,
                                             Category category) {

    final Pair[] pairs = TransitionHelper.createSafeTransitionParticipants(activity, false,
            new Pair<>(toolbar, activity.getString(R.string.transition_toolbar)));
    @SuppressWarnings("unchecked")
    ActivityOptionsCompat sceneTransitionAnimation = ActivityOptionsCompat
            .makeSceneTransitionAnimation(activity, pairs);

    // Start the activity with the participants, animating from one to the other.
    final Bundle transitionBundle = sceneTransitionAnimation.toBundle();
    Intent startIntent = QuizActivity.getStartIntent(activity, category);
    ActivityCompat.startActivityForResult(activity,
            startIntent,
            REQUEST_CATEGORY,
            transitionBundle);
}
 
Example 5
Source File: MainActivity.java    From materialize with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onItemClick(AppInfoAdapter.ViewHolder holder) {
    int index = holder.getLayoutPosition();
    AppInfo app = apps.data.get(index);

    Intent intent = new Intent(this, AdjustActivity.class);
    intent.putExtra("index", index);
    intent.putExtra("activity", app.activityInfo);

    int y = Build.VERSION.SDK_INT >= 23
            ? (int) (getResources().getDisplayMetrics().heightPixels * 0.16f)
            : 0;

    ActivityOptionsCompat options = ActivityOptionsCompatCompat.makeClipRevealAnimation(
            holder.itemView, 0, -y, holder.itemView.getWidth(), holder.itemView.getHeight());

    ActivityCompat.startActivityForResult(this, intent, REQUEST_MAKE_ICON, options.toBundle());
}
 
Example 6
Source File: BaseActivityLauncher.java    From SmartGo with Apache License 2.0 6 votes vote down vote up
@Override
public void goReally(final Context context,final Intent intent){
    if(isAvailable(context,intent)) {
        final ActivityOptionsCompat options = mActivityOptionsBox.get();
        Bundle optionsBundle = null;
        if(options != null) {
            optionsBundle = options.toBundle();
        }

        if(context instanceof Activity) {
            ActivityCompat.startActivityForResult((Activity) context, intent, mRequestCode, optionsBundle);
        }else {
            ContextCompat.startActivities(context,new Intent[]{intent},optionsBundle);
        }
    }else{
        SmartGoLog.e("have no resolved activity : " + intent);
    }
}
 
Example 7
Source File: AppsPreferencesActivity.java    From Mi-Band with GNU General Public License v2.0 5 votes vote down vote up
private void thumbNailScaleAnimation(View view, App app, int position) {
    ActivityOptionsCompat options =
            ActivityOptionsCompat.makeSceneTransitionAnimation(
                    AppsPreferencesActivity.this, view, AppDetailActivity.extra);
    Intent intent = new Intent(AppsPreferencesActivity.this, AppDetailActivity.class);
    Bundle b = new Bundle();
    b.putParcelable(AppDetailActivity.extra, app);
    b.putInt(AppDetailActivity.extra_position, position);

    intent.putExtras(b);
    ActivityCompat.startActivityForResult(AppsPreferencesActivity.this, intent, APP_DETAIL_CODE, options.toBundle());
}
 
Example 8
Source File: Router.java    From XDroidMvp with MIT License 5 votes vote down vote up
public void launch() {
    try {
        if (intent != null && from != null && to != null) {

            if (callback != null) {
                callback.onBefore(from, to);
            }

            intent.setClass(from, to);

            intent.putExtras(getBundleData());

            if (options == null) {
                if (requestCode < 0) {
                    from.startActivity(intent);
                } else {
                    from.startActivityForResult(intent, requestCode);
                }

                if (enterAnim > 0 && exitAnim > 0) {
                    from.overridePendingTransition(enterAnim, exitAnim);
                }
            } else {
                if (requestCode < 0) {
                    ActivityCompat.startActivity(from, intent, options.toBundle());
                } else {
                    ActivityCompat.startActivityForResult(from, intent, requestCode, options.toBundle());
                }
            }

            if (callback != null) {
                callback.onNext(from, to);
            }
        }
    } catch (Throwable throwable) {
        if (callback != null) {
            callback.onError(from, to, throwable);
        }
    }
}
 
Example 9
Source File: ChromeCustomTabPlugin.java    From cordova-plugin-safariviewcontroller with MIT License 5 votes vote down vote up
private void startCustomTabActivity(String url, Intent intent) {
    intent.setData(Uri.parse(url));
    if(mStartAnimationBundle == null)
        cordova.startActivityForResult(this, intent, CUSTOM_TAB_REQUEST_CODE);
    else {
        cordova.setActivityResultCallback(this);
        ActivityCompat.startActivityForResult(cordova.getActivity(), intent, CUSTOM_TAB_REQUEST_CODE, mStartAnimationBundle);
    }
}
 
Example 10
Source File: Tools.java    From Lucid-Browser with Apache License 2.0 5 votes vote down vote up
public static void launchIntentForResult(Intent i, View v, Activity activity, int requestCode){
	Log.d("LL","launchIntentForResult");
	ActivityOptionsCompat options = Tools.getActivityAnimation(v, activity);

	try {
		if (options != null)
			ActivityCompat.startActivityForResult(activity, i, requestCode, options.toBundle());
		else
			activity.startActivityForResult(i,requestCode);
	}catch (Exception e){
		e.printStackTrace();
	}
}
 
Example 11
Source File: UserPhotosFragment.java    From android-open-project-demo with Apache License 2.0 5 votes vote down vote up
public void onItemClick(AdapterView<?> gridView, View view, int position,
		long id) {
	if (view.getId() == R.id.iv_camera_button) {
		takePhoto();
	} else {
		Bundle b = null;
		if (VERSION.SDK_INT >= 16) {
			ActivityOptionsCompat options = ActivityOptionsCompat
					.makeThumbnailScaleUpAnimation(view,
							Utils.drawViewOntoBitmap(view), 0, 0);
			b = options.toBundle();
		}

		Intent intent = new Intent(getActivity(), PhotoViewerActivity.class);

		// Need take Camera icon into account so minus 1
		intent.putExtra(PhotoViewerActivity.EXTRA_POSITION, position - 1);
		intent.putExtra(PhotoViewerActivity.EXTRA_MODE,
				PhotoViewerActivity.MODE_ALL_VALUE);

		MediaStoreBucket bucket = (MediaStoreBucket) mBucketSpinner
				.getSelectedItem();
		intent.putExtra(PhotoViewerActivity.EXTRA_BUCKET_ID, bucket.getId());

		ActivityCompat.startActivityForResult(getActivity(), intent,
				RESULT_PHOTOVIEW, b);
	}

}
 
Example 12
Source File: TvShowLibraryFragment.java    From Mizuu with Apache License 2.0 5 votes vote down vote up
private void viewTvShowDetails(int position, View view) {
    Intent intent = new Intent();
    intent.putExtra("showId", mAdapter.getItem(position).getId());
    intent.setClass(mContext, TvShowDetails.class);

    if (view != null) {
        Pair<View, String> pair = new Pair<>(view.findViewById(R.id.cover), "cover");
        ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(getActivity(), pair);
        ActivityCompat.startActivityForResult(getActivity(), intent, 0, options.toBundle());
    } else {
        startActivityForResult(intent, 0);
    }
}
 
Example 13
Source File: PermissionsActivity.java    From OKHTTPUploadImage with Apache License 2.0 4 votes vote down vote up
public static void startActivityForResult(Activity activity, int requestCode, String... permissions) {
    Intent intent = new Intent(activity, PermissionsActivity.class);
    intent.putExtra(EXTRA_PERMISSIONS, permissions);
    ActivityCompat.startActivityForResult(activity, intent, requestCode, null);
}
 
Example 14
Source File: PermissionsActivity.java    From AndroidStudyDemo with GNU General Public License v2.0 4 votes vote down vote up
public static void startActivityForResult(Activity activity, int requestCode, String... permissions) {
    Intent intent = new Intent(activity, PermissionsActivity.class);
    intent.putExtra(EXTRA_PERMISSIONS, permissions);
    ActivityCompat.startActivityForResult(activity, intent, requestCode, null);
}
 
Example 15
Source File: MainActivity.java    From android-silent-ping-sms with GNU General Public License v3.0 4 votes vote down vote up
void pickContact() {
    Intent pickIntent = new Intent(Intent.ACTION_PICK);
    pickIntent.setType(ContactsContract.CommonDataKinds.Phone.CONTENT_TYPE);
    ActivityCompat.startActivityForResult(this, pickIntent, MENU_ITEM_PICK_CONTACT, null);
}
 
Example 16
Source File: PermissionsActivity.java    From AndroidReview with GNU General Public License v3.0 4 votes vote down vote up
public static void startActivityForResult(Activity activity, int requestCode, String... permissions) {
    Intent intent = new Intent(activity, PermissionsActivity.class);
    intent.putExtra(EXTRA_PERMISSIONS, permissions);
    ActivityCompat.startActivityForResult(activity, intent, requestCode, null);
}
 
Example 17
Source File: PermissionsActivity.java    From RetrofitImageUpload with Apache License 2.0 4 votes vote down vote up
public static void startActivityForResult(Activity activity, int requestCode, String... permissions) {
    Intent intent = new Intent(activity, PermissionsActivity.class);
    intent.putExtra(EXTRA_PERMISSIONS, permissions);
    ActivityCompat.startActivityForResult(activity, intent, requestCode, null);
}
 
Example 18
Source File: PermissionsActivity.java    From EvilsLive with MIT License 4 votes vote down vote up
public static void startActivityForResult(Activity activity, int requestCode, String... permissions) {
    Intent intent = new Intent(activity, PermissionsActivity.class);
    intent.putExtra(EXTRA_PERMISSIONS, permissions);
    ActivityCompat.startActivityForResult(activity, intent, requestCode, null);
}
 
Example 19
Source File: PermissionsActivity.java    From UCDLive_Android with MIT License 3 votes vote down vote up
public static void startActivityForResult(Activity activity, int requestCode, String... permissions) {
    Intent intent = new Intent(activity, PermissionsActivity.class);

    EXTRA_PERMISSIONS = activity.getPackageName() + ".extra_permission";

    intent.putExtra(EXTRA_PERMISSIONS, permissions);

    ActivityCompat.startActivityForResult(activity, intent, requestCode, null);
}
 
Example 20
Source File: PermissionsActivity.java    From UCDMediaPlayer_Android with MIT License 3 votes vote down vote up
public static void startActivityForResult(Activity activity, int requestCode, String... permissions) {
    Intent intent = new Intent(activity, PermissionsActivity.class);

    EXTRA_PERMISSIONS = activity.getPackageName() + ".extra_permission";

    intent.putExtra(EXTRA_PERMISSIONS, permissions);

    ActivityCompat.startActivityForResult(activity, intent, requestCode, null);
}