私はアンドロイドが初めてで、このコードに問題があります。JSON 文字列を取得し、別のアクティビティを開始して ListView として表示しようとしています。
活動を開始できません。The constructor Intent(RequestJsonString, Class) is undefinedとThe constructor Intent(RequestJsonString, Class) is undefinedと書かれています。
ここ:
Intent intent = new Intent(RequestJsonString.this,DisplayResults.class);
と ここ:
RequestJsonString.this.startActivity(intent);
私はstackoverflowでこれに関する多くの投稿を読みactivity
、 、context
およびthis
. しかし、まだ私はそれを正しく理解していません。私は何かが欠けているべきだと思います。どんな助けでも大歓迎です。
public class RequestJsonString extends AsyncTask<String, Void, JSONObject> {
@Override
protected JSONObject doInBackground(String... urls) {
// Code HTTP Get Request and get JSONObject
return jsonObject;
}
protected void onPostExecute(JSONObject jsonObj){
try {
Intent intent = new Intent(RequestJsonString.this,DisplayResults.class);
intent.putExtra("JSON_Object", jsonObj.toString());
RequestJsonString.this.startActivity(intent);
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Log.v("Json_OutPut","Done");
}
}