• requires the FLAG_ACTIVITY_NEW_TASK flag


    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);

  • 相关阅读:
    drf-通过drf-extensions扩展来实现缓存
    social_django第三方登录 没有token解决方法
    python-项目日志配置使用
    drf-支付宝支付
    git 相关命令
    django第三方登录与邮箱验证流程
    django项目部署
    数组中的方法
    滚动到页面底部,更新数据
    图片卷边
  • 原文地址:https://www.cnblogs.com/fengzhblog/p/3198979.html
Copyright © 2020-2023  润新知