【问题标题】:my app is not showing in the list to open shared location我的应用未显示在打开共享位置的列表中
【发布时间】:2019-11-27 13:39:49
【问题描述】:

您好,我正在开发一个应用程序以在应用程序内的谷歌地图片段上打开共享位置。当用户触摸共享的位置链接时,我的应用程序应显示在打开列表中。这是我的清单

这是我通过添加意图过滤器尝试的方法

<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="http" android:host="maps.google.com" android:pathPattern="/maps"/>
  <data android:scheme="https" android:host="maps.google.com" android:pathPattern="/maps"/>
  <data android:scheme="geo"/>
</intent-filter>

我希望在点击位置时,我的应用会以对话方式打开。

【问题讨论】:

  • 目前的行为是什么,你能具体说明一下吗?

标签: android intentfilter deeplink


【解决方案1】:

我已尝试使用此清单条目,它对我有用。

<activity
        <intent-filter>  
          <!-- Filter to run activity without geo --> 
            <action android:name="com.example.MYACTION" />                
            <category android:name="android.intent.category.DEFAULT" />                     
        </intent-filter>
        <intent-filter>   
            <!-- Filter for geo scheme geo -->                  
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />               
            <data android:scheme="geo" />
        </intent-filter>
    </activity>

My Activity 的 onCreate() 如下所示

protected void onCreate(Bundle savedInstanceState) {
  Intent intent = getIntent();  
  String action = intent.getAction();
  Uri data = intent.getData();

  if(Intent.ACTION_VIEW.equals(action) ) {
    if(data != null && "geo".equals(data.getScheme())) {  

      // Displaying map when there is geo Data
    }
  }
  else {
    // Other code when there is no geo DATA from intent
  }
}

你可以试试告诉我。

【讨论】:

  • @XeonTechnologies 很高兴知道这有帮助。如果它解决了您的问题,您可以投票并接受。
猜你喜欢
  • 1970-01-01
  • 2023-01-12
  • 1970-01-01
  • 2015-08-12
  • 1970-01-01
  • 2015-01-10
  • 1970-01-01
  • 2013-06-19
  • 2015-07-04
相关资源
最近更新 更多