How to show chooser Intent with my own android app on click of WhatsApp location?

与世无争的帅哥 提交于 2019-12-25 02:26:19

问题


If there's a WhatsApp chat which has location shared, when clicked it shows a chooser intent with some set of applications. I want to write an intent filter so that my application will also be listed there.


回答1:


You can do it by supporting implicit intent to your Activity. Define intent-filter to Activity to which you want to open after clicking to your Application from options.

<activity android:name=".BrowserActivitiy"
          android:label="@string/app_name">

      <intent-filter>
         <action android:name="android.intent.action.VIEW" />
         <category android:name="android.intent.category.DEFAULT" />
         <data android:scheme="http"/>
         <data android:scheme="geo"/>
      </intent-filter>
</activity>

To know more about Intents and Intent filters go to official website. https://developer.android.com/guide/components/intents-filters




回答2:


Add this to your Manifest file (Particular activity):

<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="geo" />
</intent-filter>


来源:https://stackoverflow.com/questions/51631121/how-to-show-chooser-intent-with-my-own-android-app-on-click-of-whatsapp-location

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!