Tuesday, 15 April 2014

android - error with GetApplicationContext() -



android - error with GetApplicationContext() -

i'm trying create classes in order have cleaner code i've occurred in error: have next class:

import java.io.ioexception; import android.content.context; import android.os.asynctask; import android.util.log; import com.metaio.sdk.metaiodebug; import com.metaio.tools.io.assetsmanager; public class assetsextracter extends asynctask<integer, integer, boolean> { @override protected boolean doinbackground(integer... params) { seek { assetsmanager.extractallassets(getapplicationcontext(), true); } grab (ioexception e) { metaiodebug.printstacktrace(log.error, e); homecoming false; } homecoming true; } }

in main activity phone call assetsextracter class this:

// extract assets assetsextracter mtask = new assetsextracter(); mtask.execute(0);

but error on getapplicationcontext() on assetsextracter class. should related context how should edit class in order prepare this?

change code this. pass context in constructor

public class assetsextracter extends asynctask<integer, integer, boolean>{ context context; public assetsextracter(context context){ this.context = context; } @override protected boolean doinbackground(integer... params) { seek { assetsmanager.extractallassets(context, true); } grab (ioexception e) { metaiodebug.printstacktrace(log.error, e); homecoming false; } homecoming true; }

}

android eclipse

No comments:

Post a Comment