Crash in application. RuntimeException: Unable to start activity [closed] - android

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I got a crash on my application android.
logcat error:
07-09 12:00:46.486: D/dalvikvm(249): GC freed 613 objects / 50984 bytes in 89ms
07-09 12:00:49.944: D/dalvikvm(249): GC freed 2700 objects / 118760 bytes in 76ms
07-09 12:00:50.406: D/AndroidRuntime(249): Shutting down VM
07-09 12:00:50.406: W/dalvikvm(249): threadid=3: thread exiting with uncaught exception (group=0x4001b188)
07-09 12:00:50.417: E/AndroidRuntime(249): Uncaught handler: thread main exiting due to uncaught exception
07-09 12:00:50.444: E/AndroidRuntime(249): java.lang.RuntimeException: Unable to start activity ComponentInfo{allo.nascubetest/allo.nascubetest.MainActivity2}: java.lang.NullPointerException
07-09 12:00:50.444: E/AndroidRuntime(249): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2496)
07-09 12:00:50.444: E/AndroidRuntime(249): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
07-09 12:00:50.444: E/AndroidRuntime(249): at android.app.ActivityThread.access$2200(ActivityThread.java:119)
07-09 12:00:50.444: E/AndroidRuntime(249): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
07-09 12:00:50.444: E/AndroidRuntime(249): at android.os.Handler.dispatchMessage(Handler.java:99)
07-09 12:00:50.444: E/AndroidRuntime(249): at android.os.Looper.loop(Looper.java:123)
07-09 12:00:50.444: E/AndroidRuntime(249): at android.app.ActivityThread.main(ActivityThread.java:4363)
07-09 12:00:50.444: E/AndroidRuntime(249): at java.lang.reflect.Method.invokeNative(Native Method)
07-09 12:00:50.444: E/AndroidRuntime(249): at java.lang.reflect.Method.invoke(Method.java:521)
07-09 12:00:50.444: E/AndroidRuntime(249): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
07-09 12:00:50.444: E/AndroidRuntime(249): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
07-09 12:00:50.444: E/AndroidRuntime(249): at dalvik.system.NativeStart.main(Native Method)
07-09 12:00:50.444: E/AndroidRuntime(249): Caused by: java.lang.NullPointerException
07-09 12:00:50.444: E/AndroidRuntime(249): at allo.nascubetest.MainActivity2.onCreate(MainActivity2.java:111)
07-09 12:00:50.444: E/AndroidRuntime(249): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
07-09 12:00:50.444: E/AndroidRuntime(249): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459)
07-09 12:00:50.444: E/AndroidRuntime(249): ... 11 more
07-09 12:00:50.454: I/dalvikvm(249): threadid=7: reacting to signal 3
07-09 12:00:50.554: I/dalvikvm(249): Wrote stack trace to '/data/anr/traces.txt'
07-09 12:00:52.084: I/Process(249): Sending signal. PID: 249 SIG: 9
in my OnCreate:
Intent thisIntent = getIntent();
date = thisIntent.getExtras().getString("date");
and my line 111:
labelDate.setText(date);

You are accessing a null variable in line 111 in file MainActivity2.java .
Check what you wrote there.
From your code it seems that either labelDate is null or date is null.
Verify you have values in them , you can also debug.
In general, it seems best if you do some tutorial from developer.android.com .

Check out with this code:
Bundle bundle=getIntent().getExtras();
if(bundle!=null){
String date=bundle.getString("date");
labelDate.setText(date);
}
hope this will help you.

your date object is null in line 111, b'coz your intent may not have key named as date or the value will be null.
To prevent from this exception:
make sure that labelDate is not null
make sure that date object is not null before assign to setText();
ex:
if (date != null)
labelDate.setText(date);

Related

react native webview java.lang.NullPointerException

Many times to open the WebView, resulting in a number of WebView, it is estimated that the memory leak, I would like to ask a way to solve it?
Shutting down VM
threadid=1: thread exiting with uncaught exception (group=0xa617e908)
uncaughtException java.lang.NullPointerException
java.lang.NullPointerException
at android.webkit.WebViewClassic.loadUrlImpl(WebViewClassic.java:2525)
at android.webkit.WebViewClassic.loadUrlImpl(WebViewClassic.java:2541)
at android.webkit.WebViewClassic.loadUrl(WebViewClassic.java:2534)
at android.webkit.WebView.loadUrl(WebView.java:784)
at cn.nin.common.MyAndroid$MyAsyncTask.onPostExecute(MyAndroid.java:1461)
at cn.nin.common.MyAndroid$MyAsyncTask.onPostExecute(MyAndroid.java:1362)
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:5041)
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:793)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
at dalvik.system.NativeStart.main(Native Method)
You didn't give us enough information. NullPointerException can be thrown for many reasons.That error means that an application attempts to use an object reference that has the null value.

Null Pointer Exception in First Android App

