Error calling method on NPObject! in Android 2.2

后端 未结 6 644
轻奢々
轻奢々 2021-01-11 16:45

I\'m using addJavascriptInterface within my Android application to allow JavaScript to invoke functions I\'ve created in my native Java application.

This worked well

6条回答
  •  我在风中等你
    2021-01-11 17:18

    OK, I have same problem as well, just in today.

    What I did is putting code in UI Thread, like code below :

    /**
     * 給網頁Javascript呼叫的method
     * Method for Javascript in HTML
     * @param java.lang.String - Playlist ID
     */
    public int callListByPID(final String pId)
    {
      Log.i(Constants.TAG, "PAD Playlist ID from HTML: "+pId);
    
      runOnUiThread(new Runnable()
      {
        public void run()
        {
          // Put your code here...
        }
      });
    
      return 1;
    }
    

    This solved my problem, and hope it can help some body... :-)

提交回复
热议问题