我正在传递一个 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
提交
取消