如何从我的应用程序打开其他应用程序的特定活动?

时间:2017-01-18 15:34:41

标签: android android-intent uri geo google-street-view

我正在开发一个应用程序,打开其他具有意图的应用程序,它运行正常,但现在我需要打开一个特定的活动(或应用程序的一部分),我不知道它是否&#39甚至可能。

在这种情况下,我想从Google Cardboard应用中打开街景视图。我无法弄清楚或找到做到这一点的方法。

这是我使用的意图(虽然有效,但没有完全填写任务):

public void actionOpenCardboard(View view) {
    Intent launchIntent = getPackageManager().getLaunchIntentForPackage("com.google.samples.apps.cardboarddemo");
    if (launchIntent != null) {
        startActivity(launchIntent);
    }
}

2 个答案:

答案 0 :(得分:1)

您可以通过以下方式启动x

Activity

此外,您可能需要将Intent intent = new Intent(); intent.setComponent(new ComponentName("com.example", "com.example.MyExampleActivity")); startActivity(intent); 添加到要调用上述代码的android:exported="true"清单中。

答案 1 :(得分:0)

你必须了解" Google Cardboard app"打开街景"街景"什么参数是必要的(即当前的纬度,经度,变焦等级)。

如果你很幸运,IntentIntercept app可以帮助你找到必要的意图细节。

如果你只需要一张地图,那么地图来自" Google Cardboard app"或任何其他地图应用程序,您可以尝试ACTION_VIEW与geo uri。

private void onButtonClick[] {
    double lat = 52.1;
    double lon = 9.2;
    double zoom = 10;

    // no need for  de.k3b.geo-lib for simple request:
    String uriGeoSimple = String.format(Locale.ENGLISH, 
                "geo:0,0?q=%f,%f&z=%f", lat, lon,zoom);

    // (1) GEOClientActivity creates and sends an android ACTION_VIEW intent 
    // with coordinate
    Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uriGeoSimple));
    startActivity(intent);
}

有关详细信息,请参阅

如果您已找到" Google Cardboard app"所需的意图详细信息。请随意将信息添加到https://github.com/k3b/k3b-geoHelper/wiki/Android-Geo-aware-apps

相关问题