当用户打开网站时,如果未安装应用程序,如何安装应用程序?

时间:2011-01-18 10:46:20

标签: android

我有一个网站和一个Android应用程序。当用户从他的Android设备访问该网站时,我想为用户提供安装此应用程序的链接,但前提是尚未安装该应用程序。有没有办法做到这一点?

1 个答案:

答案 0 :(得分:1)

是。您可以查看条形码扫描仪以获取详细信息。它基本上是这样的:

步骤1:在您的网站上创建一个网页,“嘿!你没有我的应用程序!点击这个真正闪亮的按钮下载它!”。确保此网页具有简单的URL(例如,不依赖于查询参数)。有闪亮的按钮链接到appropriate Market URL,或者您正在分发您的应用程序。

步骤2:在您的应用中创建一个活动,并为其指定<intent-filter>个相应的<data>元素,表示它将处理该网址的链接。您还需要为过滤器指定BROWSEABLE类别,并可能为text/html MIME类型。

步骤3:当用户单击链接并且已安装应用程序时,让活动执行您希望它执行的操作。这可能意味着您的<intent-filter>会使用现有活动而不是新活动 - 我无法分辨您的预期行为。


修改

以下是条码扫描器的相关<intent-filter>

<!-- Allow web apps to launch Barcode Scanner by linking to http://zxing.appspot.com/scan. -->
      <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="zxing.appspot.com" android:path="/scan"/>
      </intent-filter>

如果您在常规浏览器中访问the link,则会获得一个网页。