android - 对于 startActivity,ActivityManager Log 正在显示,但没有调用 Activity 的 onCreate

标签 android kotlin android-service android-logcat android-wear-2.0

我正在尝试从无障碍服务开始一项 Activity 。 所以在我的应用程序中,这是唯一的 Activity 。 当我调用 startActivity() , 打印了以下日志,但不会调用 Activity (名为 WifiAlertDialouge)的 onCreate(savedInstanceState: Bundle?) .

I/ActivityManager: START u0 {flg=0x50000000 cmp=com.estimote.indoorapp/.WifiAlertDialouge} from uid 10065 on display 0

上面的日志是什么意思?这是否意味着 Activity 开始了? 猜猜为什么我的 Activity 是 onCreate没有被调用?

谢谢。

最佳答案

如果您尝试从服务启动 Activity,您应该添加 FLAG_ACTIVITY_NEW_TASK 标志

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

关于android - 对于 startActivity,ActivityManager Log 正在显示,但没有调用 Activity 的 onCreate,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50162988/

相关文章:

android - Android 模拟器是否支持 OpenGL ES 2.0?

android - 如何使用自定义适配器动态更新 ListView?

android - Android Kotlin 代码运行时出现 "Accessing hidden field"错误

java - 可以告诉 'groovyc' 只生成 stub 吗? (Java+Groovy+Kotlin联合编译)

android - 从服务中的 Activity 更改窗口参数

Android 服务与多个 Activity 交互

android - 如何在 Android 中使用 ScriptIntrinsicConvolve5x5?

android - "Error inflating class fragment"尝试将 map v2 fragment 添加到 activity_main

android - 如何将项目传递给 ViewHolder?

android - 如何访问 MediaBrowserServiceCompat 服务实例?