Question

I'm trying to get my first Android plugin to work. I've successfully registered it and able to execute it. Inside of my plugin execute action, I am trying to do the following:

ctx.setContentView(R.layout.map);

Which contains a new layout to load google maps; however, when I run this I receive the following error:

Only the original thread that created a view hierarchy can touch its views.

Any idea how I should go about doing this?

Was it helpful?

Solution

You have to run it on UI thread. You can touch UI elements only on UI thread.

runOnUiThread(runb);

private Runnable runb = new Runnable() {

     public void run(){
           //call setContentView code here. 
     }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top