Hello Mark,
thanks for looking into that with me.

The problem is the Button Object which does not get instantiated correctly,
i guess this is what null is. i can let it crash now like this:

theButtonBtn  = (Button) findViewById(R.id.ButtonTheButton);
Log.d("EditYourSettings","Before accessing ID");
Log.d("EditYourSettings",""+theButtonBtn .getId());   // it crashed here -
first access to the Button Object.

Is there anything I do wrong getting the Button?

How do you actually debug an android app with eclipse? Can you step through
the code and check if a variable is null? Like on a normal java app? When i
click on debug and set a breakpoint, it never stops. It just installs it on
the device.

Toby

On Sat, Aug 22, 2009 at 6:59 AM, Mark Murphy <[email protected]>wrote:

>
> Tobias Eisentraeger wrote:
> > Hello,
> >
> > I have trouble launching the WebBrowser with an Intent with a Button
> > Click. I try doing this in the onCreate Method of my Activity:
> >
> > final Button getTheButtonBtn = (Button)
> > this.findViewById(R.id.ButtonTheButton);
> > getTheButtonBtn.setOnClickListener(new View.OnClickListener() {
> >             public void onClick(View view) {
> >              // Browser oeffnen mit url
> >              Intent i = new Intent(Intent.ACTION_VIEW ,
> > Uri.parse("http://www.url.com) );
> >      startActivity(i);
> >             }
> >         });
> >
> > Its in the View like this:
> > <Button android:text="@string/button_ButtonTheButton_hint"
> > android:id="@+id/ButtonTheButton" android:layout_width="wrap_content"
> > android:layout_height="wrap_content"></Button>
> >
> > When i launch the Activity i get a force close with this in the log:
> >
> > 08-22 12:47:35.832: ERROR/AndroidRuntime(1826): Uncaught handler: thread
> > main exiting due to uncaught exception
> > 08-22 12:47:35.942: ERROR/AndroidRuntime(1826):
> > java.lang.RuntimeException: Unable to start activity
> >
> ComponentInfo{com.mycompany.APPName/com.mycompany.APPName.EditYourSettingActivity}:
> > java.lang.NullPointerException
>
> <snip>
>
> > 08-22 12:47:35.942: ERROR/AndroidRuntime(1826): Caused by:
> > java.lang.NullPointerException
> > 08-22 12:47:35.942: ERROR/AndroidRuntime(1826):     at
> >
> com.mycompany.APPName.EditYourSettingActivity.onCreate(EditYourSettingActivity.java:43)
>
> Look at line 43 of EditYourSettingActivity -- it should be in onCreate()
> -- and figure out why you are trying to use a null pointer.
>
> --
> Mark Murphy (a Commons Guy)
> http://commonsware.com | http://twitter.com/commonsguy
>
> Android Development Wiki: http://wiki.andmob.org
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to