java - Non-static method execute() cannot be referenced from a static context -


i don't understand why i'm receiving compile error; none of classes or methods involved here static. maybe can shed light here.

in mainactivity class have declared public class extends asynctask:

public class asyncstuff extends asynctask<string, void, string> {     ... } 

in non-activity class have public function should fire async task:

public class util {     public void executeasyncmethod(){         mainactivity.asyncstuff.execute(new string[]{"test" }); // error here     } } 

i have tried instantiate object of mainactivity.asyncstuff class , execute execute() method, doesn't work either since it's not in enclosing class. can't move somewhere else because need update ui needs stay in mainactivity class.

anyhow, need figure out why executeasyncmethod() method doesn't compile.

thank you!!

define this:

public static class asyncstuff extends asynctask<string, void, string> {     ... } 

and run this:

public class util {     public void executeasyncmethod(){         new asyncstuff().execute(new string[]{"test" });     } } 

Comments

Popular posts from this blog

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

php - Zend Framework / Skeleton-Application / Composer install issue -