I am trying to write my first Android app, and I'm having trouble. I wrote a simple Java program to find the factors of a number provided by the user, and I'd like to port it over to Java. I have an XML file for the interface, which seemed to run OK until I added the first Java class. Now it won't run, and log.cat says that there's a null pointer exception. So far, I only have stubs, but it seems like it should run OK with what I've done to this point. I'm including the log.cat text, but I'm too new it this to make much sense out of it.
There may be more than one problem. After adding the Java file I began to get run-time errors right away, but I don't think they were null pointer exceptions. I think that started when I made changes to fix what was already causing problems.
Any help is appreciated.
Here is the Java file:
import android.app.Activity; <br>
import android.os.Bundle; <br>
import android.widget.Button; <br>
import android.widget.EditText; <br>
import android.widget.TextView; <br>
public class AndroidFactoringActivity extends Activity {
// Instance Variables
EditText userNumber;
Button factorButton;
TextView resultsField;
int factorResults;
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
factorButton = (Button) findViewById(R.id.factorButton);
userNumber = (EditText) findViewById(R.id.userNumber);
factorResults = 1;
resultsField.setText(String.valueOf(factorResults));
}
}
Here is main.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:id="#+id/askField"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/ask"
android:textSize="24dp" />
<EditText
android:id="#+id/userNumber"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="number" >
<requestFocus />
</EditText>
<Button
android:id="#+id/factorButton"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/click" />
<TextView
android:id="#+id/resultsField"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/tell"
android:textSize="24dp" />
</LinearLayout>
Here are the log.cat results:
03-31 23:58:53.579: D/AndroidRuntime(2804): Shutting down VM
03-31 23:58:53.589: W/dalvikvm(2804): threadid=3: thread exiting with uncaught exception (group=0x4001b188)
03-31 23:58:53.589: E/AndroidRuntime(2804): Uncaught handler: thread main exiting due to uncaught exception
03-31 23:58:53.650: E/AndroidRuntime(2804): java.lang.RuntimeException: Unable to start activity ComponentInfo{net.dave_b.factoring/net.dave_b.factoring.AndroidFactoringActivity}: java.lang.NullPointerException
03-31 23:58:53.650: E/AndroidRuntime(2804): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2496)
03-31 23:58:53.650: E/AndroidRuntime(2804): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
03-31 23:58:53.650: E/AndroidRuntime(2804): at android.app.ActivityThread.access$2200(ActivityThread.java:119)
03-31 23:58:53.650: E/AndroidRuntime(2804): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
03-31 23:58:53.650: E/AndroidRuntime(2804): at android.os.Handler.dispatchMessage(Handler.java:99)
03-31 23:58:53.650: E/AndroidRuntime(2804): at android.os.Looper.loop(Looper.java:123)
03-31 23:58:53.650: E/AndroidRuntime(2804): at android.app.ActivityThread.main(ActivityThread.java:4363)
03-31 23:58:53.650: E/AndroidRuntime(2804): at java.lang.reflect.Method.invokeNative(Native Method)
03-31 23:58:53.650: E/AndroidRuntime(2804): at java.lang.reflect.Method.invoke(Method.java:521)
03-31 23:58:53.650: E/AndroidRuntime(2804): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
03-31 23:58:53.650: E/AndroidRuntime(2804): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
03-31 23:58:53.650: E/AndroidRuntime(2804): at dalvik.system.NativeStart.main(Native Method)
03-31 23:58:53.650: E/AndroidRuntime(2804): Caused by: java.lang.NullPointerException
03-31 23:58:53.650: E/AndroidRuntime(2804): at net.dave_b.factoring.AndroidFactoringActivity.onCreate(AndroidFactoringActivity.java:26)
03-31 23:58:53.650: E/AndroidRuntime(2804): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
03-31 23:58:53.650: E/AndroidRuntime(2804): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459)
03-31 23:58:53.650: E/AndroidRuntime(2804): ... 11 more
03-31 23:58:53.679: I/dalvikvm(2804): threadid=7: reacting to signal 3
03-31 23:58:53.679: E/dalvikvm(2804): Unable to open stack trace file '/data/anr/traces.txt': Permission denied
03-31 23:59:57.629: I/Process(2804): Sending signal. PID: 2804 SIG: 9
04-01 00:07:36.129: D/AndroidRuntime(3040): Shutting down VM
04-01 00:07:36.129: W/dalvikvm(3040): threadid=3: thread exiting with uncaught exception (group=0x4001b188)
04-01 00:07:36.139: E/AndroidRuntime(3040): Uncaught handler: thread main exiting due to uncaught exception
04-01 00:07:36.159: E/AndroidRuntime(3040): java.lang.RuntimeException: Unable to start activity ComponentInfo{net.dave_b.factoring/net.dave_b.factoring.AndroidFactoringActivity}: java.lang.NullPointerException
04-01 00:07:36.159: E/AndroidRuntime(3040): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2496)
04-01 00:07:36.159: E/AndroidRuntime(3040): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
04-01 00:07:36.159: E/AndroidRuntime(3040): at android.app.ActivityThread.access$2200(ActivityThread.java:119)
04-01 00:07:36.159: E/AndroidRuntime(3040): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
04-01 00:07:36.159: E/AndroidRuntime(3040): at android.os.Handler.dispatchMessage(Handler.java:99)
04-01 00:07:36.159: E/AndroidRuntime(3040): at android.os.Looper.loop(Looper.java:123)
04-01 00:07:36.159: E/AndroidRuntime(3040): at android.app.ActivityThread.main(ActivityThread.java:4363)
04-01 00:07:36.159: E/AndroidRuntime(3040): at java.lang.reflect.Method.invokeNative(Native Method)
04-01 00:07:36.159: E/AndroidRuntime(3040): at java.lang.reflect.Method.invoke(Method.java:521)
04-01 00:07:36.159: E/AndroidRuntime(3040): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
04-01 00:07:36.159: E/AndroidRuntime(3040): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
04-01 00:07:36.159: E/AndroidRuntime(3040): at dalvik.system.NativeStart.main(Native Method)
04-01 00:07:36.159: E/AndroidRuntime(3040): Caused by: java.lang.NullPointerException
04-01 00:07:36.159: E/AndroidRuntime(3040): at net.dave_b.factoring.AndroidFactoringActivity.onCreate(AndroidFactoringActivity.java:26)
04-01 00:07:36.159: E/AndroidRuntime(3040): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
04-01 00:07:36.159: E/AndroidRuntime(3040): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459)
04-01 00:07:36.159: E/AndroidRuntime(3040): ... 11 more
04-01 00:07:36.199: I/dalvikvm(3040): threadid=7: reacting to signal 3
04-01 00:07:36.199: E/dalvikvm(3040): Unable to open stack trace file '/data/anr/traces.txt': Permission denied
04-01 00:07:40.329: I/Process(3040): Sending signal. PID: 3040 SIG: 9
resultsField.setText(String.valueOf(factorResults));
resultsField is null and you are trying to set value on null.
resultsField= (TextView ) findViewById(R.id.userNumber);
Get textview instance before setting value, otherwise resultsField will be null and all operations on null reference results in NullPointerException.
You got a null pointer because you didnt intialise the variable resultsField (you just declared it) .
As you used
userNumber = (EditText) findViewById(R.id.userNumber);
you must even initialise the reference resultsField.
This can be done using
resultsField= (TextView ) findViewById(R.id.resultsField);
in the onCreate() after the statement setContentView()
You need to initialize the userNumer and resultsFiled as follows
userNumber = (EditText) findViewById(R.id.userNumber);
resultsField= (TextView ) findViewById(R.id.resultsField);

Android App API 7

