-1
我有一個class
B和有我想調用一個方法getSomething(type, option)
,屬於class
的方法的延伸AsyncTask
和裏面class
C.機器人:調用屬於的AsyncTask類
class
我C是:
public class C extends BaseActivity{
(...)
public class A extends AsyncTask<String, Void, String> {
(...)
public String doInBackground(String... params) {
(...)
}
public String getSomething(String type, String option){
(...)
}
protected void onPreExecute() {
(...)
}
protected void onPostExecute(String result){
(...)
}
(...)
}
我想在B類調用的方法getSomething(...)
:
public class B{
(...)
public void methodInClassB(String type, String option){
String sentence = new C().new A().getSomething(type,option);
}
我也沒能成功的:
new C().new A().execute(type,option);
我不能叫getSomething()
方法,因爲我得到以下異常:
java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.pm.ApplicationInfo android.content.Context.getApplicationInfo()' on a null object reference
每次被B.
稱爲
class
時間
有人可以幫助我嗎?我如何從B類調用方法getSomething(...)?
我已經爲你編輯了這篇文章,瞭解我是如何獲得B類的。在類B中,我有一個方法,並且在該方法中,我想從AsyncTask()調用getSomething()。 – porthfind