我正在傳遞一個 Google 地圖 Url 以使用地圖應用程序啟動搜索,并且一切正常。在我的 linux 機器上導入我的項目后,mapIntent.resolveActivity()盡管null設備有谷歌地圖并且gmINtentUri是nullhttps://www.google.com/maps/search/?api=1&query=Spilia%20Beach. 我猜這是由于nullUrl 前面的額外部分引起的。是什么原因造成的?它沒有發生在我的 Windows 機器上。編輯:我發現字符串開頭的gmIntentUri's值是由于這個原因造成的。我稍后會提交答案。nullparcel.writeString(finalMapSearchUrl);@OnClick(R.id.show_in_map_button) void openMap() { Uri gmIntentUri = Uri.parse(placeObject.getMapSearchUrl()); // Create a Uri from a string. Use the result to create an Intent Intent mapIntent = new Intent(Intent.ACTION_VIEW,gmIntentUri); // Make the Intent explicit by settings the Google Maps package mapIntent.setPackage("com.google.android.apps.maps"); // Verify that there is an app available to receive the intent if(mapIntent.resolveActivity(getPackageManager()) != null) { startActivity(mapIntent); // if the result is non-null there is at least one app that can handle the intent } else { Log.d(TAG,"Error resolving Activity for map Intent in openMap(), [Uri = " + gmIntentUri + "]."); Log.d(TAG,"mapIntent.resolveActivity() = " + mapIntent.resolveActivity(getPackageManager())); }}
添加回答
舉報
0/150
提交
取消