0

I'm new to Android app development and Java in general. I have been watching some tutorials but decided it was time to start doing something on my own. I'm trying to make a fat caliper calculator where I insert all the info in one activity, calculate it and then pass the results on to another activity for displaying it. For some reason I'm getting a force close every time I hit the calculate button and I'm not sure what's causing it or which activity.

Here's the code:

MainActivity

Display

Can you see what's causing the force closes?

Thanks.

granra
  • 318
  • 1
  • 5
  • 17
  • 1
    Could you provide the logcat output which will display the error as to why it force closed. – Boardy Jan 07 '13 at 14:48
  • You are new to android you say. I guess you work with eclipse? If I remember good, it doesn't start Logcat automatically, here is how to do that: http://stackoverflow.com/questions/3280051/how-to-enable-logcat-console-in-eclipse-for-android Then post that info here too – Bigflow Jan 07 '13 at 14:55
  • The right answer is below, I forgot to putExtras into the Intent. – granra Jan 07 '13 at 15:23

3 Answers3

1

The problem is you are starting display Activity but not passing bundle to the Display Activity.

Change your code like this when you are starting Display Activity.

Intent a = new Intent(MainActivity.this, Display.class);
a.putExtras("giveResults",packet );
startActivity(a);
TNR
  • 5,839
  • 3
  • 33
  • 62
1

I believe its because where you are starting your activity, and your bundle, your not adding the bundle to the intent.

You would need to do something like

a.putExtra(packet)

before you start the activity

Boardy
  • 35,417
  • 104
  • 256
  • 447
0

Take a look at this answer. It describes LogCat which is the best way to debug android code.

https://stackoverflow.com/a/3280126/771999

If you use LogCat you can usually pinpoint the exact line number of your issue.

Community
  • 1
  • 1