I have added the Results class to the Android Manifest, so yes, you can cross that off the list.
Is it an error in the way I've set out the method?
package com.kenning.foreveralone;
import android.app.Activity;
import android.os.Bundle;
import android.widget.EditText;
import android.widget.TextView;
public class Results extends Activity{
EditText fbFriends;
TextView resulting;
String value;
#Override
public void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.rslt);
TextView resulting = (TextView) findViewById(R.id.result);
EditText fbFriends = (EditText) findViewById(R.id.noFacebookFriends);
String value = fbFriends.getText().toString();
resulting.setText("Your score is " + value);
}
}
When I start this class, it always seems to force close my app. Can anyone tell me what I'm doing wrong?
Here's the log cat:
04-08 20:05:24.169: E/AndroidRuntime(589): FATAL EXCEPTION: main
04-08 20:05:24.169: E/AndroidRuntime(589): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.kenning.foreveralone/com.kenning.foreveralone.Results}: java.lang.NullPointerException
04-08 20:05:24.169: E/AndroidRuntime(589): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
04-08 20:05:24.169: E/AndroidRuntime(589): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
04-08 20:05:24.169: E/AndroidRuntime(589): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
04-08 20:05:24.169: E/AndroidRuntime(589): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
04-08 20:05:24.169: E/AndroidRuntime(589): at android.os.Handler.dispatchMessage(Handler.java:99)
04-08 20:05:24.169: E/AndroidRuntime(589): at android.os.Looper.loop(Looper.java:123)
04-08 20:05:24.169: E/AndroidRuntime(589): at android.app.ActivityThread.main(ActivityThread.java:4627)
04-08 20:05:24.169: E/AndroidRuntime(589): at java.lang.reflect.Method.invokeNative(Native Method)
04-08 20:05:24.169: E/AndroidRuntime(589): at java.lang.reflect.Method.invoke(Method.java:521)
04-08 20:05:24.169: E/AndroidRuntime(589): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
04-08 20:05:24.169: E/AndroidRuntime(589): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
04-08 20:05:24.169: E/AndroidRuntime(589): at dalvik.system.NativeStart.main(Native Method)
04-08 20:05:24.169: E/AndroidRuntime(589): Caused by: java.lang.NullPointerException
04-08 20:05:24.169: E/AndroidRuntime(589): at com.kenning.foreveralone.Results.onCreate(Results.java:20)
04-08 20:05:24.169: E/AndroidRuntime(589): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
04-08 20:05:24.169: E/AndroidRuntime(589): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
04-08 20:05:24.169: E/AndroidRuntime(589): ... 11 more
It's a null pointer exception in onCreate, so why not try stepping through onCreate to see what variable is null?
That said, I'm guessing R.id.noFacebookFriends is not part of the R.layout.rslt.
You are getting a NullPointerException somewhere in your OnCreate. I am guessing that either the ids are wrong in your rslt.xml layout so result and fbFriends is null, or fbFriends doesn't have any text in it so getText() returns null.
Related
04-08 00:46:02.390: D/AndroidRuntime(918): Shutting down VM
04-08 00:46:02.390: W/dalvikvm(918): threadid=1: thread exiting with uncaught exception (group=0xb4acab90)
04-08 00:46:02.420: E/AndroidRuntime(918): FATAL EXCEPTION: main
04-08 00:46:02.420: E/AndroidRuntime(918): Process: net.gnobal.dindy, PID: 918
04-08 00:46:02.420: E/AndroidRuntime(918): java.lang.RuntimeException: Unable to instantiate application net.gnobal.dindy.DindyApplication: java.lang.ClassNotFoundException: Didn't find class "net.gnobal.dindy.DindyApplication" on path: DexPathList[[zip file "/data/app/net.gnobal.dindy-1.apk"],nativeLibraryDirectories=[/data/app-lib/net.gnobal.dindy-1, /system/lib]]
04-08 00:46:02.420: E/AndroidRuntime(918): at android.app.LoadedApk.makeApplication(LoadedApk.java:516)
04-08 00:46:02.420: E/AndroidRuntime(918): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4298)
04-08 00:46:02.420: E/AndroidRuntime(918): at android.app.ActivityThread.access$1400(ActivityThread.java:135)
04-08 00:46:02.420: E/AndroidRuntime(918): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1457)
04-08 00:46:02.420: E/AndroidRuntime(918): at android.os.Handler.dispatchMessage(Handler.java:102)
04-08 00:46:02.420: E/AndroidRuntime(918): at android.os.Looper.loop(Looper.java:137)
04-08 00:46:02.420: E/AndroidRuntime(918): at android.app.ActivityThread.main(ActivityThread.java:4998)
04-08 00:46:02.420: E/AndroidRuntime(918): at java.lang.reflect.Method.invokeNative(Native Method)
04-08 00:46:02.420: E/AndroidRuntime(918): at java.lang.reflect.Method.invoke(Method.java:515)
04-08 00:46:02.420: E/AndroidRuntime(918): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)
04-08 00:46:02.420: E/AndroidRuntime(918): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:593)
04-08 00:46:02.420: E/AndroidRuntime(918): at dalvik.system.NativeStart.main(Native Method)
04-08 00:46:02.420: E/AndroidRuntime(918): Caused by: java.lang.ClassNotFoundException: Didn't find class "net.gnobal.dindy.DindyApplication" on path: DexPathList[[zip file "/data/app/net.gnobal.dindy-1.apk"],nativeLibraryDirectories=[/data/app-lib/net.gnobal.dindy-1, /system/lib]]
04-08 00:46:02.420: E/AndroidRuntime(918): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
04-08 00:46:02.420: E/AndroidRuntime(918): at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
04-08 00:46:02.420: E/AndroidRuntime(918): at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
04-08 00:46:02.420: E/AndroidRuntime(918): at android.app.Instrumentation.newApplication(Instrumentation.java:975)
04-08 00:46:02.420: E/AndroidRuntime(918): at android.app.LoadedApk.makeApplication(LoadedApk.java:511)
04-08 00:46:02.420: E/AndroidRuntime(918): ... 11 more
04-08 00:46:07.430: I/Process(918): Sending signal. PID: 918 SIG: 9
Check your package name and also check whether the class name i.e activity is properly registered in the manifest.
when I import the viewpagerindicator project library into my application that works without the support library, it crashes on launch. I've tried it with more than one application with the same results. Here is the logcat output:
06-14 17:19:02.351: E/AndroidRuntime(589): FATAL EXCEPTION: main
06-14 17:19:02.351: E/AndroidRuntime(589): Process: com.example.android.navigationdrawerexample, PID: 589
06-14 17:19:02.351: E/AndroidRuntime(589): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.android.navigationdrawerexample/com.example.android.navigationdrawerexample.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.example.android.navigationdrawerexample.MainActivity" on path: DexPathList[[zip file "/data/app/com.example.android.navigationdrawerexample-9.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.android.navigationdrawerexample-9, /vendor/lib, /system/lib]]
06-14 17:19:02.351: E/AndroidRuntime(589): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2231)
06-14 17:19:02.351: E/AndroidRuntime(589): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2363)
06-14 17:19:02.351: E/AndroidRuntime(589): at android.app.ActivityThread.access$900(ActivityThread.java:161)
06-14 17:19:02.351: E/AndroidRuntime(589): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1265)
06-14 17:19:02.351: E/AndroidRuntime(589): at android.os.Handler.dispatchMessage(Handler.java:102)
06-14 17:19:02.351: E/AndroidRuntime(589): at android.os.Looper.loop(Looper.java:157)
06-14 17:19:02.351: E/AndroidRuntime(589): at android.app.ActivityThread.main(ActivityThread.java:5356)
06-14 17:19:02.351: E/AndroidRuntime(589): at java.lang.reflect.Method.invokeNative(Native Method)
06-14 17:19:02.351: E/AndroidRuntime(589): at java.lang.reflect.Method.invoke(Method.java:515)
06-14 17:19:02.351: E/AndroidRuntime(589): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1265)
06-14 17:19:02.351: E/AndroidRuntime(589): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)
06-14 17:19:02.351: E/AndroidRuntime(589): at dalvik.system.NativeStart.main(Native Method)
06-14 17:19:02.351: E/AndroidRuntime(589): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.android.navigationdrawerexample.MainActivity" on path: DexPathList[[zip file "/data/app/com.example.android.navigationdrawerexample-9.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.android.navigationdrawerexample-9, /vendor/lib, /system/lib]]
06-14 17:19:02.351: E/AndroidRuntime(589): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:67)
06-14 17:19:02.351: E/AndroidRuntime(589): at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
06-14 17:19:02.351: E/AndroidRuntime(589): at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
06-14 17:19:02.351: E/AndroidRuntime(589): at android.app.Instrumentation.newActivity(Instrumentation.java:1079)
06-14 17:19:02.351: E/AndroidRuntime(589): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2222)
06-14 17:19:02.351: E/AndroidRuntime(589): ... 11 more
So it turns out that the problem was that all of my android-support-v4.jar library files were different. So all I did was copied the latest v4 .jar files into the "libs" folder of both my project and library, added it to the build path, and voilĂ no more crashes!
i know this question has been treated so much time, but i really don't find the answer to my problem.
This is an application which connect to a server, so, there's a socket, that's why i'm using thread (i can't do anything else since android 4.0), but even if i'm disable the code of my socket, it still crash.
Here's the logCat error :
04-08 08:36:39.366: D/AndroidRuntime(16604): Shutting down VM
04-08 08:36:39.366: W/dalvikvm(16604): threadid=1: thread exiting with uncaught exception (group=0x4122f300)
04-08 08:36:39.366: E/AndroidRuntime(16604): FATAL EXCEPTION: main
04-08 08:36:39.366: E/AndroidRuntime(16604): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.projetlyres2013/com.example.projetlyres2013.PlanDMX}: java.lang.NullPointerException
04-08 08:36:39.366: E/AndroidRuntime(16604): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1983)
04-08 08:36:39.366: E/AndroidRuntime(16604): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
04-08 08:36:39.366: E/AndroidRuntime(16604): at android.app.ActivityThread.access$600(ActivityThread.java:130)
04-08 08:36:39.366: E/AndroidRuntime(16604): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
04-08 08:36:39.366: E/AndroidRuntime(16604): at android.os.Handler.dispatchMessage(Handler.java:99)
04-08 08:36:39.366: E/AndroidRuntime(16604): at android.os.Looper.loop(Looper.java:137)
04-08 08:36:39.366: E/AndroidRuntime(16604): at android.app.ActivityThread.main(ActivityThread.java:4745)
04-08 08:36:39.366: E/AndroidRuntime(16604): at java.lang.reflect.Method.invokeNative(Native Method)
04-08 08:36:39.366: E/AndroidRuntime(16604): at java.lang.reflect.Method.invoke(Method.java:511)
04-08 08:36:39.366: E/AndroidRuntime(16604): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
04-08 08:36:39.366: E/AndroidRuntime(16604): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
04-08 08:36:39.366: E/AndroidRuntime(16604): at dalvik.system.NativeStart.main(Native Method)
04-08 08:36:39.366: E/AndroidRuntime(16604): Caused by: java.lang.NullPointerException
04-08 08:36:39.366: E/AndroidRuntime(16604): at android.app.Activity.findViewById(Activity.java:1825)
04-08 08:36:39.366: E/AndroidRuntime(16604): at com.example.projetlyres2013.PlanDMX.<init>(PlanDMX.java:27)
04-08 08:36:39.366: E/AndroidRuntime(16604): at java.lang.Class.newInstanceImpl(Native Method)
04-08 08:36:39.366: E/AndroidRuntime(16604): at java.lang.Class.newInstance(Class.java:1319)
04-08 08:36:39.366: E/AndroidRuntime(16604): at android.app.Instrumentation.newActivity(Instrumentation.java:1053)
04-08 08:36:39.366: E/AndroidRuntime(16604): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1974)
04-08 08:36:39.366: E/AndroidRuntime(16604): ... 11 more
04-08 08:36:41.326: I/Process(16604): Sending signal. PID: 16604 SIG: 9
04-08 08:46:26.556: D/AndroidRuntime(16825): Shutting down VM
///////// Manifest /////////
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.projetlyres2013"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="16" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.projetlyres2013.PlanDMX"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
I don't know what's happened when i want to launch it on my tablet (android 4.1).
I really need help for that :/
Thanks
NullPointer here means that you did not set your layout XML as contentView to your Activity.
Inside onCreate(...) method of Activity add
setContentView(R.layout.some_layout-file)
Whenever I run my android application I get an exception:
05-07 12:03:55.356: E/AndroidRuntime(589): FATAL EXCEPTION: main
05-07 12:03:55.356: E/AndroidRuntime(589): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{packgname/de.fau.fsahoy.android.api15.Activities.LoginActivity}: java.lang.ClassNotFoundException: de.fau.fsahoy.android.api15.Activities.LoginActivity
05-07 12:03:55.356: E/AndroidRuntime(589): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1880)
05-07 12:03:55.356: E/AndroidRuntime(589): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
05-07 12:03:55.356: E/AndroidRuntime(589): at android.app.ActivityThread.access$600(ActivityThread.java:123)
05-07 12:03:55.356: E/AndroidRuntime(589): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
05-07 12:03:55.356: E/AndroidRuntime(589): at android.os.Handler.dispatchMessage(Handler.java:99)
05-07 12:03:55.356: E/AndroidRuntime(589): at android.os.Looper.loop(Looper.java:137)
05-07 12:03:55.356: E/AndroidRuntime(589): at android.app.ActivityThread.main(ActivityThread.java:4424)
05-07 12:03:55.356: E/AndroidRuntime(589): at java.lang.reflect.Method.invokeNative(Native Method)
05-07 12:03:55.356: E/AndroidRuntime(589): at java.lang.reflect.Method.invoke(Method.java:511)
05-07 12:03:55.356: E/AndroidRuntime(589): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
05-07 12:03:55.356: E/AndroidRuntime(589): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
05-07 12:03:55.356: E/AndroidRuntime(589): at dalvik.system.NativeStart.main(Native Method)
05-07 12:03:55.356: E/AndroidRuntime(589): Caused by: java.lang.ClassNotFoundException: packgname.Activities.LoginActivity
05-07 12:03:55.356: E/AndroidRuntime(589): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
05-07 12:03:55.356: E/AndroidRuntime(589): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
05-07 12:03:55.356: E/AndroidRuntime(589): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
05-07 12:03:55.356: E/AndroidRuntime(589): at android.app.Instrumentation.newActivity(Instrumentation.java:1023)
05-07 12:03:55.356: E/AndroidRuntime(589): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1871)
05-07 12:03:55.356: E/AndroidRuntime(589): ... 11 more
However, in my AndroidManifest.xml there imho nothing wrong:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="de.fau.fsahoy.android.api15"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="10" android:targetSdkVersion="15"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<application
android:icon="#drawable/fsa_launcher"
android:label="#string/AppName">
<activity
android:name=".Activities.LoginActivity"
android:label="#string/AppName">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".Activities.MainMenuActivity"></activity>
<activity android:name=".Activities.ProfileActivity"></activity>
</application>
</manifest>
I'm going crazy about that issue and trying to resolve it for the last 3 hours or so :<
Currently I am rebuilding the app by copy and pasting the code over to another clean project. I hope that works. Anyway, I see that many people have that issue. What is it?
I solved the problem by creating a new Android Project and manually copy and pasted the code from the old project.
Magically then - it worked :)
Might not be the best solution - especially for large projects with a huge codebase. Yet, it worked for me :)
I had a similar "poltergeist" in my code. I don't understand the reason but it seems to be related with my activity extending FragmentActivity and having a method with the following signature: public boolean isResumed().
I renamed the method and it worked.
I developed an application that allows the user to save his two favourite parking spots. It uses a service to retrieve the relevant parking information from an sqlite database. Within the database I have this method to find the first entry:
public Cursor firstentry(){
String select = "SELECT PREF1, PREF2 FROM parking_table WHERE id =1";
Cursor cursor = db.rawQuery(select, null);
return cursor;
Every time I run my application a force close error appears, when the service tries calling this method using the command:
Cursor c = dh.firstentry();
It is giving the error as when I comment it, the applications works perfectly.
Here is the logcat of the error:
04-08 18:56:38.673: E/AndroidRuntime(13166): FATAL EXCEPTION: Timer-0
04-08 18:56:38.673: E/AndroidRuntime(13166): java.lang.NullPointerException
04-08 18:56:38.673: E/AndroidRuntime(13166): at stefan.testservice.ConnectionService$1.run(ConnectionService.java:64)
04-08 18:56:38.673: E/AndroidRuntime(13166): at java.util.Timer$TimerImpl.run(Timer.java:284)
04-08 18:56:39.654: E/ActivityThread(13166): Activity stefan.testservice.TestserviceActivity has leaked IntentReceiver stefan.testservice.TestserviceActivity$2#40521b78 that was originally registered here. Are you missing a call to unregisterReceiver()?
04-08 18:56:39.654: E/ActivityThread(13166): android.app.IntentReceiverLeaked: Activity stefan.testservice.TestserviceActivity has leaked IntentReceiver stefan.testservice.TestserviceActivity$2#40521b78 that was originally registered here. Are you missing a call to unregisterReceiver()?
04-08 18:56:39.654: E/ActivityThread(13166): at android.app.LoadedApk$ReceiverDispatcher.<init>(LoadedApk.java:756)
04-08 18:56:39.654: E/ActivityThread(13166): at android.app.LoadedApk.getReceiverDispatcher(LoadedApk.java:551)
04-08 18:56:39.654: E/ActivityThread(13166): at android.app.ContextImpl.registerReceiverInternal(ContextImpl.java:795)
04-08 18:56:39.654: E/ActivityThread(13166): at android.app.ContextImpl.registerReceiver(ContextImpl.java:782)
04-08 18:56:39.654: E/ActivityThread(13166): at android.app.ContextImpl.registerReceiver(ContextImpl.java:776)
04-08 18:56:39.654: E/ActivityThread(13166): at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:318)
04-08 18:56:39.654: E/ActivityThread(13166): at stefan.testservice.TestserviceActivity$1.onServiceConnected(TestserviceActivity.java:280)
04-08 18:56:39.654: E/ActivityThread(13166): at android.app.LoadedApk$ServiceDispatcher.doConnected(LoadedApk.java:1064)
04-08 18:56:39.654: E/ActivityThread(13166): at android.app.LoadedApk$ServiceDispatcher$RunConnection.run(LoadedApk.java:1081)
04-08 18:56:39.654: E/ActivityThread(13166): at android.os.Handler.handleCallback(Handler.java:587)
04-08 18:56:39.654: E/ActivityThread(13166): at android.os.Handler.dispatchMessage(Handler.java:92)
04-08 18:56:39.654: E/ActivityThread(13166): at android.os.Looper.loop(Looper.java:123)
04-08 18:56:39.654: E/ActivityThread(13166): at android.app.ActivityThread.main(ActivityThread.java:3683)
04-08 18:56:39.654: E/ActivityThread(13166): at java.lang.reflect.Method.invokeNative(Native Method)
04-08 18:56:39.654: E/ActivityThread(13166): at java.lang.reflect.Method.invoke(Method.java:507)
04-08 18:56:39.654: E/ActivityThread(13166): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
04-08 18:56:39.654: E/ActivityThread(13166): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
04-08 18:56:39.654: E/ActivityThread(13166): at dalvik.system.NativeStart.main(Native Method)
04-08 18:56:40.054: E/ActivityThread(13166): Activity stefan.testservice.TestserviceActivity has leaked ServiceConnection stefan.testservice.TestserviceActivity$1#40521790 that was originally bound here
04-08 18:56:40.054: E/ActivityThread(13166): android.app.ServiceConnectionLeaked: Activity stefan.testservice.TestserviceActivity has leaked ServiceConnection stefan.testservice.TestserviceActivity$1#40521790 that was originally bound here
04-08 18:56:40.054: E/ActivityThread(13166): at android.app.LoadedApk$ServiceDispatcher.<init>(LoadedApk.java:938)
04-08 18:56:40.054: E/ActivityThread(13166): at android.app.LoadedApk.getServiceDispatcher(LoadedApk.java:833)
04-08 18:56:40.054: E/ActivityThread(13166): at android.app.ContextImpl.bindService(ContextImpl.java:867)
04-08 18:56:40.054: E/ActivityThread(13166): at android.content.ContextWrapper.bindService(ContextWrapper.java:347)
04-08 18:56:40.054: E/ActivityThread(13166): at stefan.testservice.TestserviceActivity.doBindService(TestserviceActivity.java:290)
04-08 18:56:40.054: E/ActivityThread(13166): at stefan.testservice.TestserviceActivity$DownloadTask.onPostExecute(TestserviceActivity.java:193)
04-08 18:56:40.054: E/ActivityThread(13166): at android.os.AsyncTask.finish(AsyncTask.java:417)
04-08 18:56:40.054: E/ActivityThread(13166): at android.os.AsyncTask.access$300(AsyncTask.java:127)
04-08 18:56:40.054: E/ActivityThread(13166): at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:429)
04-08 18:56:40.054: E/ActivityThread(13166): at android.os.Handler.dispatchMessage(Handler.java:99)
04-08 18:56:40.054: E/ActivityThread(13166): at android.os.Looper.loop(Looper.java:123)
04-08 18:56:40.054: E/ActivityThread(13166): at android.app.ActivityThread.main(ActivityThread.java:3683)
04-08 18:56:40.054: E/ActivityThread(13166): at java.lang.reflect.Method.invokeNative(Native Method)
04-08 18:56:40.054: E/ActivityThread(13166): at java.lang.reflect.Method.invoke(Method.java:507)
04-08 18:56:40.054: E/ActivityThread(13166): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
04-08 18:56:40.054: E/ActivityThread(13166): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
04-08 18:56:40.054: E/ActivityThread(13166): at dalvik.system.NativeStart.main(Native Method)
Any help is much appreciated as I tried everything and nothing seems to work. Thanks in advance!
Edited:
Parking table code:
public void onCreate(SQLiteDatabase db) {
db.execSQL("CREATE TABLE " + TABLE_NAME + "(id INTEGER PRIMARY KEY, PREF1 TEXT, PREF2 TEXT)");
}
its a nullpointerexception meaning there is probably nothing in the database at that time. you need to handle if the cursor is null
stepping through the code is really the only way to see exactly what is null. More code is definitely needed though its hard to tell with what you posted
you are running rawsql so check if the exact query is valid for your db , SELECT PREF1, PREF2 FROM parking_table WHERE id =1
are PREF1 exactly(with case) the name of columns ??
If you don't have a SQLite browser software, get one here:
SQLite Browser
It helps when I'm working with SQLite. I've run into this problem before and I solved it by adding the id parameter into the query. Essentially, you'll want to change your query to:
public Cursor firstentry(){
String select = "SELECT id, PREF1, PREF2 FROM parking_table WHERE id =1";
Cursor cursor = db.rawQuery(select, null);
return cursor;
Don't forget to call c.moveToFirst() if c is the name of the Cursor.
I managed to solve it, everything was ok, I just needed to initiliaze the class object. Here's the line of code needed:
this.yourobject = new class(this);
in my case it is:
this.dh = new SQLHelper(this);
Hope it helps :)