0

I am very new to android programming. I am trying to make an application that uses bluetooth connectivity that connects with a chip transfers data. I set up the bluetooth connection but the program wont run it comes up with the "this program has closed unexpectedly" I have read some stuff on log cat but i still can't figure it out. Could somebody please tell me what my error is?

Here is my LogCat:

    08-10 12:29:52.693: ERROR/AndroidRuntime(2575): FATAL EXCEPTION: main
08-10 12:29:52.693: ERROR/AndroidRuntime(2575): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.joshi.remotedoc/com.joshi.remotedoc.Remote_DocActivity}: java.lang.InstantiationException: com.joshi.remotedoc.Remote_DocActivity
08-10 12:29:52.693: ERROR/AndroidRuntime(2575):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2585)
08-10 12:29:52.693: ERROR/AndroidRuntime(2575):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
08-10 12:29:52.693: ERROR/AndroidRuntime(2575):     at android.app.ActivityThread.access$2300(ActivityThread.java:125)
08-10 12:29:52.693: ERROR/AndroidRuntime(2575):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
08-10 12:29:52.693: ERROR/AndroidRuntime(2575):     at android.os.Handler.dispatchMessage(Handler.java:99)
08-10 12:29:52.693: ERROR/AndroidRuntime(2575):     at android.os.Looper.loop(Looper.java:123)
08-10 12:29:52.693: ERROR/AndroidRuntime(2575):     at android.app.ActivityThread.main(ActivityThread.java:4627)
08-10 12:29:52.693: ERROR/AndroidRuntime(2575):     at java.lang.reflect.Method.invokeNative(Native Method)
08-10 12:29:52.693: ERROR/AndroidRuntime(2575):     at java.lang.reflect.Method.invoke(Method.java:521)
08-10 12:29:52.693: ERROR/AndroidRuntime(2575):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
08-10 12:29:52.693: ERROR/AndroidRuntime(2575):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
08-10 12:29:52.693: ERROR/AndroidRuntime(2575):     at dalvik.system.NativeStart.main(Native Method)
08-10 12:29:52.693: ERROR/AndroidRuntime(2575): Caused by: java.lang.InstantiationException: com.joshi.remotedoc.Remote_DocActivity
08-10 12:29:52.693: ERROR/AndroidRuntime(2575):     at java.lang.Class.newInstanceImpl(Native Method)
08-10 12:29:52.693: ERROR/AndroidRuntime(2575):     at java.lang.Class.newInstance(Class.java:1429)
08-10 12:29:52.693: ERROR/AndroidRuntime(2575):     at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
08-10 12:29:52.693: ERROR/AndroidRuntime(2575):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2577)
08-10 12:29:52.693: ERROR/AndroidRuntime(2575):     ... 11 more
08-10 12:29:52.693: WARN/ActivityManager(1074):   Force finishing activity 

Her's my main activity class

theisenp
  • 8,639
  • 5
  • 39
  • 47
YoKaGe
  • 385
  • 2
  • 7
  • 15
  • Copy and paste the stacktrace (click the top item, shift+click the button item to select several) and paste it here, rather than the image. Also, include the code around where the exception occurs. – Codeman Aug 10 '11 at 20:50
  • Please extend the "message" field of your LogCat in order to see the exact line where you're getting the RuntimeException. Then, if you still can't figure out what's going wrong, please provide the relevant code at and around that line. – Vinay Aug 10 '11 at 20:51
  • I don't know how to check where in my code the error is coming from – YoKaGe Aug 10 '11 at 20:55

2 Answers2

1

Is your Remote_DocActivity trying to do a lot of stuff in the constructor? Post that code if you are able.

What new code was added just before the application stopped working?

To help narrow things down to where the problem is, I'd suggest you reduce your code to the bare minimum. Comment out everything but the bare essentials. For example, comment out mHandler and try to run your code again. If it works after doing that then you know the problem is located there.

dustmachine
  • 10,622
  • 5
  • 26
  • 28
  • I put up my Main activity calss up hopefully this can help – YoKaGe Aug 10 '11 at 21:50
  • I think it may have something to do with the manifest file, its just that i don't know which activities to declare in my manifest file... Could you possibly help me there? – YoKaGe Aug 10 '11 at 22:13
  • Well, use the same principle of reducing down to the essentials. Remove everything except for the single main activity. You can view sample code for reference (http://developer.android.com/resources/samples/BluetoothChat/AndroidManifest.html). Rather than try to carry on a conversation in question+answer+comment, I suggest the "chat" feature at the very top of the page, there is an Android room in there where back-and-forth dialog is easier. – dustmachine Aug 10 '11 at 22:22
  • Could you create the room because i don't have enough rep – YoKaGe Aug 10 '11 at 22:31
1

It looks like you're not declaring your activity in the Android Manifest.

Make sure you declare any and all activities in the AndroidManifest.xml file as follows:

<activity android:name="MyActivityTitle"
    android:label="@string/activity_title" />

EDIT:

InstantiationException happens when you try to access a constructor that is not within context.

Are all of your class constructors public?

Also, make sure you aren't trying to override any protected constructors.

Codeman
  • 12,157
  • 10
  • 53
  • 91
  • Does that mean that this worked? I might have other ideas if this wasn't it. – Codeman Aug 10 '11 at 21:11
  • i THink that my class constructor public i don't know about the second type. Is there some code i shoudl post?? – YoKaGe Aug 10 '11 at 21:38