Hi grz,
Please check the docs and examples for AsyncTask.

http://developer.android.com/reference/android/os/AsyncTask.html

You probably want to show the dialog in onProgressUpdate or onPostExecute,
both of which are invoked on the UI thread.

Cheers,
James

On Tue, Oct 6, 2009 at 6:53 AM, martin <martinew...@gmail.com> wrote:

>
> hi
>
> I try to open a custom dialog from a asnyctask. I dont get an
> exception, but the dialog just don't shows...
> When i try it from the activity (per example from the onClick-method)
> the dialog shows without a problem. But when i first try it from the
> asynctask and then from the onClick-method it doesn't work anymore...
>
> I followed this tutorial :
> http://developer.android.com/guide/topics/ui/dialogs.html#CustomDialog
>
> my asnytask doInBackground method
> @Override
> protected Object doInBackground(Object... params) {
>  Looper.prepare(); // without this i got an exception, but i dont
> have a idea what's this for...
>
>  try {
>    showDialog(0);
>  } catch (Exception ex) {
>    Log.e(Workout.class.getName(), ex.getMessage(), ex);
>  }
>  return null;
> }
>
>
> my onCreateDialog from the activity
>    protected Dialog onCreateDialog(int id) {
>        Dialog dialog = new Dialog(this);
>
>        dialog.setContentView(R.layout.custom_dialog);
>        dialog.setTitle("Custom Dialog");
>
>        TextView text = (TextView) dialog.findViewById(R.id.text);
>        text.setText("Hello, this is a custom dialog!");
>        return dialog;
>    }
>
>
> has anybody ever tried something similar?
>
> thx for any help
>
> grz
>
> >
>

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

Reply via email to