AlertDialog in onCreate - please help

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

AlertDialog in onCreate - please help

Postby radhoo » Fri Sep 04, 2009 10:43 pm

Hi every1.

I use AlertDialog to display short messages like:

new AlertDialog.Builder(v.getContext())
.setTitle("KBDrv")
.setMessage("About")
//.setPositiveButton(android.R.string.ok, null)
.show();
for eg. in a button onClick callback (View v).

Now the problem is I don't know how to replace the v.getContext() for displaying the message box in onCreate.

"09-05 00:33:08.455: WARN/WindowManager(59): Attempted to add window with non-application token WindowToken{430b0b78 token=null}. Aborting."

putting this or this.getApplicationContext() results in application crash an no dialog is displayed.


Please advise. This is urgent.
radhoo
Freshman
Freshman
 
Posts: 3
Joined: Wed May 13, 2009 11:08 am

Top

Re: AlertDialog in onCreate - please help

Postby radhoo » Sat Sep 05, 2009 9:28 am

radhoo wrote:I use AlertDialog to display short messages like:


Found the issue. in OnCreate the application window is not yet created, so a view is not available.

Putting the messagebox code in onStart works.

public void onStart()
{
super.onStart();
Log.d("ONStart", "onstart");
new AlertDialog.Builder(this)
.setTitle("Bluetooth UI")
.setMessage("To use this software, ...")
.show();

Hope this helps others.
radhoo
Freshman
Freshman
 
Posts: 3
Joined: Wed May 13, 2009 11:08 am

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 3 guests