ayoola-solomon / mytracks

Automatically exported from code.google.com/p/mytracks
0 stars 0 forks source link

RuntimeException in Handler.<init>() #679

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
This error happens when update UI in a worker thread(non-main thread). Can we 
add a method , for example handleMessage(String msg) , to handle such issues?

The stack trace of this error:
in v1.1.11
java.lang.RuntimeException: Can't create handler inside thread that has not 
called Looper.prepare()
at android.os.Handler.<init>(Handler.java:121)
at android.widget.Toast.<init>(Toast.java:68)
at android.widget.Toast.makeText(Toast.java:231)
at com.google.android.apps.mytracks.ImportAllTracks.boolean 
importFile(java.io.File,com.google.android.apps.mytracks.content.MyTracksProvide
rUtils)(MT:233)
at com.google.android.apps.mytracks.ImportAllTracks.void 
access$0(com.google.android.apps.mytracks.ImportAllTracks)(MT:97)
at com.google.android.apps.mytracks.ImportAllTracks$1.void run()(MT:89)
at java.lang.Thread.run(Thread.java:1096)

in v1.1.9
java.lang.RuntimeException: Can't create handler inside thread that has not 
called Looper.prepare()
at android.os.Handler.<init>(Handler.java:121)
at android.app.Dialog.<init>(Dialog.java:101)
at android.app.AlertDialog.<init>(AlertDialog.java:63)
at android.app.AlertDialog.<init>(AlertDialog.java:59)
at android.app.AlertDialog$Builder.create(AlertDialog.java:807)
at android.app.AlertDialog$Builder.show(AlertDialog.java:822)
at 
com.google.android.apps.mytracks.ImportAllTracks.aquireLocksAndImport(ImportAllT
racks.java:107)
at 
com.google.android.apps.mytracks.ImportAllTracks.access$0(ImportAllTracks.java:7
8)
at 
com.google.android.apps.mytracks.ImportAllTracks$1.run(ImportAllTracks.java:70)
at java.lang.Thread.run(Thread.java:1096)

Currently I cannot reproduce it, does anybody know the key?

What steps will reproduce the problem?
1.
2.
3.

What is the expected output? What do you see instead?

Please use labels and text to provide additional information.

Original issue reported on code.google.com by youtaol@google.com on 15 Dec 2011 at 6:46

GoogleCodeExporter commented 8 years ago
Please review:

http://code.google.com/r/jshih-mytracks2/source/detail?r=289cc9df92f2436f4f84722
bc0f8c46d63994a9e

Original comment by jshih@google.com on 22 Dec 2011 at 2:27

GoogleCodeExporter commented 8 years ago

Original comment by jshih@google.com on 23 Dec 2011 at 8:30