2010-12-06 4 views
5

私はGoogleマップの代替としてアクティビティを作成しようとしています。グーグルマップのURLでそれを呼び出すとき これは完璧に動作します:Androidの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> 

しかし、「地理」-uriとの意向を開始するとき、それがアップ示されていないいくつかの理由があります。

My活動:

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

発信者(これは私のアプリを起動するためのオプションを使用せずにGoogleマップを起動する):

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

位置情報を取得するためにアプリ内のジオURIをどのように解決しますか? – Radon8472

答えて

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

priority is obsolete – cV2

5

を追加するための正しい方法を試してみてください複数のスキーム:

 <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

httpとhttpsの "maps.google.com"は私のためには機能しません。問題は知られていて、6.0.1の最新のAndroid搭載のs7を持っています... – cV2

関連する問題