Sta*_*her 5 android intentfilter
我尝试编写一个Activity作为谷歌地图的替代品.通过google-maps网址调用它时效果很好:
<activity android:name="DataActivity" android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="http" android:host="maps.google.com" />
</intent-filter>
</activity>
Run Code Online (Sandbox Code Playgroud)
但由于某种原因,在使用"geo"-URI启动Intent时它没有显示出来.
我的活动:
<activity android:name="DataActivity" android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="geo" android:host="*" />
</intent-filter>
</activity>
Run Code Online (Sandbox Code Playgroud)
来电者(这启动谷歌地图,但没有选择启动我的应用程序):
final String uri = "geo:" + lat + "," + lng;
startActivity(new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(uri)));
Run Code Online (Sandbox Code Playgroud)
Gor*_*ran 11
尝试
<intent-filter android:priority="0">
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:scheme="geo"/>
</intent-filter>
Run Code Online (Sandbox Code Playgroud)
添加多个方案的正确方法:
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:scheme="geo"/>
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:scheme="google.navigation"/>
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data
android:host="maps.google.com"
android:scheme="https"/>
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data
android:host="maps.google.com"
android:scheme="http"/>
</intent-filter>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4308 次 |
| 最近记录: |