0
M app is working fine, then I turned on the pc and went to run it once more and this giving this error "Unfortunately app has stopped" I do not know what happened I will put the logcat here in case anyone knows what happened.
05-30 01:59:03.429 10960-10960/com.rafaeljacinto.newtest3 E/Trace: error opening trace file: No such file or directory (2)
05-30 01:59:04.049 10960-10960/com.rafaeljacinto.newtest3 E/dalvikvm: Could not find class 'android.graphics.drawable.RippleDrawable', referenced from method android.support.v7.widget.AppCompatImageHelper.hasOverlappingRendering
05-30 01:59:04.839 10960-11011/com.rafaeljacinto.newtest3 E/MainActivity: Response from url: {"dados":[{"nomeAlu":"Antonio Marins","emailAlu":"[email protected]","foneAlu":"53-99887766","codDisc":"15","nomeDisc":"Redes II","codProf":"1","nota1":"7","nota2":"8","media":"7.5","exame":"0","notafinal":"0","nomeProf":"Henry Carvalho","emailProf":"[email protected]"},{"nomeAlu":"Antonio Marins","emailAlu":"[email protected]","foneAlu":"53-99887766","codDisc":"19","nomeDisc":"Projeto Web II","codProf":"3","nota1":"7","nota2":"7","media":"7","exame":"0","notafinal":"0","nomeProf":"Everton Heckler","emailProf":"[email protected]"},{"nomeAlu":"Antonio Marins","emailAlu":"[email protected]","foneAlu":"53-99887766","codDisc":"26","nomeDisc":"Inteligencia Artificial","codProf":"4","nota1":"6","nota2":"8","media":"7","exame":"0","notafinal":"0","nomeProf":"Fabio Jose Paz","emailProf":"[email protected]"},{"nomeAlu":"Antonio Marins","emailAlu":"[email protected]","foneAlu":"53-99887766","codDisc":"28","nomeDisc":"Computador e Sociedade","codProf":"7","nota1":"10","nota2":"7","media":"8.5","exame":"0","notafinal":"0","nomeProf":"Paula Silveira","emailProf":"[email protected]"},{"nomeAlu":"Antonio Marins","emailAlu":"[email protected]","foneAlu":"53-99887766","codDisc":"28","nomeDisc":"Computador e Sociedade","codProf":"7","nota1":"6.5","nota2":"6","media":"6.25","exame":"5.75","notafinal":"6","nomeProf":"Paula Silveira","emailProf":"[email protected]"}]}
05-30 01:59:04.959 10960-10960/com.rafaeljacinto.newtest3 E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.NullPointerException
at com.rafaeljacinto.newtest3.MainActivity$GetContacts.onPostExecute(MainActivity.java:155)
at com.rafaeljacinto.newtest3.MainActivity$GetContacts.onPostExecute(MainActivity.java:55)
at android.os.AsyncTask.finish(AsyncTask.java:631)
at android.os.AsyncTask.access$600(AsyncTask.java:177)
at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:644)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4960)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:798)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:565)
at dalvik.system.NativeStart.main(Native Method)
public class Mainactivity extends Appcompatactivity {
private String TAG = MainActivity.class.getSimpleName();
private ProgressDialog progressDialog;
private ListView listView;
private TextView txtAluno;
String Aluno;
int code = 11111;
// JSON data url
//private static String Jsonurl = "http://192.168.0.12/ProjetoNewWebService/Dados.php?codAlu="+code;
ArrayList<HashMap<String, String>> contactJsonList;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
txtAluno = (TextView)findViewById(R.id.txtAluno);
contactJsonList = new ArrayList<>();
new GetContacts().execute();
}
private class GetContacts extends AsyncTask<Void, Void, Void> {
@Override
protected void onPreExecute() {
super.onPreExecute();
// Showing progress dialog
progressDialog = new ProgressDialog(MainActivity.this);
progressDialog.setMessage("Por Favor Aguarde...");
progressDialog.setCancelable(false);
progressDialog.show();
}
@Override
protected Void doInBackground(Void... arg0) {
HttpHandler httpHandler = new HttpHandler();
// request to json data url and getting response
String Jsonurl = "http://192.168.0.12/ProjetoNewWebService/Dados.php?codAlu="+code;
String jsonString = httpHandler.makeServiceCall(Jsonurl);
Log.e(TAG, "Response from url: " + jsonString);
if (jsonString != null) {
try {
JSONObject jsonObject = new JSONObject(jsonString);
// Getting JSON Array node
JSONArray contacts = jsonObject.getJSONArray("dados");
for (int i = 0; i < contacts.length(); i++) {
JSONObject c = contacts.getJSONObject(i);
Aluno = c.getString("nomeAlu");
String nomeDisc = c.getString("nomeDisc");
String nomeProf = c.getString("nomeProf");
String nota1 = c.getString("nota1");
String nota2 = c.getString("nota2");
String media = c.getString("media");
String exame = c.getString("exame");
String notaFinal = c.getString("notafinal");
// tmp hash map for single contact
HashMap<String, String> contact = new HashMap<>();
// adding each child node to HashMap key => value
contact.put("nomeAlu", Aluno);
contact.put("name", nomeDisc);
contact.put("professor", nomeProf);
contact.put("nota1", nota1);
contact.put("nota2", nota2);
contact.put("media", media);
contact.put("exame", exame);
contact.put("notafinal", notaFinal);
// adding contact to contact list
contactJsonList.add(contact);
}
} catch (final JSONException e) {
Log.e(TAG, "Json parsing error: " + e.getMessage());
runOnUiThread(new Runnable() {
@Override
public void run() {
Toast.makeText(getApplicationContext(),
"Json parsing error: " + e.getMessage(),
Toast.LENGTH_LONG)
.show();
}
});
}
} else {
Log.e(TAG, "Could not get json from server.");
runOnUiThread(new Runnable() {
@Override
public void run() {
Toast.makeText(getApplicationContext(),
"Could not get json from server.",
Toast.LENGTH_LONG)
.show();
}
});
}
return null;
}
@Override
protected void onPostExecute(Void result) {
super.onPostExecute(result);
// Dismiss the progress dialog
if (progressDialog.isShowing())
progressDialog.dismiss();
/**
* Updating parsed JSON data into ListView
* */
ListAdapter adapter = new SimpleAdapter(
MainActivity.this, contactJsonList,
R.layout.list_item, new String[]{"name", "professor","nota1","nota2","media","exame","notafinal"}, new int[]{R.id.name,
R.id.professor, R.id.nota1, R.id.nota2, R.id.media, R.id.exame, R.id.notafinal });
listView.setAdapter(adapter);
txtAluno.setText(Aluno);
}
}
}
What are lines 55 and 155?
– Daniel
the line 55 is this: private class Getcontacts extends Asynctask<Void, Void, Void> { and 155 is this: listview.setAdapter(Adapter);
– Rafael Jacinto
what I find strange is that it was working perfectly, I was emulating on my own phone, and I did not save and I went to class when I returned turned on the pc and went to continue working and ran nothing, other my app also stopped working.
– Rafael Jacinto
Thank you ramaral I found one of the errors, I do not know how but the part that connects Activity with xml had deleted. "listview = (Listview)findViewById(R.id.listview view);"
– Rafael Jacinto