gpt4 book ai didi

java - 如何获取 Adob​​e AIR Native Extension 中的上下文?

转载 作者:行者123 更新时间:2023-12-01 05:05:29 25 4
gpt4 key购买 nike

在下面的代码行中...

ProgressDialog progressDialog = ProgressDialog.show(getBaseContext(), "LOADING_TITLE", "LOADING_MESSAGE");

代替 getBaseContext() 我尝试过...

getApplicationContext() // returns "java.lang.NullPointerException"
getBaseContext() // returns "java.lang.NullPointerException"
(NativeActivity)getApplicationContext()
this // returns "The method show(Context, CharSequence, CharSequence) in the Type ProgressDialog is not applicable for the arguments(new Runnable(){}, String, String)"
NativeActivity.this // returns "java.lang.NullPointerException"
NativeActivity.this.getApplicationContext() // returns "java.lang.NullPointerException"
NativeExtension.context.getActivity().getBaseContext() // returns “android.view.WindowManager$BadTokenException: Unable to add window — token null is not for an application”
myActivity.getApplicationContext() // returns “android.view.WindowManager$BadTokenException: Unable to add window — token null is not for an application”
myActivity.getBaseContext() // returns “android.view.WindowManager$BadTokenException: Unable to add window — token null is not for an application”

等等。我不知道为什么它不起作用。在扩展 FREContext 的 NativeExtensionContext 中,我使用 getActivity() 将 Activity 传递给 NativeActivity。一切正常,但当我尝试获取对 Context 的引用时,出现“NullpointerException”或“android.view.WindowManager$BadTokenException:无法添加窗口 - token null 不适用于应用程序”。

任何有使用 Adob​​e AIR Native Extensions 和/或 Android Java 经验的人都会很棒。

最佳答案

NativeExtension.context.getActivity().getBaseContext() // this should work.

我唯一能想到的是确保您是在 Activity 内部工作。也就是说,您从 FREFunction 实例初始化的 Activity。

关于java - 如何获取 Adob​​e AIR Native Extension 中的上下文?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12754357/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com