Hello all i have an app it works fine on API 8 but i need it to work on API 7 2.1. the app launches but when i click the button on the spalsh screen to go into the app it force closes on me.
I am using the kankan wheel project if that is any help?
Also i go this from LogCat:
11-22 11:36:53.591: D/ddm-heap(3356): Got feature list request
11-22 11:36:54.071: D/dalvikvm(3356): GC freed 723 objects / 53872 bytes in 247ms
11-22 11:36:54.461: D/dalvikvm(3356): GC freed 225 objects / 10080 bytes in 55ms
11-22 11:37:02.881: D/dalvikvm(3356): GC freed 243 objects / 18368 bytes in 62ms
11-22 11:37:03.121: D/AndroidRuntime(3356): Shutting down VM
11-22 11:37:03.121: W/dalvikvm(3356): threadid=3: thread exiting with uncaught exception (group=0x40026160)
11-22 11:37:03.121: E/AndroidRuntime(3356): Uncaught handler: thread main exiting due to uncaught exception
11-22 11:37:03.121: E/AndroidRuntime(3356): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.insult.kp/kankan.wheel.demo.PasswActivity}: java.lang.ClassCastException: android.widget.ImageView
11-22 11:37:03.121: E/AndroidRuntime(3356): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2503)
11-22 11:37:03.121: E/AndroidRuntime(3356): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2519)
11-22 11:37:03.121: E/AndroidRuntime(3356): at android.app.ActivityThread.access$2200(ActivityThread.java:123)
11-22 11:37:03.121: E/AndroidRuntime(3356): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1870)
11-22 11:37:03.121: E/AndroidRuntime(3356): at android.os.Handler.dispatchMessage(Handler.java:99)
11-22 11:37:03.121: E/AndroidRuntime(3356): at android.os.Looper.loop(Looper.java:123)
11-22 11:37:03.121: E/AndroidRuntime(3356): at android.app.ActivityThread.main(ActivityThread.java:4370)
11-22 11:37:03.121: E/AndroidRuntime(3356): at java.lang.reflect.Method.invokeNative(Native Method)
11-22 11:37:03.121: E/AndroidRuntime(3356): at java.lang.reflect.Method.invoke(Method.java:521)
11-22 11:37:03.121: E/AndroidRuntime(3356): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
11-22 11:37:03.121: E/AndroidRuntime(3356): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
11-22 11:37:03.121: E/AndroidRuntime(3356): at dalvik.system.NativeStart.main(Native Method)
11-22 11:37:03.121: E/AndroidRuntime(3356): Caused by: java.lang.ClassCastException: android.widget.ImageView
11-22 11:37:03.121: E/AndroidRuntime(3356): at kankan.wheel.demo.PasswActivity.onCreate(PasswActivity.java:72)
11-22 11:37:03.121: E/AndroidRuntime(3356): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
11-22 11:37:03.121: E/AndroidRuntime(3356): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2466)
11-22 11:37:03.121: E/AndroidRuntime(3356): ... 11 more
11-22 11:37:03.131: E/SemcCheckin(3356): Get crash dump level : java.io.FileNotFoundException: /data/semc-checkin/crashdump
11-22 11:37:03.141: I/dalvikvm(3356): threadid=7: reacting to signal 3
11-22 11:37:03.151: I/dalvikvm(3356): Wrote stack trace to '/data/anr/traces.txt'
11-22 11:37:04.631: D/dalvikvm(3376): GC freed 760 objects / 55296 bytes in 78ms
11-22 11:37:04.841: D/dalvikvm(3376): GC freed 235 objects / 10552 bytes in 56ms
11-22 11:37:05.181: D/dalvikvm(3376): GC freed 337 objects / 24144 bytes in 58ms
11-22 11:37:05.421: D/AndroidRuntime(3376): Shutting down VM
11-22 11:37:05.421: W/dalvikvm(3376): threadid=3: thread exiting with uncaught exception (group=0x40026160)
11-22 11:37:05.421: E/AndroidRuntime(3376): Uncaught handler: thread main exiting due to uncaught exception
11-22 11:37:05.421: E/AndroidRuntime(3376): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.insult.kp/kankan.wheel.demo.PasswActivity}: java.lang.ClassCastException: android.widget.ImageView
11-22 11:37:05.421: E/AndroidRuntime(3376): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2503)
11-22 11:37:05.421: E/AndroidRuntime(3376): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2519)
11-22 11:37:05.421: E/AndroidRuntime(3376): at android.app.ActivityThread.access$2200(ActivityThread.java:123)
11-22 11:37:05.421: E/AndroidRuntime(3376): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1870)
11-22 11:37:05.421: E/AndroidRuntime(3376): at android.os.Handler.dispatchMessage(Handler.java:99)
11-22 11:37:05.421: E/AndroidRuntime(3376): at android.os.Looper.loop(Looper.java:123)
11-22 11:37:05.421: E/AndroidRuntime(3376): at android.app.ActivityThread.main(ActivityThread.java:4370)
11-22 11:37:05.421: E/AndroidRuntime(3376): at java.lang.reflect.Method.invokeNative(Native Method)
11-22 11:37:05.421: E/AndroidRuntime(3376): at java.lang.reflect.Method.invoke(Method.java:521)
11-22 11:37:05.421: E/AndroidRuntime(3376): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
11-22 11:37:05.421: E/AndroidRuntime(3376): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
11-22 11:37:05.421: E/AndroidRuntime(3376): at dalvik.system.NativeStart.main(Native Method)
11-22 11:37:05.421: E/AndroidRuntime(3376): Caused by: java.lang.ClassCastException: android.widget.ImageView
11-22 11:37:05.421: E/AndroidRuntime(3376): at kankan.wheel.demo.PasswActivity.onCreate(PasswActivity.java:72)
11-22 11:37:05.421: E/AndroidRuntime(3376): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
11-22 11:37:05.421: E/AndroidRuntime(3376): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2466)
11-22 11:37:05.421: E/AndroidRuntime(3376): ... 11 more
11-22 11:37:05.431: E/SemcCheckin(3376): Get crash dump level : java.io.FileNotFoundException: /data/semc-checkin/crashdump
11-22 11:37:05.441: I/dalvikvm(3376): threadid=7: reacting to signal 3
11-22 11:37:05.441: I/dalvikvm(3376): Wrote stack trace to '/data/anr/traces.txt'
11-22 11:37:07.311: D/dalvikvm(3383): GC freed 788 objects / 56384 bytes in 147ms
11-22 11:37:07.561: D/dalvikvm(3383): GC freed 240 objects / 10768 bytes in 54ms
11-22 11:37:26.111: D/dalvikvm(3436): GC freed 594 objects / 48896 bytes in 236ms
11-22 11:37:26.451: D/dalvikvm(3436): GC freed 205 objects / 9176 bytes in 55ms
11-22 11:37:34.391: D/dalvikvm(3436): GC freed 243 objects / 18336 bytes in 127ms
11-22 11:37:34.791: D/AndroidRuntime(3436): Shutting down VM
11-22 11:37:34.791: W/dalvikvm(3436): threadid=3: thread exiting with uncaught exception (group=0x40026160)
11-22 11:37:34.791: E/AndroidRuntime(3436): Uncaught handler: thread main exiting due to uncaught exception
11-22 11:37:34.791: E/AndroidRuntime(3436): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.insult.kp/kankan.wheel.demo.PasswActivity}: java.lang.ClassCastException: android.widget.ImageView
11-22 11:37:34.791: E/AndroidRuntime(3436): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2503)
11-22 11:37:34.791: E/AndroidRuntime(3436): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2519)
11-22 11:37:34.791: E/AndroidRuntime(3436): at android.app.ActivityThread.access$2200(ActivityThread.java:123)
11-22 11:37:34.791: E/AndroidRuntime(3436): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1870)
11-22 11:37:34.791: E/AndroidRuntime(3436): at android.os.Handler.dispatchMessage(Handler.java:99)
11-22 11:37:34.791: E/AndroidRuntime(3436): at android.os.Looper.loop(Looper.java:123)
11-22 11:37:34.791: E/AndroidRuntime(3436): at android.app.ActivityThread.main(ActivityThread.java:4370)
11-22 11:37:34.791: E/AndroidRuntime(3436): at java.lang.reflect.Method.invokeNative(Native Method)
11-22 11:37:34.791: E/AndroidRuntime(3436): at java.lang.reflect.Method.invoke(Method.java:521)
11-22 11:37:34.791: E/AndroidRuntime(3436): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
11-22 11:37:34.791: E/AndroidRuntime(3436): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
11-22 11:37:34.791: E/AndroidRuntime(3436): at dalvik.system.NativeStart.main(Native Method)
11-22 11:37:34.791: E/AndroidRuntime(3436): Caused by: java.lang.ClassCastException: android.widget.ImageView
11-22 11:37:34.791: E/AndroidRuntime(3436): at kankan.wheel.demo.PasswActivity.onCreate(PasswActivity.java:72)
11-22 11:37:34.791: E/AndroidRuntime(3436): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
11-22 11:37:34.791: E/AndroidRuntime(3436): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2466)
11-22 11:37:34.791: E/AndroidRuntime(3436): ... 11 more
11-22 11:37:34.801: E/SemcCheckin(3436): Get crash dump level : java.io.FileNotFoundException: /data/semc-checkin/crashdump
11-22 11:37:34.811: I/dalvikvm(3436): threadid=7: reacting to signal 3
11-22 11:37:34.831: I/dalvikvm(3436): Wrote stack trace to '/data/anr/traces.txt'
11-22 11:37:36.115: I/Process(3436): Sending signal. PID: 3436 SIG: 9
11-22 11:37:36.341: D/dalvikvm(3458): GC freed 601 objects / 49176 bytes in 89ms
11-22 11:37:36.601: D/dalvikvm(3458): GC freed 210 objects / 9400 bytes in 66ms
11-22 11:37:39.991: W/IInputConnectionWrapper(3458): showStatusIcon on inactive InputConnection
11-22 11:38:23.861: D/dalvikvm(3545): GC freed 774 objects / 55792 bytes in 515ms
11-22 11:38:24.071: D/dalvikvm(3545): GC freed 230 objects / 10368 bytes in 57ms
11-22 11:38:27.491: D/dalvikvm(3545): GC freed 243 objects / 18360 bytes in 60ms
11-22 11:38:27.731: D/AndroidRuntime(3545): Shutting down VM
11-22 11:38:27.731: W/dalvikvm(3545): threadid=3: thread exiting with uncaught exception (group=0x40026160)
11-22 11:38:27.731: E/AndroidRuntime(3545): Uncaught handler: thread main exiting due to uncaught exception
11-22 11:38:27.741: E/AndroidRuntime(3545): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.insult.kp/kankan.wheel.demo.PasswActivity}: java.lang.ClassCastException: android.widget.ImageView
11-22 11:38:27.741: E/AndroidRuntime(3545): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2503)
11-22 11:38:27.741: E/AndroidRuntime(3545): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2519)
11-22 11:38:27.741: E/AndroidRuntime(3545): at android.app.ActivityThread.access$2200(ActivityThread.java:123)
11-22 11:38:27.741: E/AndroidRuntime(3545): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1870)
11-22 11:38:27.741: E/AndroidRuntime(3545): at android.os.Handler.dispatchMessage(Handler.java:99)
11-22 11:38:27.741: E/AndroidRuntime(3545): at android.os.Looper.loop(Looper.java:123)
11-22 11:38:27.741: E/AndroidRuntime(3545): at android.app.ActivityThread.main(ActivityThread.java:4370)
11-22 11:38:27.741: E/AndroidRuntime(3545): at java.lang.reflect.Method.invokeNative(Native Method)
11-22 11:38:27.741: E/AndroidRuntime(3545): at java.lang.reflect.Method.invoke(Method.java:521)
11-22 11:38:27.741: E/AndroidRuntime(3545): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
11-22 11:38:27.741: E/AndroidRuntime(3545): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
11-22 11:38:27.741: E/AndroidRuntime(3545): at dalvik.system.NativeStart.main(Native Method)
11-22 11:38:27.741: E/AndroidRuntime(3545): Caused by: java.lang.ClassCastException: android.widget.ImageView
11-22 11:38:27.741: E/AndroidRuntime(3545): at kankan.wheel.demo.PasswActivity.onCreate(PasswActivity.java:72)
11-22 11:38:27.741: E/AndroidRuntime(3545): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
11-22 11:38:27.741: E/AndroidRuntime(3545): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2466)
11-22 11:38:27.741: E/AndroidRuntime(3545): ... 11 more
11-22 11:38:27.751: E/SemcCheckin(3545): Get crash dump level : java.io.FileNotFoundException: /data/semc-checkin/crashdump
11-22 11:38:27.761: I/dalvikvm(3545): threadid=7: reacting to signal 3
11-22 11:38:27.761: I/dalvikvm(3545): Wrote stack trace to '/data/anr/traces.txt'
11-22 11:38:32.201: D/dalvikvm(3552): GC freed 779 objects / 56024 bytes in 142ms
11-22 11:38:32.441: D/dalvikvm(3552): GC freed 230 objects / 10368 bytes in 55ms
11-22 11:41:22.251: D/dalvikvm(3552): GC freed 341 objects / 24264 bytes in 60ms
11-22 11:41:22.541: D/AndroidRuntime(3552): Shutting down VM
11-22 11:41:22.541: W/dalvikvm(3552): threadid=3: thread exiting with uncaught exception (group=0x40026160)
11-22 11:41:22.541: E/AndroidRuntime(3552): Uncaught handler: thread main exiting due to uncaught exception
11-22 11:41:22.541: E/AndroidRuntime(3552): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.insult.kp/kankan.wheel.demo.PasswActivity}: java.lang.ClassCastException: android.widget.ImageView
11-22 11:41:22.541: E/AndroidRuntime(3552): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2503)
11-22 11:41:22.541: E/AndroidRuntime(3552): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2519)
11-22 11:41:22.541: E/AndroidRuntime(3552): at android.app.ActivityThread.access$2200(ActivityThread.java:123)
11-22 11:41:22.541: E/AndroidRuntime(3552): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1870)
11-22 11:41:22.541: E/AndroidRuntime(3552): at android.os.Handler.dispatchMessage(Handler.java:99)
11-22 11:41:22.541: E/AndroidRuntime(3552): at android.os.Looper.loop(Looper.java:123)
11-22 11:41:22.541: E/AndroidRuntime(3552): at android.app.ActivityThread.main(ActivityThread.java:4370)
11-22 11:41:22.541: E/AndroidRuntime(3552): at java.lang.reflect.Method.invokeNative(Native Method)
11-22 11:41:22.541: E/AndroidRuntime(3552): at java.lang.reflect.Method.invoke(Method.java:521)
11-22 11:41:22.541: E/AndroidRuntime(3552): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
11-22 11:41:22.541: E/AndroidRuntime(3552): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
11-22 11:41:22.541: E/AndroidRuntime(3552): at dalvik.system.NativeStart.main(Native Method)
11-22 11:41:22.541: E/AndroidRuntime(3552): Caused by: java.lang.ClassCastException: android.widget.ImageView
11-22 11:41:22.541: E/AndroidRuntime(3552): at kankan.wheel.demo.PasswActivity.onCreate(PasswActivity.java:72)
11-22 11:41:22.541: E/AndroidRuntime(3552): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
11-22 11:41:22.541: E/AndroidRuntime(3552): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2466)
11-22 11:41:22.541: E/AndroidRuntime(3552): ... 11 more
11-22 11:41:22.551: E/SemcCheckin(3552): Get crash dump level : java.io.FileNotFoundException: /data/semc-checkin/crashdump
11-22 11:41:22.561: I/dalvikvm(3552): threadid=7: reacting to signal 3
11-22 11:41:22.571: I/dalvikvm(3552): Wrote stack trace to '/data/anr/traces.txt'
11-22 11:41:24.612: I/Process(3552): Sending signal. PID: 3552 SIG: 9
11-22 11:41:24.831: D/dalvikvm(3626): GC freed 579 objects / 48312 bytes in 79ms
11-22 11:41:25.031: D/dalvikvm(3626): GC freed 205 objects / 9248 bytes in 55ms
11-22 11:41:34.621: D/dalvikvm(3626): GC freed 313 objects / 22008 bytes in 55ms
11-22 11:41:35.651: D/dalvikvm(3626): GC freed 119 objects / 7392 bytes in 56ms
11-22 11:41:36.231: D/dalvikvm(3626): GC freed 86 objects / 6432 bytes in 63ms
11-22 11:41:36.641: D/dalvikvm(3626): GC freed 77 objects / 6024 bytes in 56ms
11-22 11:41:37.041: D/dalvikvm(3626): GC freed 77 objects / 6016 bytes in 56ms
11-22 11:41:38.661: D/dalvikvm(3626): GC freed 182 objects / 17224 bytes in 57ms
11-22 11:41:38.741: D/AndroidRuntime(3626): Shutting down VM
11-22 11:41:38.741: W/dalvikvm(3626): threadid=3: thread exiting with uncaught exception (group=0x40026160)
11-22 11:41:38.741: E/AndroidRuntime(3626): Uncaught handler: thread main exiting due to uncaught exception
11-22 11:41:38.751: E/AndroidRuntime(3626): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.insult.kp/kankan.wheel.demo.PasswActivity}: java.lang.ClassCastException: android.widget.ImageView
11-22 11:41:38.751: E/AndroidRuntime(3626): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2503)
11-22 11:41:38.751: E/AndroidRuntime(3626): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2519)
11-22 11:41:38.751: E/AndroidRuntime(3626): at android.app.ActivityThread.access$2200(ActivityThread.java:123)
11-22 11:41:38.751: E/AndroidRuntime(3626): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1870)
11-22 11:41:38.751: E/AndroidRuntime(3626): at android.os.Handler.dispatchMessage(Handler.java:99)
11-22 11:41:38.751: E/AndroidRuntime(3626): at android.os.Looper.loop(Looper.java:123)
11-22 11:41:38.751: E/AndroidRuntime(3626): at android.app.ActivityThread.main(ActivityThread.java:4370)
11-22 11:41:38.751: E/AndroidRuntime(3626): at java.lang.reflect.Method.invokeNative(Native Method)
11-22 11:41:38.751: E/AndroidRuntime(3626): at java.lang.reflect.Method.invoke(Method.java:521)
11-22 11:41:38.751: E/AndroidRuntime(3626): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
11-22 11:41:38.751: E/AndroidRuntime(3626): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
11-22 11:41:38.751: E/AndroidRuntime(3626): at dalvik.system.NativeStart.main(Native Method)
11-22 11:41:38.751: E/AndroidRuntime(3626): Caused by: java.lang.ClassCastException: android.widget.ImageView
11-22 11:41:38.751: E/AndroidRuntime(3626): at kankan.wheel.demo.PasswActivity.onCreate(PasswActivity.java:72)
11-22 11:41:38.751: E/AndroidRuntime(3626): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
11-22 11:41:38.751: E/AndroidRuntime(3626): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2466)
11-22 11:41:38.751: E/AndroidRuntime(3626): ... 11 more
11-22 11:41:38.751: E/SemcCheckin(3626): Get crash dump level : java.io.FileNotFoundException: /data/semc-checkin/crashdump
11-22 11:41:38.761: I/dalvikvm(3626): threadid=7: reacting to signal 3
11-22 11:41:38.771: I/dalvikvm(3626): Wrote stack trace to '/data/anr/traces.txt'
11-22 11:41:41.161: D/dalvikvm(3636): GC freed 601 objects / 49168 bytes in 71ms
11-22 11:41:41.371: D/dalvikvm(3636): GC freed 205 objects / 9248 bytes in 54ms
11-22 11:42:06.711: W/IInputConnectionWrapper(3636): showStatusIcon on inactive InputConnection
11-22 11:42:14.291: D/dalvikvm(3695): GC freed 748 objects / 54816 bytes in 203ms
11-22 11:42:14.691: D/dalvikvm(3695): GC freed 220 objects / 9968 bytes in 59ms
11-22 11:42:16.721: D/dalvikvm(3695): GC freed 243 objects / 18368 bytes in 59ms
11-22 11:42:17.161: D/AndroidRuntime(3695): Shutting down VM
11-22 11:42:17.161: W/dalvikvm(3695): threadid=3: thread exiting with uncaught exception (group=0x40026160)
11-22 11:42:17.161: E/AndroidRuntime(3695): Uncaught handler: thread main exiting due to uncaught exception
11-22 11:42:17.171: E/AndroidRuntime(3695): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.insult.kp/kankan.wheel.demo.PasswActivity}: java.lang.ClassCastException: android.widget.ImageView
11-22 11:42:17.171: E/AndroidRuntime(3695): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2503)
11-22 11:42:17.171: E/AndroidRuntime(3695): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2519)
11-22 11:42:17.171: E/AndroidRuntime(3695): at android.app.ActivityThread.access$2200(ActivityThread.java:123)
11-22 11:42:17.171: E/AndroidRuntime(3695): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1870)
11-22 11:42:17.171: E/AndroidRuntime(3695): at android.os.Handler.dispatchMessage(Handler.java:99)
11-22 11:42:17.171: E/AndroidRuntime(3695): at android.os.Looper.loop(Looper.java:123)
11-22 11:42:17.171: E/AndroidRuntime(3695): at android.app.ActivityThread.main(ActivityThread.java:4370)
11-22 11:42:17.171: E/AndroidRuntime(3695): at java.lang.reflect.Method.invokeNative(Native Method)
11-22 11:42:17.171: E/AndroidRuntime(3695): at java.lang.reflect.Method.invoke(Method.java:521)
11-22 11:42:17.171: E/AndroidRuntime(3695): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
11-22 11:42:17.171: E/AndroidRuntime(3695): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
11-22 11:42:17.171: E/AndroidRuntime(3695): at dalvik.system.NativeStart.main(Native Method)
11-22 11:42:17.171: E/AndroidRuntime(3695): Caused by: java.lang.ClassCastException: android.widget.ImageView
11-22 11:42:17.171: E/AndroidRuntime(3695): at kankan.wheel.demo.PasswActivity.onCreate(PasswActivity.java:72)
11-22 11:42:17.171: E/AndroidRuntime(3695): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
11-22 11:42:17.171: E/AndroidRuntime(3695): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2466)
11-22 11:42:17.171: E/AndroidRuntime(3695): ... 11 more
11-22 11:42:17.181: E/SemcCheckin(3695): Get crash dump level : java.io.FileNotFoundException: /data/semc-checkin/crashdump
11-22 11:42:17.181: I/dalvikvm(3695): threadid=7: reacting to signal 3
11-22 11:42:17.191: I/dalvikvm(3695): Wrote stack trace to '/data/anr/traces.txt'
11-22 11:42:21.771: D/dalvikvm(3711): GC freed 750 objects / 54904 bytes in 69ms
11-22 11:42:21.981: D/dalvikvm(3711): GC freed 220 objects / 9960 bytes in 54ms
11-22 11:42:43.901: D/dalvikvm(3711): GC freed 341 objects / 24248 bytes in 57ms
11-22 11:42:44.131: D/AndroidRuntime(3711): Shutting down VM
11-22 11:42:44.131: W/dalvikvm(3711): threadid=3: thread exiting with uncaught exception (group=0x40026160)
11-22 11:42:44.131: E/AndroidRuntime(3711): Uncaught handler: thread main exiting due to uncaught exception
11-22 11:42:44.141: E/AndroidRuntime(3711): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.insult.kp/kankan.wheel.demo.PasswActivity}: java.lang.ClassCastException: android.widget.ImageView
11-22 11:42:44.141: E/AndroidRuntime(3711): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2503)
11-22 11:42:44.141: E/AndroidRuntime(3711): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2519)
11-22 11:42:44.141: E/AndroidRuntime(3711): at android.app.ActivityThread.access$2200(ActivityThread.java:123)
11-22 11:42:44.141: E/AndroidRuntime(3711): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1870)
11-22 11:42:44.141: E/AndroidRuntime(3711): at android.os.Handler.dispatchMessage(Handler.java:99)
11-22 11:42:44.141: E/AndroidRuntime(3711): at android.os.Looper.loop(Looper.java:123)
11-22 11:42:44.141: E/AndroidRuntime(3711): at android.app.ActivityThread.main(ActivityThread.java:4370)
11-22 11:42:44.141: E/AndroidRuntime(3711): at java.lang.reflect.Method.invokeNative(Native Method)
11-22 11:42:44.141: E/AndroidRuntime(3711): at java.lang.reflect.Method.invoke(Method.java:521)
11-22 11:42:44.141: E/AndroidRuntime(3711): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
11-22 11:42:44.141: E/AndroidRuntime(3711): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
11-22 11:42:44.141: E/AndroidRuntime(3711): at dalvik.system.NativeStart.main(Native Method)
11-22 11:42:44.141: E/AndroidRuntime(3711): Caused by: java.lang.ClassCastException: android.widget.ImageView
11-22 11:42:44.141: E/AndroidRuntime(3711): at kankan.wheel.demo.PasswActivity.onCreate(PasswActivity.java:72)
11-22 11:42:44.141: E/AndroidRuntime(3711): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
11-22 11:42:44.141: E/AndroidRuntime(3711): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2466)
11-22 11:42:44.141: E/AndroidRuntime(3711): ... 11 more
11-22 11:42:44.151: E/SemcCheckin(3711): Get crash dump level : java.io.FileNotFoundException: /data/semc-checkin/crashdump
11-22 11:42:44.161: I/dalvikvm(3711): threadid=7: reacting to signal 3
11-22 11:42:44.191: I/dalvikvm(3711): Wrote stack trace to '/data/anr/traces.txt'
Either:
you are calling findViewById() on the wrong thing, and therefore are getting an ImageView when you are expecting something else
your R class is out of sync with the rest of your code, which can be fixed by cleaning your project (Project > Clean from the Eclipse main menu, or ant clean from the command line)

