[英]How to open a specific activity from an external link clicking
I know this question is not new, but its a bit different from already asked questions.我知道这个问题并不新鲜,但它与已经提出的问题有点不同。 I have a website that provides links to my app.
我有一个网站,提供指向我的应用程序的链接。 The links direct users to specific data on my app.
这些链接将用户引导至我的应用程序上的特定数据。 This is the layout of my app: I have 4 activities as Activity1.class, Activity2.class, Activity3.class, and of course the MainActivity.class which is the launcher activity.
This is the layout of my app: I have 4 activities as Activity1.class, Activity2.class, Activity3.class, and of course the MainActivity.class which is the launcher activity.
My worry is this: On my website, I have 3 buttons: button 1 goes to open directly Activity1 on my app (assuming the app is already installed on the device), Button 2 on website opens Activity2 in my app.我担心的是:在我的网站上,我有 3 个按钮:按钮 1 直接打开我的应用程序上的 Activity1(假设该应用程序已安装在设备上),网站上的按钮 2 在我的应用程序中打开 Activity2。
Note: the app and the website are not by any means linked.
注意:应用程序和网站未以任何方式链接。
My question is: how to get a URL link to specific activity on my app.我的问题是:如何在我的应用程序上获得指向特定活动的 URL 链接。 I need 3 URLs that open different 3 activities.
我需要 3 个 URL 来打开不同的 3 个活动。 I need these links for external use, such that they open a specified activity whey clicked.
我需要这些链接供外部使用,以便它们打开单击的指定活动。
Something like: http://myapppackage/ACTIVITY1 .类似于: http://myapppackage/ACTIVITY1 。
This is just an example.这只是一个例子。
In you AndroidManifest.xml add intent-filters to the activities like this在您的 AndroidManifest.xml 中,将意图过滤器添加到这样的活动中
<activity android:name=".ACTIVITY1">
<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="myapppackage"
android:pathPattern="/ACTIVITY1" />
</intent-filter>
</activity>
<activity android:name=".ACTIVITY2">
<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="myapppackage"
android:pathPattern="/ACTIVITY2" />
</intent-filter>
</activity>
<activity android:name=".ACTIVITY3">
<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="myapppackage"
android:pathPattern="/ACTIVITY3" />
</intent-filter>
</activity>
For more info check this out有关更多信息,请查看
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.