Eli*_*ine 27 navigation android android-intent
在我的应用程序中,我可以选择开始导航到选定的POI.基本上我想要的是从我的应用程序中启动一个转弯导航器.问题是我不知道安装了哪个(如果有的话)导航器.
那么,问题是如何通过显示一个合适的活动列表来启动一个意图,以便首先导航给用户,让他选择他想要使用哪一个?也很高兴找到一种方法将额外的参数传递给选定的活动(这听起来像是一个问题,因为不同的导航应用程序使用不同的名称为他们的额外,我猜).
如果不清楚:我正在寻找一种方法来显示一个适用于导航的应用程序列表,并提供一个默认选项.
编辑:在这里找到实施http://datamoil.blogspot.com/2011/04/android-universal-intent-to-start.html
Phi*_*llo 21
坏消息是,没有用于导航的标准Intent URI.
是的,存在google.navigation URI,应用可能会选择支持它.
我能想到的最佳解决方案是:
您可以使用PackageManage.queryIntentActivities枚举可能的隐式目标
pum*_*kee 12
尝试:
Intent intent = new Intent(Intent.ACTION_VIEW,
Uri.parse("google.navigation:q=New+York+NY"));
startActivity(intent);
Run Code Online (Sandbox Code Playgroud)
小智 5
首先,我在我的onTap
方法中使用了按钮的监听器:
Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse("google.navigation:q=New+York+NY"));
mContext.startActivity(i);
Run Code Online (Sandbox Code Playgroud)
然后在清单中使用:
<activity android:name=".LaunchGPS" android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
Run Code Online (Sandbox Code Playgroud)
这将打开您的手机具有的任何Navigator应用程序,例如VZ Navigagtor,Google或手机所加载的任何内容.第一次完美地为我工作.希望这能解决你的问题.