`

android intent中的flag

 
阅读更多

Intent中flags的那些事儿

 

转载:http://blog.csdn.net/berber78/article/details/7278408

 

 

Intent intent = new Intent();

intent.setClass(context.getApplicationContext(), MainActivity.class);

 

intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK |Intent.FLAG_ACTIVITY_CLEAR_TOP);

移除其他Activity,只保留/创建MainActivity

分享到:
评论

相关推荐

    android Intent.FLAG大全

    android Intent.FLAG大全

    Android中调用系统所装的软件打开文件

    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); //设置intent的Action属性 intent.setAction(Intent.ACTION_VIEW); //获取文件file的MIME类型 String type = getMIMEType(file); //设置intent的data和Type...

    AppInstall.rar

    把其它app 放在assets/ 下面打包, 通过系统调用安装这个app //申请安装未知应用权限 ... intent.setDataAndType(uri, "application/vnd.android.package-archive"); Log.i(TAG,"btnAppInstallClick uri="+uri);

    打开附件.java

    Intent intent = new Intent("android.intent.action.VIEW"); intent.addCategory("android.intent.category.DEFAULT"); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); Uri uri = Uri.fromFile(new File...

    Android代码-Android-Ultra-Photo-Selector

    Android Ultra Photo Selector Select images from Android devices made easy :-) In preview you can also Zoom images. You can select images from different albums.... intent.addFlags(Intent.FLAG_

    android创建桌面快捷方式

    shortcutIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); shortcut.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent); // 快捷图标 ShortcutIconResource iconRes = Intent....

    android-将内容分享到自己的app

    像qq,微信那样 调用代码Intent intent=new Intent(Intent.ACTION_SEND);... intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(Intent.createChooser(intent, "请选择")); 可以选择分享到自己的app

    兼容android7.0拍照或相册选择照片并裁剪

    intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); intent.setDataAndType(getImageContentUri(this,file), "image/*");//自己使用Content Uri替换File Uri }else{ intent.setDataAndType(Uri.fromFile...

    Android 调用第三方导航(百度、高德、腾讯)以及坐标转换

    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); getContext().startActivity(intent); //启动调用 } catch (URISyntaxException e) { Log.e("intent", e.getMessage()); } } else {//未安装 //market为...

    Android 自动启动服务的示例.rar

    Android 自动启动服务,也可以手动启动或停止指定的服务,这只是一个例子,演示在android环境下,如何在后台自动运行Service。  public void onDestroy() {//重写的onDestroy方法   myThread.flag = false;//停止...

    Android 应用中跳转到应用市场评分示例

    在开发Android App过程中,经常会遇见这样的功能。从当前的app跳转到一个应用商店并且跳转到自己app的详情页面,让用户给自己的App进行评分、评价,从而提高自己App的排名。下面介绍三种方法实现该功能。 方法一:...

    新版Android开发教程.rar

    ----------------------------------- Android 编程基础 1 封面----------------------------------- Android 编程基础 2 开放手机联盟 --Open --Open --Open --Open Handset Handset Handset Handset Alliance ...

    Android自主学习项目报告(一).doc

    解决方案:不要在让transactions在其他的Activity生命周期函数提交,如onActivi tyResult()、onStart()和onResume() 自己在学习过程中总结的知识点 (3)Android体系结构和Android项目目录 Android是基于Linux内核...

    Android圆形头像拍照后“无法加载此图片”的问题解决方法(适配Android7.0)

    intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION); 主要代码如下:   public static final String PHOTO_IMAGE_FILE_NAME = fileImg.jpg;

    Android 开机自启

    static final String ACTION = "android.intent.action.BOOT_COMPLETED"; @Override public void onReceive(Context context, Intent intent) { if(intent.getAction().equals(ACTION)){ Intent ...

    android开发使用例子

    在进行Android开发的过程中,免不了,要开发TCP/UDP通讯的程序,下面这两段代码,分别介绍了TCP/UCP通过的一个实例: 代码一: private void tcpdata() { try { Socket s = new Socket("192.168.0.25", 65500); ...

    Android应用开发中模拟按下HOME键的效果(实现代码)

    下面提供代码示例,请参考。 代码如下:public boolean onKeyDown(int keyCode, KeyEvent event) { if ... intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.addCategory(Intent.CATEGORY_HOME); startA

    Android 两种启动模式的实例详解

    Intent的FLAG_ACTIVITY_CLEAR_TOP和FLAG_ACTIVITY_REORDER_TO_FRONT Activity的两种启动模式:FLAG_ACTIVITY_CLEAR_TOP和FLAG_ACTIVITY_REORDER_TO_FRONT 1. 如果已经启动了四个Activity:A,B,C和D。在D Activity...

    Android GPS定位

    i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startService(i);  tv1 = (TextView) this.findViewById(R.id.tv1); openGPSSettings();// String ip=GetHostIp();// tv1.setText(ip);// Log.i("hello", "ip is...

Global site tag (gtag.js) - Google Analytics