在以下代码行中...
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() 将活动传递给 NativeActivity。一切正常,但是当我尝试获取对上下文的引用时,我得到一个“Nullpointerexception”或“android.view.WindowManager$BadTokenException: Unable to add window - token null is not for an application”。
任何有使用 Adobe AIR Native Extensions 和/或 Android Java 经验的人都会很棒。