好的,我将分享一些关于如何实现这一目标的想法。
阅读本文时,我的第一个想法是“您可以通过与服务器交互来完成所有这些工作,坦率地说,有了这种支持会很容易”,当然,直到您注意到这是不可能的。
我在一些假设下提出这些建议:
贵公司的任何人都不会尝试以任何方式利用该应用程序 - 例如过度缓冲或更改应用程序语言或 utf 设置等。他们也不会尝试查看任何源文件。
在您公司的人员使用设备之前,您将始终掌握这些设备。
好吧,处理 30 天困境:最简单的方法(虽然也是最容易出错的方法)是在用户登录时获取系统当前时间(和日期),并将该“天”设置为计数器“30 或”0。这可以用Time now = new Time();
now.setToNow();
或来完成Calendar c = Calendar.getInstance();
。将这个“天”存储在您自己的SharedPreferences
或只是存储这个“天” DefaultSharedPreferences
。每次应用程序启动时,将这一天与您的当前日期一起检查,并计算它已经过了多少天。如果当前天数为 30 或更长,请重置密码。
^这是最简单的之一,也是非常“错误……满了?” (想不出一个好词)解决这个问题的方法。现在进入密码:
I would recommend using UUID for the passwords. Although the identifiers made aren't "technically" unique, the chances of getting the same password twice are...well so close to zero in your case it's probably not going to happen.
Generate these and store, lets say 1000 different ones into a file onto each device (a simple text file with each password on a different line will work), and save a copy in your own records (Make sure you know which passwords go to which device).
Then when that calendar counter from earlier goes off, set the password for the app as the "next" password in the file, deleting previous one from the file. The company employee calls you with his app Id (Generate an app ID the user can see in each app. So the first person who gets his app has app #1, the second is app#2 etc. so that you know which password file you should be reading from) you can send him the new password.
These are two veeeeeerrrryyy simple ways to handle this, but they might be able to at least get you thinking. Hope I helped a bit.