gpt4 book ai didi

android - 在特定位置从我的应用打开街景

转载 作者:太空狗 更新时间:2023-10-29 14:39:19 26 4
gpt4 key购买 nike

我正在尝试从我的 Android 应用程序以全景模式打开 Google 街景。

我真的很想打开 Google StreetView 而不是 Google map ,因为我想将它与使用 VR Glass 的虚拟现实应用程序一起使用,该应用程序使用立体 View 和全景模式。我想要的全景模式是这样的:https://youtu.be/3mQKGEnWxIw

以下代码打开 StreetView 应用程序:

PackageManager pm = this.getPackageManager();
Intent intent = pm.getLaunchIntentForPackage("com.google.android.street");
startActivity(intent);

但它在默认屏幕上打开。

编辑 1:

我发现了如何打开街景的全景 Activity。首先,我列出了应用程序中的可用 Activity :

void listAppActivities(String packagename) {
PackageManager pManager = getPackageManager();
Intent startIntent = new Intent();
startIntent.setPackage(packagename);

List<ResolveInfo> activities = pManager.queryIntentActivities(startIntent, 0);
for (ResolveInfo ri : activities) {
System.out.println("getAppActivities::nome::" + ri.activityInfo.name);
}

}

然后我使用了 Activity com.google.vr.app.StreetViewApp.StreetViewApp。我可以使用以下代码直接启动 StreetView Panorama Activity:

void openStreetView() {
String packagename = "com.google.android.street";
PackageManager pm = this.getPackageManager();
Intent intent = pm.getLaunchIntentForPackage(packagename);
intent.setComponent(new ComponentName(packagename, "com.google.vr.app.StreetViewApp.StreetViewApp"));
startActivity(intent);
}

但我仍然不知道如何将位置参数传递给 StreetView。我该怎么做?

我已经使用 URI 进行了测试:

Uri gmmIntentUri;
//gmmIntentUri = Uri.parse("geo:"+lat+","+lng); // Test1
gmmIntentUri = Uri.parse("google.streetview:cbll="+lat+","+lng); // Test2
//gmmIntentUri = Uri.parse("http://maps.google.com/maps?ll="+lat+","+lng); // Test3
intent.setData(gmmIntentUri);

并使用 Intent.putExtra:

intent.putExtra("cbll", lat+","+lng);
intent.putExtra("args", "cbll="+lat+","+lng);
intent.putExtra("lat", new Double(lat));
intent.putExtra("long", new Double(lng));
intent.putExtra("lng", new Double(lng));

但是没有成功。有谁知道如何在全景模式下将位置参数传递给街景应用程序?

编辑 2:

我发现,如果我使用街景突出显示链接或特色位置,则可以在全景模式下打开街景,并传递 URI Intent。我测试了以下链接:

https://www.google.com/streetview/#christmas-island/ethel-beach-2 https://www.google.com/streetview/#russian-landmarks/terskol-1 https://www.google.com/streetview/#day-of-the-dead-in-mexico/ofrenda-dia-de-muertos-zocalo

可以在这里找到更多: https://www.google.com/streetview/

但仍然不知道如何传递通用位置。

最佳答案

以下是使用传递的坐标打开 Google 街景的方法:

(我刚刚测试了它,它按预期工作)

private void openStreetView (double latitude, double longitude) {
Uri gmmIntentUri = Uri.parse ("google.streetview:cbll=" + latitude + "," + longitude);

Intent mapIntent = new Intent (Intent.ACTION_VIEW, gmmIntentUri);
mapIntent.setPackage ("com.google.android.apps.maps");

startActivity (mapIntent);
}

你很接近!您犯的错误是您在第三个代码 fragment 中用不正确的 Uri 覆盖了 Uri :)

这里有更多详细信息:https://developers.google.com/maps/documentation/urls/android-intents

关于android - 在特定位置从我的应用打开街景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51083188/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com