识别 Android 设备/安装(无物理 ID)
问题:
在我的一个 Android 应用程序中,应该允许用户更改我的服务器上的文本数据(通过 HTTP 请求),而无需登录或注册。
为了防止垃圾邮件和滥用此功能,我想识别我的应用程序的单个安装,以便我可以“禁止”此安装。当然,滥用我的服务的用户可以卸载该应用程序并再次下载或类似的操作。但这确实是一个障碍,使滥用该应用程序变得更加困难。
所以我必须找到一种方法来识别 Android 设备或至少是单个安装。
您可以阅读此处或此处 Android 手机的物理设备 ID 并不是一个好的解决方案。那么我还能做些什么来实现这一目标呢?
我的想法:
当应用程序第一次启动时,创建当前时间戳的(几乎)唯一的哈希值(可能是 SHA-512)和一个巨大的随机数。然后将此值保存在内部存储中,并始终使用它来识别此设备或稍后安装(在 HTTP 请求上)。
您觉得这个解决方案怎么样?还有更好的方法吗?
这几乎就是 Android 开发者博客 所建议的,正确的?但他们真的写入内部存储吗?他们没有按照此处。
最后,一个可能有点愚蠢的问题:
如何使用 Android 开发者博客上显示的代码?我可以将该公共类添加到我的主要活动 .java 文件中吗?
预先非常感谢您! :)
The problem:
In one of my Android apps, users should be allowed to make changes to text data on my server (via HTTP request) without being required to login or sign up.
In order to prevent spam and abuse of this function, I would like to identify a single installation of my app so that I can "ban" this installation. Of course, the user who is abusing my service could uninstall the app and download it again or something like that. But this is truly an obstacle and makes abusing the app more difficult.
So I have to find a way to identify an Android device or at least a single installation.
As one can read here or here the physical device ID of an Android phone is not a good solution. So what else could I do to achieve this?
My idea:
When the app is started for the first time, create an (almost) unique hash (maybe SHA-512) of the current timestamp and a huge random number. Then save this value on internal storage and always use it to identify this device or installation later (on HTTP requests).
What do you think of that solution? Are there any better approaches?
This is almost what the Android Developers Blog suggest, right? But are they really writing to the internal storage? They don't use openFileOutput() as suggested here.
And, at last, a question that is probably a bit stupid:
How can I use the code shown on the Android Developers Blog? Can I add that public class to my main activity .java file?
Thank you very much in advance! :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在我当前的 Android 项目中,我使用蓝牙 mac id 作为标识符,因为我了解到物理设备 ID 不可靠。当然,我的应用程序非常专业,无论如何都需要蓝牙和互联网,所以这是可行的。
具体来说,我有一种方法可以从手机调用我的网络服务器,并传入蓝牙 mac ID。我可以检查许可证状态(试用/到期),您可以在其中检查禁止方法以查看该 ID 是否被禁止。
由于我的应用程序需要蓝牙,这对我来说非常有效,因为[大多数]所有蓝牙 mac id 都应该是唯一的。
只是一个想法。
In my current Android project, I use the Bluetooth mac id as the identifier because of what I read about the physical device ID not being reliable. Of course, my app is very specialized and REQUIRES bluetooth AND internet anyway, so this works.
Specifically I have a way of calling my web server from the phone, passing in the Bluetooth mac ID. I can check license status (for trials/expirations), where you might check against a ban method to see if that id is banned.
Since my application requires bluetooth, this worked perfectly for me since [mostly] all bluetooth mac id's should be unique.
Just an idea.