NumberFormatException in GPS processing

I am having a weird problem.
I am developing a program to log GPS and sensor readings periodically. My friend runs the code on his machine using Eclipse Galileo 3.6 and it works perfectly fine for her.
When I run the code on my machine which has Eclipse Galileo 3.5.2 it shows service stopped unexpectedly.
We have the same JDK version. I am not able to figure out what may be the exact problem.
Please let me know what else information I need to give in order to fix the problem.
logcat
I/ActivityManager( 1104): Start proc com.sensor.test for service com.sensor.test/.SensorReadings: pid=3539 uid=10057 gids={3003, 1015}
D/AndroidRuntime( 3539): Shutting down VM
W/dalvikvm( 3539): threadid=1: thread exiting with uncaught exception (group=0x4001d7e0)
E/AndroidRuntime( 3539): FATAL EXCEPTION: main
E/AndroidRuntime( 3539): java.lang.RuntimeException: Error receiving broadcast Intent { act=android.intent.action.BATTERY_CHANGED flg=0x60000000 (has extras) } in com.sensor.test.SensorReadings$2#44770958
E/AndroidRuntime( 3539): at android.app.ActivityThread$PackageInfo$ReceiverDispatcher$Args.run(ActivityThread.java:905)
E/AndroidRuntime( 3539): at android.os.Handler.handleCallback(Handler.java:587)
E/AndroidRuntime( 3539): at android.os.Handler.dispatchMessage(Handler.java:92)
E/AndroidRuntime( 3539): at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime( 3539): at android.app.ActivityThread.main(ActivityThread.java:4627)
E/AndroidRuntime( 3539): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 3539): at java.lang.reflect.Method.invoke(Method.java:521)
E/AndroidRuntime( 3539): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
E/AndroidRuntime( 3539): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
E/AndroidRuntime( 3539): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime( 3539): Caused by: java.lang.NullPointerException
E/AndroidRuntime( 3539): at com.sensor.test.SensorReadings$2.onReceive(SensorReadings.java:327)
E/AndroidRuntime( 3539): at android.app.ActivityThread$PackageInfo$ReceiverDispatcher$Args.run(ActivityThread.java:892)
E/AndroidRuntime( 3539): ... 9 more
W/ActivityManager( 1104): Activity destroy timeout for HistoryRecord{44b38508 com.sensor.test/.MainScreen}
D/WifiService( 1104): acquireWifiLockLocked: WifiLock{NetworkLocationProvider type=2 binder=android.os.Binder#44963d80}
D/LocationMasfClient( 1104): getNetworkLocation(): Location not found in cache, making network request
D/LocationMasfClient( 1104): getNetworkLocation(): Number of prefetched entries 10
E/LocationMasfClient( 1104): getNetworkLocation(): Returning *server* computed location with accuracy 28
D/libgps ( 1104): GpsInterface_inject_location( 35.772249, -78.673950, 28.000 )
D/WifiService( 1104): releaseWifiLockLocked: WifiLock{NetworkLocationProvider type=2 binder=android.os.Binder#44963d80}
D/WifiService( 1104): acquireWifiLockLocked: WifiLock{NetworkLocationProvider type=2 binder=android.os.Binder#44963d80}
D/WifiService( 1104): releaseWifiLockLocked: WifiLock{NetworkLocationProvider type=2 binder=android.os.Binder#44963d80}
D/NativeCrypto( 1104): Freeing OpenSSL session
D/dalvikvm( 1104): GC_FOR_MALLOC freed 22104 objects / 1169312 bytes in 128ms
D/NativeCrypto( 1104): Freeing OpenSSL session
I/Process ( 3539): Sending signal. PID: 3539 SIG: 9
W/InputManagerService( 1104): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy#44b40dd0
I/ActivityManager( 1104): Process com.sensor.test (pid 3539) has died.
The pertinent code for line 88 with parsing going on:
public void startService(){
//startService(new Intent(MainScreen.this,SensorReadings.class));
Intent intent = new Intent(MainScreen.this, SensorReadings.class);
**intent.putExtra("lp", Integer.parseInt(""+longPeriod.getText()));// LINE 88**
intent.putExtra("gp", Integer.parseInt(""+gpsPeriod.getText()));
intent.putExtra("sp", Integer.parseInt(""+snrPeriod.getText()));
//startActivity(intent);
startService(intent);
}
Thanks.
AG
E/AndroidRuntime( 2934): java.lang.NumberFormatException: unable to parse '' as integer
E/AndroidRuntime( 2934): at java.lang.Integer.parseInt(Integer.java:412)
E/AndroidRuntime( 2934): at java.lang.Integer.parseInt(Integer.java:382)
E/AndroidRuntime( 2934): at com.sensor.test.MainScreen.startService(MainScreen.java:88)
Perhaps at line 88 in MainScreen.java, your startService method is calling Integer.parseInt with an empty string?
Can you show us the pertinent code?
I don't get why you are putting "".
So to be sure this is not the problem try either this:
intent.putExtra("lp", Integer.parseInt(longPeriod.getText()));
intent.putExtra("gp", Integer.parseInt(gpsPeriod.getText()));
intent.putExtra("sp", Integer.parseInt(snrPeriod.getText()));
or
String lp = longPeriod.getText();
String gp = gpsPeriod.getText();
String sp = snrPeriod.getText();
intent.putExtra("lp", Integer.parseInt(lp));
intent.putExtra("gp", Integer.parseInt(gp));
intent.putExtra("sp", Integer.parseInt(sp));
The second way is better for debugging... so you can see what is actually happening.

Exception on ListPreferences

This is my first Android app and I've encountered an exception when trying to use the ListPreference. The application loads along with the preferences... but when i touch the ListPreference entry the applications "stops unexpectedly".
Settings.java
public class Settings extends PreferenceActivity {
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.addPreferencesFromResource(R.layout.settings);
}
}
settings.xml
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android">
<CheckBoxPreference
android:key="chk_enabled"
android:summary="SMS response based on settings"
android:title="Enable"
/>
<ListPreference
android:title="Contacts"
android:summary="Contacs that will be sent SMSs"
android:key="list_contacts"
android:defaultValue="0"
android:entries="#array/list_entries"
android:entryValues="#array/list_values"
/>
</PreferenceScreen>
arrays.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="list_entries">
<item>All</item>
<item>WhiteList</item>
<item>BlackList</item>
</string-array>
<integer-array name="list_values">
<item>0</item>
<item>1</item>
<item>2</item>
</integer-array>
</resources>
This is the logcat output:
D/AndroidRuntime( 3187): >>>>>>>>>>>>>> AndroidRuntime START <<<<<<<<<<<<<<
D/AndroidRuntime( 3187): CheckJNI is OFF
D/AndroidRuntime( 3187): --- registering native functions ---
I/jdwp ( 3187): received file descriptor 16 from ADB
/ddm-heap( 3187): Got feature list request
I/ActivityManager( 86): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=tml.UI.main/.MainActivity }
D/AndroidRuntime( 3187): Shutting down VM
D/dalvikvm( 3187): DestroyJavaVM waiting for non-daemon threads to exit
I/ActivityManager( 86): Start proc tml.UI.main for activity tml.UI.main/.MainActivity: pid=3194 uid=10039 gids={1015}
D/dalvikvm( 3187): DestroyJavaVM shutting VM down
D/dalvikvm( 3187): HeapWorker thread shutting down
D/dalvikvm( 3187): HeapWorker thread has shut down
D/jdwp ( 3187): JDWP shutting down net...
D/jdwp ( 3187): +++ peer disconnected
I/dalvikvm( 3187): Debugger has detached; object registry had 1 entries
D/dalvikvm( 3187): VM cleaning up
D/dalvikvm( 3187): LinearAlloc 0x0 used 676380 of 4194304 (16%)
I/jdwp ( 3194): received file descriptor 10 from ADB
D/ddm-heap( 3194): Got feature list request
W/Resources( 3194): Converting to string: TypedValue{t=0x10/d=0x0 a=-1}
I/ActivityManager( 86): Displayed activity tml.UI.main/.MainActivity: 977 ms (total 977 ms)
D/AndroidRuntime( 3194): Shutting down VM
W/dalvikvm( 3194): threadid=3: thread exiting with uncaught exception (group=0x4001da28)
E/AndroidRuntime( 3194): Uncaught handler: thread main exiting due to uncaught exception
E/AndroidRuntime( 3194): java.lang.NullPointerException
E/AndroidRuntime( 3194): at android.preference.ListPreference.findIndexOfValue(ListPreference.java:169)
E/AndroidRuntime( 3194): at android.preference.ListPreference.getValueIndex(ListPreference.java:178)
E/AndroidRuntime( 3194): at android.preference.ListPreference.onPrepareDialogBuilder(ListPreference.java:190)
E/AndroidRuntime( 3194): at android.preference.DialogPreference.showDialog(DialogPreference.java:291)
E/AndroidRuntime( 3194): at android.preference.DialogPreference.onClick(DialogPreference.java:262)
E/AndroidRuntime( 3194): at android.preference.Preference.performClick(Preference.java:811)
E/AndroidRuntime( 3194): at android.preference.PreferenceScreen.onItemClick(PreferenceScreen.java:190)
E/AndroidRuntime( 3194): at android.widget.AdapterView.performItemClick(AdapterView.java:284)
E/AndroidRuntime( 3194): at android.widget.ListView.performItemClick(ListView.java:3246)
E/AndroidRuntime( 3194): at android.widget.AbsListView$PerformClick.run(AbsListView.java:1635)
E/AndroidRuntime( 3194): at android.os.Handler.handleCallback(Handler.java:587)
E/AndroidRuntime( 3194): at android.os.Handler.dispatchMessage(Handler.java:92)
E/AndroidRuntime( 3194): at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime( 3194): at android.app.ActivityThread.main(ActivityThread.java:4203)
E/AndroidRuntime( 3194): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 3194): at java.lang.reflect.Method.invoke(Method.java:521)
E/AndroidRuntime( 3194): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
E/AndroidRuntime( 3194): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549)
E/AndroidRuntime( 3194): at dalvik.system.NativeStart.main(Native Method)
I/Process ( 86): Sending signal. PID: 3194 SIG: 3
I/dalvikvm( 3194): threadid=7: reacting to signal 3
I/dalvikvm( 3194): Wrote stack trace to '/data/anr/traces.txt'
I/Process ( 3194): Sending signal. PID: 3194 SIG: 9
I/ActivityManager( 86): Process tml.UI.main (pid 3194) has died.
I/WindowManager( 86): WIN DEATH: Window{4341fd00 tml.UI.main/tml.UI.main.MainActivity paused=false}
W/UsageStats( 86): Unexpected resume of com.android.launcher while already resumed in tml.UI.main
W/InputManagerService( 86): Got RemoteException sending setActive(false) notification to pid 3194 uid 10039
I fixed it... I kept on trying and, at the end, it turns out that I cannot use an integer-array as the entryValues Source. I just changed that integer-array to a string-array and got it working.
If there's a way to use integer-array as the source for entryValues please comment.
I've been searching for a similar solution to what you are looking for, agreeing that you should be able to use an Integer array to read from and store an integer result.
A solution to this problem I found was at http://kvance.livejournal.com/1039349.html, which I found to be useful.
It doesn't quite solve the problem the way I was thinking or that way I think you want it to, instead you still specify your initial / selection values with a String array although when the ListPreference saves it back to the SharedPreferences it saves as an Integer instead of a String (doing the conversion when the user selects it), removing the need to have to convert it possibly many times throughout your application when accessing the preference value.

Categories

Resources