Java Code Examples for androidx.core.app.ActivityCompat#startActivity()

The following examples show how to use androidx.core.app.ActivityCompat#startActivity() . 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: LatestFragment.java    From light-novel-library_Wenku8_Android with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void onItemClick(View view, final int position) {
    //Toast.makeText(getActivity(),"item click detected", Toast.LENGTH_SHORT).show();
    if(position < 0 || position >= listNovelItemInfo.size()) {
        // ArrayIndexOutOfBoundsException
        Toast.makeText(getActivity(), "ArrayIndexOutOfBoundsException: " + position + " in size " + listNovelItemInfo.size(), Toast.LENGTH_SHORT).show();
        return;
    }

    // go to detail activity
    Intent intent = new Intent(getActivity(), NovelInfoActivity.class);
    intent.putExtra("aid", listNovelItemInfo.get(position).aid);
    intent.putExtra("from", "latest");
    intent.putExtra("title", listNovelItemInfo.get(position).title);
    if(Build.VERSION.SDK_INT < 21) {
        startActivity(intent);
    }
    else {
        ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(getActivity(),
                Pair.create(view.findViewById(R.id.novel_cover), "novel_cover"),
                Pair.create(view.findViewById(R.id.novel_title), "novel_title"));
        ActivityCompat.startActivity(getActivity(), intent, options.toBundle());
    }
}
 
Example 2
Source File: FragmentUtils.java    From hipda with GNU General Public License v2.0 6 votes vote down vote up
public static void showPostActivity(Activity activity, int mode, String parentSessionId,
                                    int fid, String tid, String postId, int floor,
                                    String author, String text, String quoteText) {
    Intent intent = new Intent(activity, PostActivity.class);
    intent.putExtra(PostFragment.ARG_MODE_KEY, mode);
    intent.putExtra(PostFragment.ARG_FID_KEY, fid);
    intent.putExtra(PostFragment.ARG_PARENT_ID, parentSessionId);
    intent.putExtra(PostFragment.ARG_TID_KEY, tid);
    intent.putExtra(PostFragment.ARG_PID_KEY, postId);
    intent.putExtra(PostFragment.ARG_FLOOR_KEY, floor);
    if (text != null)
        intent.putExtra(PostFragment.ARG_TEXT_KEY, text);
    if (author != null)
        intent.putExtra(PostFragment.ARG_FLOOR_AUTHOR_KEY, author);
    if (quoteText != null)
        intent.putExtra(PostFragment.ARG_QUOTE_TEXT_KEY, quoteText);
    ActivityCompat.startActivity(activity, intent, getAnimBundle(activity, true));
}
 
Example 3
Source File: NovelItemListFragment.java    From light-novel-library_Wenku8_Android with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void onItemClick(View view, final int position) {
    //Toast.makeText(getActivity(),"item click detected", Toast.LENGTH_SHORT).show();
    if(position < 0 || position >= listNovelItemAid.size()) {
        // ArrayIndexOutOfBoundsException
        Toast.makeText(getActivity(), "ArrayIndexOutOfBoundsException: " + position + " in size " + listNovelItemAid.size(), Toast.LENGTH_SHORT).show();
        return;
    }

    // go to detail activity
    Intent intent = new Intent(getActivity(), NovelInfoActivity.class);
    intent.putExtra("aid", listNovelItemAid.get(position));
    intent.putExtra("from", "list");
    intent.putExtra("title", ((TextView) view.findViewById(R.id.novel_title)).getText());

    if(Build.VERSION.SDK_INT < 21) {
        startActivity(intent);
    }
    else {
        ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(getActivity(),
                Pair.create(view.findViewById(R.id.novel_cover), "novel_cover"),
                Pair.create(view.findViewById(R.id.novel_title), "novel_title"));
        ActivityCompat.startActivity(getActivity(), intent, options.toBundle());
    }
}
 
Example 4
Source File: LoginActivity.java    From Twire with GNU General Public License v3.0 6 votes vote down vote up
private void navigateToNotificationActivity() {
    // Go to the login activity, with no transition.
    hasTransitioned = true;
    if (!isPartOfSetup) {
        if (!LoginActivity.hasLoadedFollows()) {
            this.startActivity(new Intent(getBaseContext(), ConfirmSetupActivity.class));
            this.overridePendingTransition(0, 0);
        } else {
            this.startActivity(Service.getLoggedInIntent(getBaseContext()));
            this.overridePendingTransition(0, 0);
        }

    } else {
        Intent loginActivityIntent = new Intent(getBaseContext(), NotificationActivity.class);
        loginActivityIntent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
        ActivityCompat.startActivity(this, loginActivityIntent, null);
    }
}
 
Example 5
Source File: ActivityRecreationHelper.java    From LocaleChanger with Apache License 2.0 6 votes vote down vote up
/**
 * Helper method to recreate the Activity. This method should be called after a Locale change.
 * @param activity the Activity that will be recreated
 * @param animate a flag indicating if the recreation will be animated or not
 */
public static void recreate(Activity activity, boolean animate) {
    Intent restartIntent = new Intent(activity, activity.getClass());

    Bundle extras = activity.getIntent().getExtras();
    if (extras != null) {
        restartIntent.putExtras(extras);
    }

    if (animate) {
        ActivityCompat.startActivity(
                activity,
                restartIntent,
                ActivityOptionsCompat
                        .makeCustomAnimation(activity, android.R.anim.fade_in, android.R.anim.fade_out)
                        .toBundle()
        );
    } else {
        activity.startActivity(restartIntent);
        activity.overridePendingTransition(0, 0);
    }

    activity.finish();

}
 
Example 6
Source File: ThreadImageLayout.java    From hipda with GNU General Public License v2.0 5 votes vote down vote up
private void startImageGallery() {
    if (mImages.size() > 0) {
        Intent intent = new Intent(getContext(), ImageViewerActivity.class);
        ActivityOptionsCompat options = ActivityOptionsCompat.
                makeScaleUpAnimation(mImageView, 0, 0, mImageView.getMeasuredWidth(), mImageView.getMeasuredHeight());
        intent.putExtra(ImageViewerActivity.KEY_IMAGE_INDEX, mImageIndex);
        intent.putParcelableArrayListExtra(ImageViewerActivity.KEY_IMAGES, mImages);
        ActivityCompat.startActivity(getContext(), intent, options.toBundle());
    }
}
 
Example 7
Source File: MainActivity.java    From android-player-samples with Apache License 2.0 5 votes vote down vote up
@Override
public void itemClicked(View view, Video video, int position) {
    Intent intent = new Intent(this, VideoPlayerActivity.class);
    intent.putExtra(VideoPlayerActivity.INTENT_EXTRA_VIDEO_ID, video.getId());

    Pair<View, String> imagePair = Pair
            .create(view, getString(R.string.transition_image));
    //noinspection unchecked
    ActivityOptionsCompat options = ActivityOptionsCompat
            .makeSceneTransitionAnimation(this, imagePair);
    ActivityCompat.startActivity(this, intent, options.toBundle());
}
 
Example 8
Source File: JumpUtils.java    From GSYVideoPlayer with Apache License 2.0 5 votes vote down vote up
/**
 * 跳转到无UI视频播放
 *
 * @param activity
 * @param view
 */
public static void goToPlayEmptyControlActivity(Activity activity, View view) {
    Intent intent = new Intent(activity, PlayEmptyControlActivity.class);
    intent.putExtra(PlayActivity.TRANSITION, true);
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
        Pair pair = new Pair<>(view, PlayActivity.IMG_TRANSITION);
        ActivityOptionsCompat activityOptions = ActivityOptionsCompat.makeSceneTransitionAnimation(
                activity, pair);
        ActivityCompat.startActivity(activity, intent, activityOptions.toBundle());
    } else {
        activity.startActivity(intent);
        activity.overridePendingTransition(R.anim.abc_fade_in, R.anim.abc_fade_out);
    }
}
 
