android.content.Intent.addFlags()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(7.4k)|赞(0)|评价(0)|浏览(245)

本文整理了Java中android.content.Intent.addFlags()方法的一些代码示例,展示了Intent.addFlags()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Intent.addFlags()方法的具体详情如下:
包路径:android.content.Intent
类名称:Intent
方法名:addFlags

Intent.addFlags介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

...
Intent i = new Intent(this, Wakeup.class);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
...

代码示例来源:origin: TeamNewPipe/NewPipe

public static void openMainActivity(Context context) {
  Intent mIntent = new Intent(context, MainActivity.class);
  mIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  mIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
  context.startActivity(mIntent);
}

代码示例来源:origin: k9mail/k-9

public static Intent shortcutIntent(Context context, String specialFolder) {
  Intent intent = new Intent(context, MessageList.class);
  intent.setAction(ACTION_SHORTCUT);
  intent.putExtra(EXTRA_SPECIAL_FOLDER, specialFolder);
  intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
  intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  return intent;
}

代码示例来源:origin: HotBitmapGG/bilibili-android-client

public static void launch(Activity activity, int aid, String imgUrl) {
  Intent intent = new Intent(activity, VideoDetailsActivity.class);
  intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  intent.putExtra(ConstantUtil.EXTRA_AV, aid);
  intent.putExtra(ConstantUtil.EXTRA_IMG_URL, imgUrl);
  activity.startActivity(intent);
}

代码示例来源:origin: stackoverflow.com

public static void startInstalledAppDetailsActivity(final Activity context) {
  if (context == null) {
    return;
  }
  final Intent i = new Intent();
  i.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
  i.addCategory(Intent.CATEGORY_DEFAULT);
  i.setData(Uri.parse("package:" + context.getPackageName()));
  i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  i.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
  i.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
  context.startActivity(i);
}

代码示例来源:origin: julian-klode/dns66

public void performFileSearch() {
  Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
  intent.addCategory(Intent.CATEGORY_OPENABLE);
  intent.setType("*/*");
  intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
  intent.addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION);
  startActivityForResult(intent, READ_REQUEST_CODE);
}

代码示例来源:origin: stackoverflow.com

public void startNewActivity(Context context, String packageName) {
  Intent intent = context.getPackageManager().getLaunchIntentForPackage(packageName);
  if (intent == null) {
    // Bring user to the market or let them choose an app?
    intent = new Intent(Intent.ACTION_VIEW);
    intent.setData(Uri.parse("market://details?id=" + packageName));
  }
  intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  context.startActivity(intent);
}

代码示例来源:origin: stackoverflow.com

public static void triggerRebirth(Context context, Intent nextIntent) {
  Intent intent = new Intent(context, YourClass.class);
  intent.addFlags(FLAG_ACTIVITY_NEW_TASK);
  intent.putExtra(KEY_RESTART_INTENT, nextIntent);
  context.startActivity(intent);
  if (context instanceof Activity) {
   ((Activity) context).finish();
  }

  Runtime.getRuntime().exit(0);
}

代码示例来源:origin: stackoverflow.com

Intent intent = new Intent(Intent.ACTION_SENDTO); // it's not ACTION_SEND
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_SUBJECT, "Subject of email");
intent.putExtra(Intent.EXTRA_TEXT, "Body of email");
intent.setData(Uri.parse("mailto:default@recipient.com")); // or just "mailto:" for blank
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // this will make such that when user returns to your app, your app is displayed, instead of the email app.
startActivity(intent);

代码示例来源:origin: stackoverflow.com

Intent intent2open = new Intent(context, YourActivity.class);
intent2open.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent2open.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
String name = "KEY";
String value = "String you want to pass";
intent2open.putExtra(name, value);
context.startActivity(intent2open);

代码示例来源:origin: stackoverflow.com

final Intent notificationIntent = new Intent(context, YourActivity.class);
notificationIntent.setAction(Intent.ACTION_MAIN);
notificationIntent.addCategory(Intent.CATEGORY_LAUNCHER);
notificationIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

代码示例来源:origin: crazycodeboy/TakePhoto

/**
 * 获取拍照的Intent
 *
 * @return
 */
public static Intent getCaptureIntent(Uri outPutUri) {
  Intent intent = new Intent();
  intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
  intent.setAction(MediaStore.ACTION_IMAGE_CAPTURE);//设置Action为拍照
  intent.putExtra(MediaStore.EXTRA_OUTPUT, outPutUri);//将拍取的照片保存到指定URI
  return intent;
}

代码示例来源:origin: stackoverflow.com

Intent dialogIntent = new Intent(this, MyActivity.class);
dialogIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(dialogIntent);

代码示例来源:origin: HotBitmapGG/bilibili-android-client

public static void launch(Activity activity, String name, int mid, String avatar_url) {
  Intent intent = new Intent(activity, UserInfoDetailsActivity.class);
  intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  intent.putExtra(EXTRA_USER_NAME, name);
  intent.putExtra(EXTRA_MID, mid);
  intent.putExtra(EXTRA_AVATAR_URL, avatar_url);
  activity.startActivity(intent);
}

代码示例来源:origin: commonsguy/cw-omnibus

public static void loadDocument(Context ctxt, Uri document) {
 Intent i=new Intent(ctxt, DocumentStorageService.class)
  .setAction(Intent.ACTION_OPEN_DOCUMENT)
  .addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
  .setData(document);
 ctxt.startService(i);
}

代码示例来源:origin: commonsguy/cw-omnibus

@Override
public void onClick(View v) {
 Intent i=
  new Intent(title.getContext(), VideoPlayerActivity.class)
   .setData(videoUri)
   .addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
 title.getContext().startActivity(i);
}

代码示例来源:origin: iTXTech/Daedalus

@TargetApi(Build.VERSION_CODES.KITKAT)
private void performFileSearch() {
  Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
  intent.addCategory(Intent.CATEGORY_OPENABLE);
  intent.setType("*/*");
  intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
  intent.addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION);
  startActivityForResult(intent, READ_REQUEST_CODE);
}

代码示例来源:origin: stackoverflow.com

public void startNewActivity(Context context, String packageName) {
  Intent intent = context.getPackageManager().getLaunchIntentForPackage(packageName);
  if (intent != null) {
    // We found the activity now start the activity
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(intent);
  } else {
    // Bring user to the market or let them choose an app?
    intent = new Intent(Intent.ACTION_VIEW);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.setData(Uri.parse("market://details?id=" + packageName));
    context.startActivity(intent);
  }
}

代码示例来源:origin: stackoverflow.com

Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setType("image/*");
Uri fileUri = FileProvider.getUriForFile(mContext, "com.myfileprovider", new File(mFilename));
shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
shareIntent.putExtra(Intent.EXTRA_STREAM, fileUri);
mContext.startActivity(Intent.createChooser(shareIntent, mChooserTitle));

代码示例来源:origin: stackoverflow.com

Intent notificationIntent = new Intent(getApplicationContext(), viewmessage.class);
 notificationIntent.putExtra("NotificationMessage", notificationMessage);
 notificationIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP);
 PendingIntent pendingNotificationIntent = PendingIntent.getActivity(getApplicationContext(),notificationIndex,notificationIntent,PendingIntent.FLAG_UPDATE_CURRENT);
 notification.flags |= Notification.FLAG_AUTO_CANCEL;
 notification.setLatestEventInfo(getApplicationContext(), notificationTitle, notificationMessage, pendingNotificationIntent);

相关文章

Intent类方法