07-18 16:34:05.891: E/AndroidRuntime(18396): FATAL EXCEPTION: main
07-18 16:34:05.891: E/AndroidRuntime(18396): android.util.AndroidRuntimeException:

Calling startActivity() from outside of an Activity  context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?
07-18 16:34:05.891: E/AndroidRuntime(18396):     at android.app.ContextImpl.startActivity(ContextImpl.java:971)
07-18 16:34:05.891: E/AndroidRuntime(18396):     at android.content.ContextWrapper.startActivity(ContextWrapper.java:283)
07-18 16:34:05.891: E/AndroidRuntime(18396):     at com.txrj.sms.service.ReceiveMsgService$1.handleMessage(ReceiveMsgService.java:37)
07-18 16:34:05.891: E/AndroidRuntime(18396):     at android.os.Handler.dispatchMessage(Handler.java:99)
07-18 16:34:05.891: E/AndroidRuntime(18396):     at android.os.Looper.loop(Looper.java:137)
07-18 16:34:05.891: E/AndroidRuntime(18396):     at android.app.ActivityThread.main(ActivityThread.java:4517)
07-18 16:34:05.891: E/AndroidRuntime(18396):     at java.lang.reflect.Method.invokeNative(Native Method)
07-18 16:34:05.891: E/AndroidRuntime(18396):     at java.lang.reflect.Method.invoke(Method.java:511)
07-18 16:34:05.891: E/AndroidRuntime(18396):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:993)
07-18 16:34:05.891: E/AndroidRuntime(18396):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:760)
07-18 16:34:05.891: E/AndroidRuntime(18396):     at dalvik.system.NativeStart.main(Native Method)

在ReceiveMsgService(extends Service)中,添加addFlags()方法。

Intent it = new Intent(mContext, ShowSmsActivity.class);
it.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(it);

requires the FLAG_ACTIVITY_NEW_TASK flag的更多相关文章

  1. 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 ...

  2. 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 ...

  3. 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 ...

  4. 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 ...

  5. 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 ...

  6. 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的话,需 ...

  7. 兔子--Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK

    错误原因: Activity打开别的Activity的时候会默认把新的Activity放到自己的task中,所以不用指定,可是别的地方就得指定了. 解决的方法:intent.addFlags(Inte ...

  8. Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW _TASK flag.

    在Activity中使用startActivity()方法不会有任何限制,因为Activity重载了Context的startActivity()方法.但是如果是在其他地方(如Widget或Servi ...

  9. Android 启动模式及常用的Intent的Flag

    LaunchMode 在声明Activity的xml中指定 android:launchMode="xxx" standard 标准模式.这是系统默认的模式,每次启动Activit ...

随机推荐

  1. 秒懂,Java 注解 (Annotation)你可以这样学

    转自: https://blog.csdn.net/briblue/article/details/73824058 文章开头先引入一处图片. 这处图片引自老罗的博客.为了避免不必要的麻烦,首先声明我 ...

  2. C/C++log日志库比较

    事实上,在C的世界里面没有特别好的日志函数库(就像Java里面的的log4j,或者C++的log4cxx).C程序员都喜欢用自己的轮子.printf就是个挺好的轮子,但没办法通过配置改变日志的格式或者 ...

  3. postgresql数据库用户名密码验证失败

    问题分析 (1)检查环境变量中是否指定了相关参数,比如: #export PGUSER=highgo#export PGDATABASE=highgo#export PGHOST=localhost# ...

  4. w​i​n​d​o​w​s​ ​s​e​r​v​e​r​ ​2​0​0​8​ ​r​2​ ​启​用​索​引(转)

    08r2的“windows search”服务默认是不安装的,要想启用索引执行下列步骤:        1.打开“服务器管理”——选中“角色”——右边选中“添加角色”——勾选“文件服务”.    2. ...

  5. [leetcode]Interleaving String @ Python

    原题地址:https://oj.leetcode.com/problems/interleaving-string/ 题意: Given s1, s2, s3, find whether s3 is ...

  6. @class指令的使用

    @class指令能够减少编译时间,告诉编译器“相信我,你最终能了解这个名称的类”,可以减少不得不导入的头文件的数量. sample如下: #import <Foundation/Foundati ...

  7. Kafka:ZK+Kafka+Spark Streaming集群环境搭建(二十二)Spark Streaming接收流数据及使用窗口函数

    官网文档:<http://spark.apache.org/docs/latest/streaming-programming-guide.html#a-quick-example> Sp ...

  8. 单元测试中用@Autowired 报null (空指针异常)

    原因是因为,单元测试不依赖于容器,所以自动注入也就存在问题 (单元测试中加@Autowired注解亲自测过是不行,不知道这样理解的是否正确)

  9. 在sublime text2上安装xdebug

    目录 安装Xdebug extension 设定php.ini 安装Xdebug plugin for Sublime Text2 1.安装Xdebug extension 先从安装Xdebug开始, ...

  10. 微软BI 之SSAS 系列 - 关于父子维度的设计

    除了之前的几篇文章中出现的时间维度,雪花型维度的设计之外还有一种比较特殊的维度 - 父子维度.父子维度特殊就特殊在它包含了一种基于递归关系(Recursive Relationship)的引用结构,  ...