1

次のコード行では...

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 に渡しています。すべて正常に動作しますが、Context への参照を取得しようとすると、「Nullpointerexception」または「android.view.WindowManager$BadTokenException: Unable to add window — token null is not for an application」が表示されます。

Adobe AIR Native Extensions や Android Java の使用経験がある方なら誰でも歓迎します。

4

2 に答える 2

0

これをクラスに追加します。

public static FREContext myANEContext=null;

....
....

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

FREFunctionクラスを使用する前に、から値を渡すことを忘れないでください。

  public class MyANEfunction implements FREFunction{


    @Override
      public FREObject call(final FREContext context, FREObject[] args) {
      try{
            myANEClass.myANEContext=context;

         ....
于 2014-01-18T21:53:22.987 に答える
0
NativeExtension.context.getActivity().getBaseContext() // this should work.

私が考えることができる唯一のことは、アクティビティ内から作業していることを確認することです。つまり、FREFunction インスタンスから初期化するアクティビティです。

于 2012-11-02T16:50:46.533 に答える