Details
-
Type:
Bug
-
Status: Resolved
-
Priority:
Major
-
Resolution: Done
-
Labels:
-
Story Points:3
Description
App has been crashing on step 2 of the wizard work flow.
Win has shared the below :
Shwetha,
I think it's not related to user's credential. I'm seeing the following exception in the log:
06-29 07:51:45.326 1822-1822/com.muzima D/SntpClient﹕ request time failed: android.os.NetworkOnMainThreadException at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1145) at java.net.InetAddress.lookupHostByName(InetAddress.java:385) at java.net.InetAddress.getAllByNameImpl(InetAddress.java:236) at java.net.InetAddress.getByName(InetAddress.java:289) at com.muzima.service.SntpClient.requestTime(SntpClient.java:77) at com.muzima.service.SntpService.getLocalTime(SntpService.java:19) at com.muzima.view.cohort.CohortWizardActivity$3$1.onPostExecute(CohortWizardActivity.java:161) at com.muzima.view.cohort.CohortWizardActivity$3$1.onPostExecute(CohortWizardActivity.java:136) at android.os.AsyncTask.finish(AsyncTask.java:632) at android.os.AsyncTask.access$600(AsyncTask.java:177) at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:645) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:136) at android.app.ActivityThread.main(ActivityThread.java:5017) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595) at dalvik.system.NativeStart.main(Native Method)
The error is saying that we're doing some HTTP connection in the main UI thread. And the offending line of code is the call to get the sntp time to calculate the last sync date.
@Override protected void onPostExecute(int[] result) { dismissProgressDialog(); if (result[0] != SUCCESS) { Toast.makeText(CohortWizardActivity.this, "Could not download clients", Toast.LENGTH_SHORT).show(); } Log.i(TAG, "Restarting timeout timer!") ; ((MuzimaApplication) getApplication()).restartTimer(); try { LastSyncTimeService lastSyncTimeService = ((MuzimaApplication)getApplicationContext()).getMuzimaContext().getLastSyncTimeService(); SntpService sntpService = ((MuzimaApplication)getApplicationContext()).getSntpService(); LastSyncTime lastSyncTime = new LastSyncTime(DOWNLOAD_COHORTS, sntpService.getLocalTime()); lastSyncTimeService.saveLastSyncTime(lastSyncTime); } catch (IOException e) { Log.i(TAG,"Error setting cohort sync time."); } keepPhoneAwake(false) ; navigateToNextActivity(); }
Maybe we should either remove this or do the last sync time differently?
Gliffy Diagrams
Attachments
Issue Links
- relates to
-
MUZIMA-56 Ensure application data is empty before starting wizard
-
- Resolved
-