Example 9
Source File: OneMovieDetailActivity.java    From CloudReader with Apache License 2.0 5 votes vote down vote up
/**
 * @param context      activity
 * @param positionData bean
 * @param imageView    imageView
 */
public static void start(Activity context, SubjectsBean positionData, ImageView imageView) {
    Intent intent = new Intent(context, OneMovieDetailActivity.class);
    intent.putExtra("bean", positionData);
    ActivityOptionsCompat options =
            ActivityOptionsCompat.makeSceneTransitionAnimation(context,
                    imageView, CommonUtils.getString(R.string.transition_movie_img));//与xml文件对应
    ActivityCompat.startActivity(context, intent, options.toBundle());
}
 
Example 10
Source File: ContactsActivity.java    From YcShareElement with Apache License 2.0 5 votes vote down vote up
private void gotoDetailActivity(Contacts contacts, final View avatarImg, final View nameTxt) {
    Intent intent = new Intent(this, DetailActivity.class);
    intent.putExtra(KEY_CONTACTS, contacts);
    Bundle bundle = YcShareElement.buildOptionsBundle(ContactsActivity.this, new IShareElements() {
        @Override
        public ShareElementInfo[] getShareElements() {
            return new ShareElementInfo[]{new ShareElementInfo(avatarImg),
                    new ShareElementInfo(nameTxt, new TextViewStateSaver())};
        }
    });
    ActivityCompat.startActivity(ContactsActivity.this, intent, bundle);
}
 
Example 11
Source File: JumpUtils.java    From GSYVideoPlayer with Apache License 2.0 5 votes vote down vote up
/**
 * 跳转列表带广告
 *
 * @param activity
 */
public static void goToADListVideoPlayer(Activity activity) {
    //Intent intent = new Intent(activity, ListADVideoActivity.class);
    Intent intent = new Intent(activity, ListADVideoActivity2.class);
    ActivityOptionsCompat activityOptions = ActivityOptionsCompat.makeSceneTransitionAnimation(activity);
    ActivityCompat.startActivity(activity, intent, activityOptions.toBundle());
}
 
Example 12
Source File: BookDetailActivity.java    From CloudReader with Apache License 2.0 5 votes vote down vote up
/**
 * @param context      activity
 * @param positionData bean
 * @param imageView    imageView
 */
public static void start(Activity context, BooksBean positionData, ImageView imageView) {
    Intent intent = new Intent(context, BookDetailActivity.class);
    intent.putExtra(EXTRA_PARAM, positionData);
    ActivityOptionsCompat options =
            ActivityOptionsCompat.makeSceneTransitionAnimation(context,
                    imageView, CommonUtils.getString(R.string.transition_book_img));//与xml文件对应
    ActivityCompat.startActivity(context, intent, options.toBundle());
}
 
Example 13
Source File: SlideShadeViewActivity.java    From CloudReader with Apache License 2.0 5 votes vote down vote up
/**
 * @param context      activity
 * @param positionData bean
 * @param imageView    imageView
 */
public static void start(Activity context, SubjectsBean positionData, ImageView imageView) {
    Intent intent = new Intent(context, SlideShadeViewActivity.class);
    intent.putExtra("bean", positionData);
    ActivityOptionsCompat options =
            ActivityOptionsCompat.makeSceneTransitionAnimation(context,
                    imageView, CommonUtils.getString(R.string.transition_movie_img));//与xml文件对应
    ActivityCompat.startActivity(context, intent, options.toBundle());
}
 
Example 14
Source File: DetailActivity.java    From wear-os-samples with Apache License 2.0 5 votes vote down vote up
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static void launch(Activity activity, String attraction, View heroView) {
    Intent intent = getLaunchIntent(activity, attraction);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(
                activity, heroView, heroView.getTransitionName());
        ActivityCompat.startActivity(activity, intent, options.toBundle());
    } else {
        activity.startActivity(intent);
    }
}
 
