Note that there are some explanatory texts on larger screens.

plurals
  1. POApplication stopped working after some time
    primarykey
    data
    text
    <p>I'm experiencing weird problem. I'm new to android, I've coded some random app that sends some data to my external database. Everything was working properly and few days ago it stopped. It wouldn't be anything special but...I've done 0 changes, I wasn't touching the code. It just stopped working for no reason. Here's a part of my (i know, bad) code. I'm getting <code>NullPointerEx</code> on <strong>client.execute(hp)</strong> line (if I understood logcat well).</p> <pre><code>LocationManager lm = (LocationManager)getSystemService(Context.LOCATION_SERVICE); Location loc = lm.getLastKnownLocation(LocationManager.GPS_PROVIDER); double latitude = loc.getLatitude(); double longitude = loc.getLongitude(); Intent intent = new Intent(this, LoggedInSys.class); EditText editText = (EditText) findViewById(R.id.editTextUsername); String username = editText.getText().toString(); try { DefaultHttpClient client = new DefaultHttpClient(); HttpPost hp = new HttpPost("LINK TO MY PHP SCRIPT"); List&lt;NameValuePair&gt; params = new ArrayList&lt;NameValuePair&gt;(); params.add(new BasicNameValuePair("lat", String.valueOf(latitude))); params.add(new BasicNameValuePair("lon", String.valueOf(longitude))); params.add(new BasicNameValuePair("name", username)); hp.setEntity(new UrlEncodedFormEntity(params)); HttpResponse response = client.execute(hp); HttpEntity entity = response.getEntity(); isr = entity.getContent(); }catch(Exception ex){ ex.printStackTrace(); } BufferedReader reader = new BufferedReader(new InputStreamReader(isr)); StringBuilder sb = new StringBuilder(); String line; try { while((line=reader.readLine())!=null){ sb.append(line); } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { isr.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } result = sb.toString(); intent.putExtra(EXTRA_LATITUDE, String.valueOf(latitude)); intent.putExtra(EXTRA_LONGITUDE, String.valueOf(longitude)); intent.putExtra(EXTRA_USERNAME, username); intent.putExtra(EXTRA_DEVID, result); startActivity(intent); </code></pre> <p>It's really strange, how could it stop working when I didn't change anything? Any suggestions please?</p> <p><strong>Log:</strong></p> <pre><code> 11-13 10:42:52.689: D/AndroidRuntime(26259): Shutting down VM 11-13 10:42:52.689: W/dalvikvm(26259): threadid=1: thread exiting with uncaught exception (group=0x2aac8578) 11-13 10:42:52.689: E/AndroidRuntime(26259): FATAL EXCEPTION: main 11-13 10:42:52.689: E/AndroidRuntime(26259): java.lang.IllegalStateException: Could not execute method of the activity 11-13 10:42:52.689: E/AndroidRuntime(26259): at android.view.View$1.onClick(View.java:2168) 11-13 10:42:52.689: E/AndroidRuntime(26259): at android.view.View.performClick(View.java:2552) 11-13 10:42:52.689: E/AndroidRuntime(26259): at android.view.View$PerformClick.run(View.java:9229) 11-13 10:42:52.689: E/AndroidRuntime(26259): at android.os.Handler.handleCallback(Handler.java:587) 11-13 10:42:52.689: E/AndroidRuntime(26259): at android.os.Handler.dispatchMessage(Handler.java:92) 11-13 10:42:52.689: E/AndroidRuntime(26259): at android.os.Looper.loop(Looper.java:130) 11-13 10:42:52.689: E/AndroidRuntime(26259): at android.app.ActivityThread.main(ActivityThread.java:3701) 11-13 10:42:52.689: E/AndroidRuntime(26259): at java.lang.reflect.Method.invokeNative(Native Method) 11-13 10:42:52.689: E/AndroidRuntime(26259): at java.lang.reflect.Method.invoke(Method.java:507) 11-13 10:42:52.689: E/AndroidRuntime(26259): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866) 11-13 10:42:52.689: E/AndroidRuntime(26259): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:624) 11-13 10:42:52.689: E/AndroidRuntime(26259): at dalvik.system.NativeStart.main(Native Method) 11-13 10:42:52.689: E/AndroidRuntime(26259): Caused by: java.lang.reflect.InvocationTargetException 11-13 10:42:52.689: E/AndroidRuntime(26259): at java.lang.reflect.Method.invokeNative(Native Method) 11-13 10:42:52.689: E/AndroidRuntime(26259): at java.lang.reflect.Method.invoke(Method.java:507) 11-13 10:42:52.689: E/AndroidRuntime(26259): at android.view.View$1.onClick(View.java:2163) 11-13 10:42:52.689: E/AndroidRuntime(26259): ... 11 more 11-13 10:42:52.689: E/AndroidRuntime(26259): Caused by: java.lang.NullPointerException 11-13 10:42:52.689: E/AndroidRuntime(26259): at com.example.mojaapka.MainActivity.logInSystem(MainActivity.java:61) 11-13 10:42:52.689: E/AndroidRuntime(26259): ... 14 more 11-13 10:42:54.539: I/Process(26259): Sending signal. PID: 26259 SIG: 9 </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload