I want to get data from MySQL database using PHP and display it in Android activity. I code it and pass JSON Array but there is a problem i dont know how to connect to server and my all database is on local server. I code it Kindly tell me where i go wrong so I can get exact results. I’ll be very thankful to you.
my all database is in localhost and it is not opening an activity. displays an error “Stopped unexpectedly”:( How can i get exact results. Kindly guide me
now it gives these errors:( and and loading saved details
12-08 11:09:19.314: E/WindowManager(19972): Activity com.example.visit.record.My_Task has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@40555850 that was originally added here
12-08 11:09:19.314: E/WindowManager(19972): android.view.WindowLeaked: Activity com.example.visit.record.My_Task has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@40555850 that was originally added here
12-08 11:09:19.314: E/WindowManager(19972): at android.view.ViewRoot.<init>(ViewRoot.java:277)
12-08 11:09:19.314: E/WindowManager(19972): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:148)
12-08 11:09:19.314: E/WindowManager(19972): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
12-08 11:09:19.314: E/WindowManager(19972): at android.view.Window$LocalWindowManager.addView(Window.java:433)
12-08 11:09:19.314: E/WindowManager(19972): at android.app.Dialog.show(Dialog.java:288)
12-08 11:09:19.314: E/WindowManager(19972): at com.example.visit.record.My_Task$GetTaskDetails.onPreExecute(My_Task.java:149)
12-08 11:09:19.314: E/WindowManager(19972): at android.os.AsyncTask.execute(AsyncTask.java:391)
12-08 11:09:19.314: E/WindowManager(19972): at com.example.visit.record.My_Task.onCreate(My_Task.java:107)
12-08 11:09:19.314: E/WindowManager(19972): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)
12-08 11:09:19.314: E/WindowManager(19972): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1785)
12-08 11:09:19.314: E/WindowManager(19972): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1842)
12-08 11:09:19.314: E/WindowManager(19972): at android.app.ActivityThread.access$1500(ActivityThread.java:132)
12-08 11:09:19.314: E/WindowManager(19972): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1038)
12-08 11:09:19.314: E/WindowManager(19972): at android.os.Handler.dispatchMessage(Handler.java:99)
12-08 11:09:19.314: E/WindowManager(19972): at android.os.Looper.loop(Looper.java:143)
12-08 11:09:19.314: E/WindowManager(19972): at android.app.ActivityThread.main(ActivityThread.java:4268)
12-08 11:09:19.314: E/WindowManager(19972): at java.lang.reflect.Method.invokeNative(Native Method)
12-08 11:09:19.314: E/WindowManager(19972): at java.lang.reflect.Method.invoke(Method.java:507)
12-08 11:09:19.314: E/WindowManager(19972): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
12-08 11:09:19.314: E/WindowManager(19972): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
12-08 11:09:19.314: E/WindowManager(19972): at dalvik.system.NativeStart.main(Native Method)
Currently you are Trying to access Ui elements or
runOnUiThreadinsidedoInBackgroundinGetProductDetailsAsyncTaskclass . because it’s not possible to access UI elements fromdoInBackgroundyou can useonPreExecuteandonPostExecutefor updating UI elements.Change your code as without usingrunOnUiThreador UI elements insidedoInBackground:and Change your onCreate code as: