有沒有人有一個想法,爲什麼以下吐司不出現? 日誌被印刷在同一功能的另一土司也正在吐司消息不服務意圖
if (searchType.equals("ByName")){
// get the extra from the intent:
String query = intent.getStringExtra("query");
if (!searchByName(query)){
Toast.makeText(getApplicationContext(), "No results for this search",
Toast.LENGTH_LONG).show();
Log.d(TAG, "return status true/false -->" + searchByName(query));
}
}
任何幫助將不勝感激
我附加日誌,我不得不刪除一些行,因爲它太長了.. 。 這裏是日誌:
01-15 10:22:39.267: D/FragmentList(2035): doSearchByName
01-15 10:22:39.267: D/FragmentList(2035): query -> asdgasdgsdagas
01-15 10:22:39.271: D/FragmentList(2035): ByName
01-15 10:22:39.283: D/FragmentList(2035): currentLocation
01-15 10:22:39.303: D/SearchPlacesSevice(2035): onHandleIntentstart
01-15 10:22:39.303: D/SearchPlacesSevice(2035): ByName
01-15 10:22:39.303: D/SearchPlacesSevice(2035): searchByName
01-15 10:22:39.303: D/GooglePlaces(2035): query -> asdgasdgsdagas
01-15 10:22:39.307: D/GooglePlaces(2035): https://maps.googleapis.com/maps/api/place/textsearch/json?query=asdgasdgsdagas&sensor=false&key=AIzaSyBDi3A3ZLFQPm1I9sUsYasxtwndQjn7mfQ
01-15 10:22:39.879: D/GooglePlaces(2035): {
01-15 10:22:39.879: D/GooglePlaces(2035): "debug_info" : [],
01-15 10:22:39.879: D/GooglePlaces(2035): "html_attributions" : [],
01-15 10:22:39.879: D/GooglePlaces(2035): "results" : [],
01-15 10:22:39.879: D/GooglePlaces(2035): "status" : "ZERO_RESULTS"
01-15 10:22:39.879: D/GooglePlaces(2035): }
01-15 10:22:39.879: D/SearchPlacesSevice(2035): {
01-15 10:22:39.879: D/SearchPlacesSevice(2035): "debug_info" : [],
01-15 10:22:39.879: D/SearchPlacesSevice(2035): "html_attributions" : [],
01-15 10:22:39.879: D/SearchPlacesSevice(2035): "results" : [],
01-15 10:22:39.879: D/SearchPlacesSevice(2035): "status" : "ZERO_RESULTS"
01-15 10:22:39.879: D/SearchPlacesSevice(2035): }
01-15 10:22:39.879: D/SearchPlacesSevice(2035): ZERO_RESULTS
01-15 10:22:39.883: D/SearchPlacesSevice(2035): Status -->ZERO_RESULTS
01-15 10:22:39.887: D/SearchPlacesSevice(2035): searchByName
01-15 10:22:39.887: D/GooglePlaces(2035): query -> asdgasdgsdagas
01-15 10:22:39.887: D/GooglePlaces(2035): https://maps.googleapis.com/maps/api/place/textsearch/json?query=asdgasdgsdagas&sensor=false&key=AIzaSyBDi3A3ZLFQPm1I9sUsYasxtwndQjn7mfQ
01-15 10:22:40.083: D/SearchPlacesSevice(2035): {
01-15 10:22:40.083: D/SearchPlacesSevice(2035): "debug_info" : [],
01-15 10:22:40.083: D/SearchPlacesSevice(2035): "html_attributions" : [],
01-15 10:22:40.083: D/SearchPlacesSevice(2035): "results" : [],
01-15 10:22:40.083: D/SearchPlacesSevice(2035): "status" : "ZERO_RESULTS"
01-15 10:22:40.083: D/SearchPlacesSevice(2035): }
01-15 10:22:40.087: D/SearchPlacesSevice(2035): ZERO_RESULTS
01-15 10:22:40.087: D/SearchPlacesSevice(2035): Status -->ZERO_RESULTS
01-15 10:22:40.091: D/SearchPlacesSevice(2035): return status true/false -->false
01-15 10:22:43.387: W/MessageQueue(2035): Handler (android.os.Handler) {535afd88} sending message to a Handler on a dead thread
01-15 10:22:43.387: W/MessageQueue(2035): java.lang.RuntimeException: Handler (android.os.Handler) {535afd88} sending message to a Handler on a dead thread
01-15 10:22:43.387: W/MessageQueue(2035): at android.os.MessageQueue.enqueueMessage(MessageQueue.java:294)
01-15 10:22:43.387: W/MessageQueue(2035): at android.os.Handler.sendMessageAtTime(Handler.java:473)
01-15 10:22:43.387: W/MessageQueue(2035): at android.os.Handler.sendMessageDelayed(Handler.java:446)
01-15 10:22:43.387: W/MessageQueue(2035): at android.os.Handler.post(Handler.java:263)
01-15 10:22:43.387: W/MessageQueue(2035): at android.widget.Toast$TN.hide(Toast.java:363)
01-15 10:22:43.387: W/MessageQueue(2035): at android.app.ITransientNotification$Stub.onTransact(ITransientNotification.java:55)
01-15 10:22:43.387: W/MessageQueue(2035): at android.os.Binder.execTransact(Binder.java:367)
01-15 10:22:43.387: W/MessageQueue(2035): at dalvik.system.NativeStart.run(Native Method)
01-15 10:23:42.003: D/dalvikvm(2035): GC_CONCURRENT freed 434K, 6% free 8502K/9031K, paused 1ms+1ms, total 8ms
試着給自己的活動範圍內,而不是getApplicationContext。 –
你在哪裏試圖展示它?我的意思是,它是否在一個活動? – nKn
不可能,如果你的日誌**返回狀態真/假 - > **打印出來,然後用你爲Toast顯示的代碼必須執行,會出錯。 – user370305