Android:如何在浏览器中保存所有应用程序都可以访问的内容?

发布于 2024-12-01 02:45:59 字数 651 浏览 3 评论 0原文

所需的基本功能

当 Android 手机上的用户访问 URL http://www.example.com?key=asdf 时,我想要值 asdf< /code> 以手机上的任何应用程序稍后都可以访问的方式保存。

最终目标

该目标是通过将您的朋友定向到 URL 来邀请他们进入应用程序的简单方法。该 URL 包含一个从市场下载我的应用程序的链接,因此接受邀请所需的唯一操作就是访问该 URL 并单击单个链接。安装该应用后,它就可以获取值 asdf 并将您与邀请您的人联系起来。

我尝试过的事情

我最初的想法是使用 localStorage 或 cookies 之类的东西,但出于安全考虑,似乎不太可能存在涉及其中任何一种的解决方案。

到目前为止,我想出的最佳解决方案是使用 com.android.browser.permission.READ_HISTORY_BOOKMARKS 权限读取用户的历史记录,以从我的域中搜索 URL。这是一个非常好的解决方案,但它不适用于其他浏览器,例如移动版 Firefox。此外,它需要一个可疑的许可,如果可能的话我想避免这种情况。

Basic Desired Functionality

When a user on an android phone visits the URL http://www.example.com?key=asdf I would like the value asdf to be saved in a way that any app on the phone can access it at a later point.

The End Goal

The goal is a simple way to invite your friends into the app by directing them to a URL. The URL has a link to download my app from the market, so the only thing required to accept the invite is visiting that URL and clicking on a single link. Once you've installed the app, it can then grab the value asdf and connect you with whoever invited you.

Things I've Tried

My original thought was using something like localStorage or cookies, but it seems unlikely a solution involving either of those exists due to security concerns.

The best solution I've come up with so far is using the com.android.browser.permission.READ_HISTORY_BOOKMARKS permission to read through the user's history in search of URL's from my domain. This is a pretty good solution, but it does not work for other browsers like mobile Firefox. In addition, it requires a shady permission, which I would like to avoid if possible.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

任谁 2024-12-08 02:45:59

为了实现您的实际目标,您可以使用与 Google Analytics 相同的方法。
基本思想是,您使用指向应用商店的 URL 以及传递到应用程序的特定格式的引用值。尽管该字符串的格式应该可以是任何格式,但如果不遵循实际的 Google Analytics 格式,就会出现问题。

示例:

http://market.android.com/details?id=com.example.myapp&referrer=utm_source%3Dfriend%26utm_medium%3Dinvite%26utm_content%3Dasdf%26utm_campaign%3Dinvite

更多特定于分析的文档可以在 Android Google Analytics 中找到

然后,您需要为 com.android.vending.INSTALL_REFERRER 类型实现一个广播接收器,

在您的清单中,它将如下所示:

<!-- Used for install referrer tracking -->
<receiver android:name=".MyReceiverClass" android:exported="true">
  <intent-filter>
    <action android:name="com.android.vending.INSTALL_REFERRER" />
  </intent-filter>
</receiver>

有关实现 BroadcastReceiver

此方法要求朋友使用设备上的 Google Marketplace(通过单击生成的 URL)下载应用程序,因为 MarketPlace 应用程序会获取引荐来源网址数据并将其传递到应用程序。

注意:虽然该方法应该有效,但当前的 MarketPlace 应用程序可能存在问题,导致该方法无法正常工作。查看错误:http://code.google.com/p/android/问题/详细信息?id=19247

To achieve your actual goal you can use the same method that Google Analytics uses.
The basic idea is that you you use a URL pointed at the app store with a specifically formatted referrer value that gets passed on to the app. Though the format of this string is supposed to be able to be anything, there have been reports of problems if you don't follow the actual Google Analytics format.

example:

http://market.android.com/details?id=com.example.myapp&referrer=utm_source%3Dfriend%26utm_medium%3Dinvite%26utm_content%3Dasdf%26utm_campaign%3Dinvite

More documentation specific to analytics can be found at Android Google Analytics

You then will need to implement a broadcast receiver for the type com.android.vending.INSTALL_REFERRER

In your manifest it will look like:

<!-- Used for install referrer tracking -->
<receiver android:name=".MyReceiverClass" android:exported="true">
  <intent-filter>
    <action android:name="com.android.vending.INSTALL_REFERRER" />
  </intent-filter>
</receiver>

See Android docs for details on implementing a BroadcastReceiver.

This approach requires that the friend download the app using the Google Marketplace (by clicking on the generated URL) on the device, as it is the MarketPlace app that takes the referrer data and passes it on to the app.

NOTE: While the approach should work there may be problems with the current MarketPlace app that prevent this from working. see bug: http://code.google.com/p/android/issues/detail?id=19247

So要识趣 2024-12-08 02:45:59

抱歉,不存在支持的方法来执行此操作。

Sorry, no there is no supported way to do this.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文