Example 15
Source File: FragmentUtils.java    From hipda with GNU General Public License v2.0 5 votes vote down vote up
public static void showNewPostActivity(Activity activity, int fid, String parentSessionId) {
    Intent intent = new Intent(activity, PostActivity.class);
    intent.putExtra(PostFragment.ARG_MODE_KEY, PostHelper.MODE_NEW_THREAD);
    intent.putExtra(PostFragment.ARG_FID_KEY, fid);
    intent.putExtra(PostFragment.ARG_PARENT_ID, parentSessionId);
    ActivityCompat.startActivity(activity, intent, getAnimBundle(activity, true));
}
 
Example 16
Source File: ViewImgActivity.java    From Ruisi with Apache License 2.0 5 votes vote down vote up
public static void open(Context context, String url) {
    Intent intent = new Intent(context, ViewImgActivity.class);
    intent.putExtra("url", url);
    needAnimate = true;
    ActivityOptionsCompat compat = ActivityOptionsCompat.makeCustomAnimation(context, R.anim.fade_in, R.anim.fade_out);
    ActivityCompat.startActivity(context, intent, compat.toBundle());
}
 
Example 17
Source File: JumpUtils.java    From GSYVideoPlayer with Apache License 2.0 4 votes vote down vote up
/**
 * 跳转到视频列表
 *
 * @param activity
 */
public static void goToAutoVideoPlayer(Activity activity) {
    Intent intent = new Intent(activity, AutoPlayRecyclerViewActivity.class);
    ActivityOptionsCompat activityOptions = ActivityOptionsCompat.makeSceneTransitionAnimation(activity);
    ActivityCompat.startActivity(activity, intent, activityOptions.toBundle());
}
 
Example 18
Source File: IntentActivity.java    From hipda with GNU General Public License v2.0 4 votes vote down vote up
private void handleIntent() {
    Intent intent = new Intent(this, MainFrameActivity.class);
    Intent srcIntent = getIntent();
    if (srcIntent != null) {
        intent.setAction(srcIntent.getAction());
        intent.putExtras(srcIntent);
        intent.setData(srcIntent.getData());
    }

    //to send a test notification
    boolean finished = false;
    if (BuildConfig.DEBUG) {
        if ("test_sms".equals(intent.getAction())) {
            NotiHelper.sendNotification(this, 0, 1, "绿皮怪兽", "723379", "测试短消息内容");
            finished = true;
            finish();
        } else if ("test_thread".equals(intent.getAction())) {
            NotiHelper.sendNotification(this, 1, 0, "", "", "");
            finished = true;
            finish();
        } else if ("test_all".equals(intent.getAction())) {
            NotiHelper.sendNotification(this, 1, 1, "", "", "");
            finished = true;
            finish();
        }
    }

    if (!finished) {
        boolean clearActivities = !HiApplication.isAppVisible();
        FragmentArgs args = FragmentUtils.parse(intent);
        if (!clearActivities) {
            clearActivities = args != null && args.getType() == FragmentArgs.TYPE_FORUM;
        }
        if (clearActivities) {
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
            ActivityCompat.startActivity(this, intent, null);
        } else {
            if (args != null) {
                FragmentUtils.show(this, args);
            }
        }
        finish();
    }
}
 
Example 19
Source File: JumpUtils.java    From GSYVideoPlayer with Apache License 2.0 4 votes vote down vote up
/**
 * 跳转到视频列表
 *
 * @param activity
 */
public static void goToVideoRecyclerPlayer(Activity activity) {
    Intent intent = new Intent(activity, RecyclerViewActivity.class);
    ActivityOptionsCompat activityOptions = ActivityOptionsCompat.makeSceneTransitionAnimation(activity);
    ActivityCompat.startActivity(activity, intent, activityOptions.toBundle());
}
 
Example 20
Source File: SwitchDetailActivity.java    From GSYVideoPlayer with Apache License 2.0 4 votes vote down vote up
public static void startTActivity(Activity activity, View transitionView) {
    Intent intent = new Intent(activity, SwitchDetailActivity.class);
    // 这里指定了共享的视图元素
    ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(activity, transitionView, OPTION_VIEW);
    ActivityCompat.startActivity(activity, intent, options.toBundle());
}