如何检测设备是否已在应用程序中root?
可能的重复:
确定是否在已取得 root 权限的设备上运行
在启动应用程序时,我想要检测正在运行的设备是否已root。 有没有正确的检测方法?
我不认为尝试将文件写入“\data”来查看是否已root是一个好的解决方案。 (因为即使是 root 设备也可能没有特权)
Possible Duplicate:
Determine if running on a rooted device
On Launch of the application, I want to detect if the device running is rooted.
Is there proper way of detecting it?
I don't think trying to write a file to '\data' to see if rooted is a good solution.
(Since even rooted devices may have that path unprivileged)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
归根结底,你不能。已取得 root 权限的设备可以以任何方式进行修改,因此可以完全隐藏您想要的任何内容。在实践中,您可以查看一些标准的 root 版本,以查找它们具有的功能或您可以查看的特征......但无法保证您所做的任何操作都会真正检测到“root”设备。
At the end of the day, you can't. A rooted device may be modified in any way, and thus can completely hide whatever it wants from you. In practice you could look at some of the standard root builds to find features they have or characteristics you can look at... but there is no way to guarantee that whatever you do will actually detect a "rooted" device.
你可以尝试这样做,
如果抛出异常或 proc 为空,那么它们没有 root
you could try to do
if that throws an exception or proc is null then they don't have root