2010-12-06 68 views
5

J'essaie d'écrire une activité comme une alternative à google maps. Il fonctionne parfaitement lors de l'appel par une URL google maps:Android Intent-filtre pour GEO-URI

<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> 

Mais pour une raison quelconque, il n'a pas montré quand le démarrage d'une intention avec un « géo » -uri.

Mon activité:

<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> 

L'appelant (Cela commence Google Maps sans l'option pour démarrer mon application):

final String uri = "geo:" + lat + "," + lng; 
startActivity(new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(uri))); 
+0

Comment résolvez-vous l'emplacement géographique de votre application pour obtenir les données de localisation? – Radon8472

Répondre

11

essayer avec

<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> 
+0

priorité est obsolète – cV2

5

façon correcte d'ajouter Régimes multiples:

 <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> 
+0

"maps.google.com" sur http et https ne fonctionne pas pour moi, aucun problème connu, avoir un s7 avec 6.0.1 dernière Android ... juste mon application est déclenchée du tout ... – cV2