Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW _TASK flag.
在Activity中使用startActivity()方法不会有任何限制,因为Activity重载了Context的startActivity()方法。但是如果是在其他地方(如Widget或Service、BroadcastReceiver中)使用startActivity()方法,就会报错:
android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?
这时就需要为Intent设置一个FLAG_ACTIVITY_NEW_TASK的flag:
Intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
这样就不会报错了,可以顺利的startActivity()。
Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW _TASK flag.的更多相关文章
- Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK fla
转载于 http://blog.csdn.net/wike163/article/details/6678073 从一个Activity中要通过intent调出另一个Activity的话,需 ...
- Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?
Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK fla ...
- startActivity时报错Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVI
原代码如下: Intent intent = new Intent(); intent.setClass(mContext, PhotoView.class); Bundle bundle = new ...
- android.util.AndroidRuntimeException Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want? com.uethinking.microvideo.manag
记录学习,网络摘抄 碰到这个异常其实这个上面说的很清楚,加个flag 从一个Activity中要通过intent调出另一个Activity的话,需要使用 FLAG_ACTIVITY_NEW_TASK ...
- startActivity时报错Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag
startActivity时报错Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVI ...
- Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag.
https://blog.csdn.net/watermusicyes/article/details/44963773 Context中有一个startActivity方法,Activity继承自C ...
- 兔子--Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK
错误原因: Activity打开别的Activity的时候会默认把新的Activity放到自己的task中,所以不用指定,可是别的地方就得指定了. 解决的方法:intent.addFlags(Inte ...
- Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?
安卓出现如下错误,需要增加FLAG_ACTIVITY_NEW_TASK标志 Intent intent1 = new Intent(getApplicationContext(), CameraAct ...
- Calling startActivity() from outside of an Activity
在Activity中使用startActivity()方法不会有任何限制,因为Activity重载了Context的startActivity()方法.但是如果是在其他地方(如Widget或Servi ...
随机推荐
- 电脑IP改变后oracle em无法登陆的解决办法(亲测)
以下方法为本人亲测 情况:假设电脑初次安装oracle时的ip是192.168.133.110 那么进入em的地址就是http://192.168.133.110:1158/em/console/lo ...
- Esper系列(三)Context和Group by
Context 把不同的事件按照框的规则框起来(规则框在partition by中定义),并且有可能有多个框,而框与框之间不会互相影响. 功能: 组合事件查询并进行分组,类型:Hash Context ...
- Eclipse创建Maven Web项目 + 测试覆盖率 + 常见问题(2015.07.14——湛耀)
Eclipse创建Maven web项目: 到此,并没有创建好,接下来一步步解决问题: 问题:无法创建src/main/java目录 解决: 右键项目选择[properties] 点击[OK] 问题: ...
- windows 下安装elasticsearch
1.下载 elasticsearch-2.3.3.zip 注意::elasticsearch 版本太高的话,java运行不起来 elasticsearch-1.5.2下载地址 http://downl ...
- NASA关于如何写出安全代码的10条军规
博客搬到了fresky.github.io - Dawei XU,请各位看官挪步.最新的一篇是:NASA关于如何写出安全代码的10条军规.
- PowerShell脚本传递参数
在编写PowerShell脚本的时候,可以通过给变量赋值的方法输出想要的结果,但这样的话,需要改动脚本内容.其实也可以在脚本中定义参数,然后再在执行脚本的时候对参数赋值,而无需改动脚本内容. 在Pow ...
- 每天进步一点达——MySQL——myisampack
一. 简单介绍 myisampack是一个压缩使用MyISAM引擎表的工具,通常会压缩40%~70%,当须要訪问数据.server会将所须要的信息读入到内存中.所以当訪问详细记录时,性能 ...
- iOS开发中WebP格式的64位支持处理
几个月前我们项目中添加了对webp格式的处理.期间遇到了一些问题,这是当中的一个小的记录. 官方下载地址:https://code.google.com/p/webp/downloads/list 对 ...
- Redis学习手册(虚拟内存)
一.简介: 和大多NoSQL数据库一样,Redis同样遵循了Key/Value数据存储模型.在有些情况下,Redis会将Keys/Values保存在内存中以提高数据查询和数据修改的效率,然而这样的做法 ...
- 深入理解jQuery插件开发(转)
如果你看到这篇文章,我确信你毫无疑问会认为jQuery是一个使用简便的库.jQuery可能使用起来很简单,但是它仍然有一些奇怪的地方,对它基本功能和概念不熟悉的人可能会难以掌握.但是不用担心,我下面已 ...