Hi,
I understood what you were trying to say. Here's what I;'m doing now:

class ConnectionsListAddScreen extends Activity{
       public void onCreate(Bundle savedInstState){
            super.onCreate(savedInstState);
            //here on particular button click
            new ConnReqSenderAsyncTask().execute();

       }

       protected Dialog onCreateDialog(int id) {
                Dialog dialog = new Dialog(ConnectionsListAddScreen.this);
                switch(id){
                        case Constants.LOGIN_DIALOG:    ProgressDialog pg = new
ProgressDialog(ConnectionsListAddScreen.this);
                                                        pg.setMessage(//some 
string);
                                                        pg.setCancelable(true);
                                                        dialog = pg;
                                                        break;
                        default:        return super.onCreateDialog(id);

                }
                return dialog;
        }

}

private class ConnReqSenderAsyncTask extends
AsyncTask<Void,Void,Void>{

        protected Void doInBackground(Void... params) {
              //send request to server
              return null;
        }

        protected void onPreExecute() {
                super.onPreExecute();
                showDialog(Constants.LOGIN_DIALOG);
        }

        protected void onPostExecute(Void result) {
                super.onPostExecute(result);
                dismissDialog(Constants.LOGIN_DIALOG);
        }
}

If the above is right. Then the problem is on Orientation Change it
throws below exception:

FATAL EXCEPTION: main
java.lang.IllegalArgumentException: no dialog with id 5 was ever shown
via Activity#showDialog
at android.app.Activity.missingDialog(Activity.java:2590)
at android.app.Activity.dismissDialog(Activity.java:2575)
at com.sap.explorer.view.ConnectionsListAddScreen
$ConnReqSenderAsyncTask.onPostExecute(ConnectionsListAddScreen.java:
699)
at com.sap.explorer.view.ConnectionsListAddScreen
$ConnReqSenderAsyncTask.onPostExecute(ConnectionsListAddScreen.java:1)
at android.os.AsyncTask.finish(AsyncTask.java:417)
at android.os.AsyncTask.access$300(AsyncTask.java:127)
at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:
429)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4627)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit
$MethodAndArgsCaller.run(ZygoteInit.java:868)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)

Since we are using showDialog(...) and onCreateDialog(...) for
ProgressDialog display, then shouldn't Android keep a reference of
same on orientation change. Can you let me know if there are any
mistakes in my code or solution to my problem asap.


On Jun 16, 4:02 pm, sahana uday <[email protected]> wrote:
> Hi,
> Yes I'm sending the request to server in onCreateDialog(), but its an
> AsyncTask.
> In onPreExecute() show theprogressdialogand onPostExecute() cancel
> theprogressdialog.
>
> Off late I have anotherissuein computing textview height, I have
> posted thisissueon a separate thread also.
> The issues is:
>         How to compute TextView Height before its laid out on screen?
>
>         I'm not aware how we can use getPaint().ascent() or descent()
> method
>         for computing height?
>
>         Can you please provide an example
>
> On Jun 6, 6:38 pm, Streets Of Boston <[email protected]> wrote:
>
> > Are you sending a request to the server in the implementation of the
> > 'onCreateDialog(...)' method? If so, this is not good. The onCreateDialog is
> > called by the OS when the hosting activity is recreated due to a config
> >changewhen adialogis shown using the showDialog method (i.e. an
> > activity-manageddialog). This is perfectly normal behavior.
>
> > Call 'showDialog' just *after *you send an (asynchronous) request to the
> > server and call 'dismissDialog' when the server returns a response. Usually,
> > do not code anything in the onCreateDialog except for building an
> > AlertDialog object.
>
>

-- 
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