本文整理汇总了Java中android.support.v4.app.ActivityCompat.startActivity方法的典型用法代码示例。如果您正苦于以下问题:Java ActivityCompat.startActivity方法的具体用法?Java ActivityCompat.startActivity怎么用?Java ActivityCompat.startActivity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v4.app.ActivityCompat
的用法示例。
在下文中一共展示了ActivityCompat.startActivity方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onNavigationItemSelected
import android.support.v4.app.ActivityCompat; //导入方法依赖的package包/类
@Override
public boolean onNavigationItemSelected(final MenuItem menuItem) {
if (menuItem.getItemId() != R.id.navigation_item_settings) {
if (mSelectedNavigationPosition != menuItem.getOrder() ||
mSelectedAccountId != mAccounts.get(0).id()) {
mPager.post(new Runnable() {
@Override
public void run() {
mPager.setCurrentItem(menuItem.getOrder(), false);
}
});
}
selectNavigation(menuItem);
} else {
ActivityCompat.startActivity(this, new Intent(this, SettingsActivity.class), null);
}
return true;
}
示例2: launchDetail
import android.support.v4.app.ActivityCompat; //导入方法依赖的package包/类
public static void launchDetail(MainActivity fromActivity, View fromView, Thing item, View backgroundView) {
ViewCompat.setTransitionName(fromView, "detail_element");
ViewCompat.setTransitionName(fromActivity.findViewById(R.id.fab), "fab");
ActivityOptionsCompat options =
TransitionHelper.makeOptionsCompat(
fromActivity,
Pair.create(fromView, "detail_element"),
Pair.create(fromActivity.findViewById(R.id.fab), "fab")
);
Intent intent = new Intent(fromActivity, MainActivity.class);
intent.putExtra("item_text", item.text);
intent.putExtra("fragment_resource_id", R.layout.fragment_thing_detail);
if (backgroundView != null) BitmapUtil.storeBitmapInIntent(BitmapUtil.createBitmap(backgroundView), intent);
ActivityCompat.startActivity(fromActivity, intent, options.toBundle());
fromActivity.overridePendingTransition(R.anim.slide_up, R.anim.scale_down);
}
示例3: itemClicked
import android.support.v4.app.ActivityCompat; //导入方法依赖的package包/类
@Override
public void itemClicked(View view, MediaInfo item, int position) {
if (view instanceof ImageButton) {
Utils.showQueuePopup(getActivity(), view, item);
} else {
String transitionName = getString(R.string.transition_image);
VideoListAdapter.ViewHolder viewHolder =
(VideoListAdapter.ViewHolder) mRecyclerView.findViewHolderForPosition(position);
Pair<View, String> imagePair = Pair
.create((View) viewHolder.getImageView(), transitionName);
ActivityOptionsCompat options = ActivityOptionsCompat
.makeSceneTransitionAnimation(getActivity(), imagePair);
Intent intent = new Intent(getActivity(), LocalPlayerActivity.class);
intent.putExtra("media", item);
intent.putExtra("shouldStart", false);
ActivityCompat.startActivity(getActivity(), intent, options.toBundle());
}
}
示例4: onBackPressed
import android.support.v4.app.ActivityCompat; //导入方法依赖的package包/类
@Override
public void onBackPressed() {
if (getContentResolver().query(AccountContract.CONTENT_URI, null, null, null, null).getCount() > 0) {
NavigationUtils.changeDefaultActivityToSignIn(getApplicationContext(), false);
ActivityCompat.startActivity(SignInActivity.this,
new Intent(SignInActivity.this, HomeActivity.class), null);
}
super.onBackPressed();
}
示例5: start
import android.support.v4.app.ActivityCompat; //导入方法依赖的package包/类
/**
* @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());
}
示例6: launch
import android.support.v4.app.ActivityCompat; //导入方法依赖的package包/类
public void launch(Intent intent) {
intent.putExtras(createBundle());
if (Build.VERSION.SDK_INT >= 16) {
ActivityCompat.startActivity(activity, intent, createOptions());
return;
}
activity.startActivity(intent);
activity.overridePendingTransition(0, 0);
}
示例7: onViewClicked
import android.support.v4.app.ActivityCompat; //导入方法依赖的package包/类
@OnClick({R.id.main_imgPicture, R.id.main_btnPicImage, R.id.main_btnCropImage})
public void onViewClicked(View view) {
switch (view.getId()) {
case R.id.main_imgPicture:
if (selectedFilePath != null && selectedFilePath.length() > 0) {
// Construct an Intent as normal
Intent intent = new Intent(this, PicImageDetailActivity.class);
intent.putExtra(PicImageDetailActivity.EXTRA_PARAM_ID, selectedFilePath);
// BEGIN_INCLUDE(start_activity)
/**
* Now create an {@link android.app.ActivityOptions} instance using the
* {@link ActivityOptionsCompat#makeSceneTransitionAnimation(Activity, Pair[])} factory
* method.
*/
ActivityOptionsCompat activityOptions = ActivityOptionsCompat.makeSceneTransitionAnimation(this,
// Now we provide a list of Pair items which contain the view we can transitioning
// from, and the name of the view it is transitioning to, in the launched activity
new Pair<View, String>(view.findViewById(R.id.main_imgPicture), PicImageDetailActivity.VIEW_NAME_HEADER_IMAGE));
// Now we can start the Activity, providing the activity options as a bundle
ActivityCompat.startActivity(this, intent, activityOptions.toBundle());
}
break;
case R.id.main_btnPicImage:
openImagePickerDialog(this);
break;
case R.id.main_btnCropImage:
if (selectedFilePath != null && selectedFilePath.length() > 0) {
try {
cropImage(selectedFilePath, getString(R.string.app_name), 1, 1, 200, 200);
} catch (IOException e) {
Toast.makeText(mContext, e.getMessage().toString().trim(), Toast.LENGTH_LONG).show();
e.printStackTrace();
}
} else {
Toast.makeText(mContext, "Please select image first.", Toast.LENGTH_LONG).show();
}
break;
}
}
示例8: startPhotoActivity
import android.support.v4.app.ActivityCompat; //导入方法依赖的package包/类
private void startPhotoActivity(){
Intent intent = PhotoActivity.getIntent(MainActivity.this, word.fenxiang_img, word.caption + word.dateline);
ActivityOptionsCompat optionsCompat = ActivityOptionsCompat
.makeSceneTransitionAnimation(MainActivity.this, bgImg, PhotoActivity.KEY_PHOTO);
try {
ActivityCompat.startActivity(MainActivity.this, intent, optionsCompat.toBundle());
}catch (IllegalArgumentException e){
e.printStackTrace();
startActivity(intent);
}
}
示例9: launch
import android.support.v4.app.ActivityCompat; //导入方法依赖的package包/类
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);
}
}
}
示例10: onClick
import android.support.v4.app.ActivityCompat; //导入方法依赖的package包/类
@Override
public void onClick(View v) {
final String url = String.format("https://twitter.com/%s/status/%d",
tweet.quotedScreenName(), tweet.quotedId());
final Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
ActivityCompat.startActivity(mActivity, intent, null);
}
示例11: onCreate
import android.support.v4.app.ActivityCompat; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
if (Utils.hasLollipop()) requestWindowFeature(Window.FEATURE_CONTENT_TRANSITIONS);
super.onCreate(savedInstanceState);
if (Utils.hasLollipop()) {
getWindow().setExitTransition(new Fade());
}
Intent intent = new Intent(this, MainActivity.class);
ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(this);
ActivityCompat.startActivity(this, intent, options.toBundle());
ActivityCompat.finishAfterTransition(this);
}
示例12: goToPreviewVideo
import android.support.v4.app.ActivityCompat; //导入方法依赖的package包/类
public static void goToPreviewVideo(AppCompatActivity activity, String url, SearchDetail.Doc doc) {
ActivityOptionsCompat aoc;
aoc = ActivityOptionsCompat.makeBasic();
Intent intent = new Intent(activity, VideoPreviewActivity.class);
Bundle bundle = new Bundle();
bundle.putString(C.Extras.VIDEO_URL, url);
bundle.putParcelable(C.Extras.DOC, doc);
intent.putExtras(bundle);
ActivityCompat.startActivity(activity, intent, aoc.toBundle());
}
示例13: onPokeClicked
import android.support.v4.app.ActivityCompat; //导入方法依赖的package包/类
@OnClick(R.id.imPoke)
void onPokeClicked() {
Pokemon pokemon = mCurPokeQuiz.getAnswer();
Intent intent = PokeDetailActivity.createIntent(this, pokemon, mImAnswerPoke.getDrawable());
Pair<View, String> pairIm = Pair.create((View) mImAnswerPoke, getString(R.string
.transition_name_im_poke));
Pair<View, String> pairTv = Pair.create((View) mTvAnswerName, getString(R
.string.transition_name_tv_poke_name));
ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(this,
pairIm, pairTv);
ActivityCompat.startActivity(this, intent, options.toBundle());
}
示例14: start
import android.support.v4.app.ActivityCompat; //导入方法依赖的package包/类
public static void start(Activity activity, Account account, String query) {
Intent intent = new Intent(activity, SearchActivity.class);
intent.putExtra("account", account);
intent.putExtra("query", query);
ActivityCompat.startActivity(activity, intent, null);
}
示例15: goToAlbum
import android.support.v4.app.ActivityCompat; //导入方法依赖的package包/类
public static void goToAlbum(@NonNull Activity activity, int i, @Nullable Pair... pairArr) {
Intent intent = new Intent(activity, AlbumDetailsActivity.class);
intent.putExtra(AlbumDetailsActivity.EXTRA_ALBUM_ID, i);
ActivityCompat.startActivity(activity, intent, ActivityOptionsCompat.makeSceneTransitionAnimation(activity, pairArr).toBundle());
}