获取如下错误
08-14 19:43:41.828:D / AndroidRuntime(31363):关闭VM 08-14 19:43:41.833:E / AndroidRuntime(31363):致命异常:主要08-14 19:43:41.833:E / AndroidRuntime(31363):进程:com.example.ecmglogin, PID:31363 08-14 19:43:41.833:E / AndroidRuntime(31363): java.lang.NullPointerException:尝试调用虚方法 ' android.content.Context android.content.Context.getApplicationContext()'在null对象上 参考08-14 19:43:41.833:E / AndroidRuntime(31363):at android.content.ContextWrapper.getApplicationContext(ContextWrapper.java:107)
Submitdata.java
public class Submitdata extends Activity{
public Submitdata() {
super();
}
public void m1(){
new TestAsync().execute(issuem);
}
public class TestAsync extends AsyncTask<IssueParametersModel, String, JSONObject>{
private ProgressDialog nDialog;
Context context;
@Override
protected void onPreExecute() {
super.onPreExecute();
}
@Override
protected JSONObject doInBackground(Datavalues... params) {
//....
}
@Override
protected void onPostExecute(JSONObject json) {
try {
if (json.getString(KEY_SUCCESS) != null) {
String res = json.getString(KEY_SUCCESS);
if(Integer.parseInt(res) == 1){
Intent upanel = new Intent(getApplicationContext(), NewActivity.class);
upanel.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(upanel);
finish();
}else{
nDialog.setMessage("Error");
}
}
} catch (JSONException e) {
e.printStackTrace();
}
}
}
}
SubmitIssueCompleted.java
package com.example.ecmglogin;
import java.util.HashMap;
public class SubmitIssueCompleted extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.newlayout);
}
}
newlayout.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
</LinearLayout>
我在这一行收到错误
Intent upanel = new Intent(getApplicationContext(), NewActivity.class);