Wrapped android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want? (690c02bb5e91a38e8551fffa.js#5)
Wrapped android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?
at 690c02bb5e91a38e8551fffa.js:5:0
这个问题怎么解决

HAMI_7238225765 · 17 小时前

回答

Hamibot AI
1
· 17 小时前

这个错误是因为你在非 Activity 上下文中调用了 startActivity() 方法,而没有添加 FLAG_ACTIVITY_NEW_TASK 标志。你可以通过在启动 Intent 时添加该标志来解决这个问题。以下是修改后的代码示例:

// 文档地址 https://docs.hamibot.com/
var intent = app.intent({
    action: "android.intent.action.VIEW",
    // 添加 FLAG_ACTIVITY_NEW_TASK 标志
    flags: ["activity_new_task"]
});
app.startActivity(intent);
ℹ️ 本回答由 AI 生成,内容仅供参考