Autore Topic: Progress Dialog non visualizzata  (Letto 735 volte)

Offline ibrido90

  • Nuovo arrivato
  • *
  • Post: 29
  • Respect: 0
    • Mostra profilo
  • Dispositivo Android:
    Samsung Galaxy Ace
Progress Dialog non visualizzata
« il: 03 Settembre 2012, 16:27:30 CEST »
0
Ciao a tutti, ho un problema in questo frammento di codice:
Codice (Java): [Seleziona]
public class MyDownloadThread extends AsyncTask<Object,Boolean,String>{
        ProgressDialog pd;
        Context c;
        String str = "";

        public MyDownloadThread(Context app) {
                // TODO Auto-generated constructor stub
                c=app;
       
        }

        @Override
        protected void onPreExecute() {
                // TODO Auto-generated method stub
                pd = ProgressDialog.show(c, "Executing", "please wait...",false,false);
                super.onPreExecute();
        }
       
        @Override
        protected void onPostExecute(String result) {
                // TODO Auto-generated method stub
                pd.dismiss();
                super.onPostExecute(result);
               
        }
Il LogCat:

09-03 16:25:35.019: E/AndroidRuntime(18814): android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application
09-03 16:25:35.019: E/AndroidRuntime(18814):    at android.view.ViewRoot.setView(ViewRoot.java:536)
09-03 16:25:35.019: E/AndroidRuntime(18814):    at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:177)
09-03 16:25:35.019: E/AndroidRuntime(18814):    at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
09-03 16:25:35.019: E/AndroidRuntime(18814):    at android.app.Dialog.show(Dialog.java:241)
09-03 16:25:35.019: E/AndroidRuntime(18814):    at android.app.ProgressDialog.show(ProgressDialog.java:107)
09-03 16:25:35.019: E/AndroidRuntime(18814):    at android.app.ProgressDialog.show(ProgressDialog.java:95)
09-03 16:25:35.019: E/AndroidRuntime(18814):    at log.in.MyDownloadThread.onPreExecute(MyDownloadThread.java:40)
09-03 16:25:35.019: E/AndroidRuntime(18814):    at android.os.AsyncTask.execute(AsyncTask.java:391)
09-03 16:25:35.019: E/AndroidRuntime(18814):    at log.in.MyMain.startWebServiceTask(MyMain.java:78)
09-03 16:25:35.019: E/AndroidRuntime(18814):    at log.in.MyMain.onClick(MyMain.java:70)
09-03 16:25:35.019: E/AndroidRuntime(18814):    at android.view.View.performClick(View.java:2485)
09-03 16:25:35.019: E/AndroidRuntime(18814):    at android.view.View$PerformClick.run(View.java:9080)
09-03 16:25:35.019: E/AndroidRuntime(18814):    at android.os.Handler.handleCallback(Handler.java:587)
09-03 16:25:35.019: E/AndroidRuntime(18814):    at android.os.Handler.dispatchMessage(Handler.java:92)
09-03 16:25:35.019: E/AndroidRuntime(18814):    at android.os.Looper.loop(Looper.java:130)
09-03 16:25:35.019: E/AndroidRuntime(18814):    at android.app.ActivityThread.main(ActivityThread.java:3687)
09-03 16:25:35.019: E/AndroidRuntime(18814):    at java.lang.reflect.Method.invokeNative(Native Method)
09-03 16:25:35.019: E/AndroidRuntime(18814):    at java.lang.reflect.Method.invoke(Method.java:507)
09-03 16:25:35.019: E/AndroidRuntime(18814):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
09-03 16:25:35.019: E/AndroidRuntime(18814):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
09-03 16:25:35.019: E/AndroidRuntime(18814):    at dalvik.system.NativeStart.main(Native Method)

Se mi potete essere di auto vi ringrazio :)
Yes i am noob :)

Offline Vlad

  • Utente normale
  • ***
  • Post: 271
  • Respect: +16
    • Github
    • Google+
    • vmihalachi
    • vmihalachi
    • Mostra profilo
    • vmihalachi.com
  • Dispositivo Android:
    Samsung galaxy s2 | Samsung galaxy tab 7
  • Play Store ID:
    Vlad Mihalachi
  • Sistema operativo:
    Windows 8
R: Progress Dialog non visualizzata
« Risposta #1 il: 03 Settembre 2012, 17:22:48 CEST »
0
Dove e il doInBacground ?

Offline ibrido90

  • Nuovo arrivato
  • *
  • Post: 29
  • Respect: 0
    • Mostra profilo
  • Dispositivo Android:
    Samsung Galaxy Ace
Re:Progress Dialog non visualizzata
« Risposta #2 il: 03 Settembre 2012, 17:43:51 CEST »
0
Codice (Java): [Seleziona]
@Override
        protected String doInBackground(Object... p) {
                // TODO Auto-generated method stub
               
               
                String text;
                String URL = (String)p[0];
                String email = MyMain.getEmail();
                String password = MyMain.getPass();
                text=postLoginData(URL, email, password);
                return text;
        }

Dove e il doInBacground ?
lol me ne ero dimenticato :D
Yes i am noob :)