防丢App记录(4)--开机启动service检测sim卡的串码和之前保存的是否相同
来源:互联网 发布:凯文加内特生涯数据 编辑:程序博客网 时间:2024/06/01 17:37
开机广播的接收
- 在Mainifest文件里静态注册
<receiver android:name=".BootCompleteReceiver"> <intent-filter> <action android:name="android.intent.action.BOOT_COMPLETED"></action> </intent-filter> </receiver>
- 在广播接收类中重写onReceive方法,启动检测的后台服务
public class BootCompleteReceiver extends BroadcastReceiver{ String TAG="BoostCompleteReceiver"; @Override public void onReceive(Context context, Intent intent) { Log.d(TAG,"boost receive ..."); Intent service = new Intent(context,DetectService.class); context.startService(service); }}
- 工具类FileProcessBinder的实现,结合之前
防丢App记录(2)–将序列号通过文件存储
只是假如文件名封装起来,这里因为存文件要用到Context,所以就将Context当做参数传进去了,,,这样不好,,心怀咯噔往前走,,,
/** FileProcessBinder* 文件保存工具类*/public class FileProcessBinder { private Context context; private String fileName; String TAG = "FileProcessBinder"; public FileProcessBinder(Context context) { this.context = context; } public FileProcessBinder(String fileName, Context context) { this.fileName = fileName; this.context = context; } public String load(String fileName) { FileInputStream in = null; BufferedReader reader = null; StringBuilder content = new StringBuilder(); try { in = context.openFileInput(fileName); reader = new BufferedReader(new InputStreamReader(in)); String line = null; while ((line = reader.readLine()) != null) { content.append(line); Log.d(TAG, "load:" + content.toString()); } } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally { if (reader != null) { try { reader.close(); } catch (IOException e) { e.printStackTrace(); } } } return content.toString(); } public void save(String te1,String fileName) { BufferedWriter writer = null; try { FileOutputStream mFileOutputStream = null; mFileOutputStream = context.openFileOutput(fileName, Context.MODE_PRIVATE); writer = new BufferedWriter(new OutputStreamWriter(mFileOutputStream)); writer.write(te1); Log.d(TAG, "save:" + te1); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally { if (writer != null) { try { writer.close(); } catch (IOException e) { e.printStackTrace(); } } } }}
0 0
- 防丢App记录(4)--开机启动service检测sim卡的串码和之前保存的是否相同
- 防丢App记录(1)--取出sim卡的标志序列号
- 新建和之前保存的相同关键字对象,之前的对象会怎么样?
- Android 开机启动的service
- MTK Phonebook 开机后如何把nvram 和sim 中的电话本记录读到MMI 来的?
- 如何检测自己的APP是否卡
- SQL 检测是否存在相同的行。
- Android系统传播大全和开机自启动的Service
- 开机检查是否更换sim卡
- Android基于BroadcastReceiver和Service、SoundPool开发的防过充助手app
- iOS 检测手机是否安装SIM卡
- android 开机启动服务service的开发
- 检测某个应用是否开机启动
- android开机自动启动Service或app
- 开机启动Service或者一个app
- 【C#】关于服务Service的操作(是否存在,是否启动,是否自动启动)
- android的APP开机自启动
- 检测app是否存在的Html
- Bzoj2626:JZPFAR:K-D-Tree
- Jenkins 安装以及配置全过程(一)
- MySql-索引优化
- Sparse Autoencoder 编程练习
- HDFS基本原理及数据存取实战
- 防丢App记录(4)--开机启动service检测sim卡的串码和之前保存的是否相同
- 八类大学毕业生求职时不受欢迎
- OGNL表达式的基本语法和用法
- 自定义图片在上边,文字在下边的按钮
- 用notepa++写java程序时,中文部分编译运行会出现乱码
- 浅谈进制转换
- [Kali Linux] Kali Linux2.0 安装后的一些基本配置
- 匈牙利算法
- 多处理机、多核cpu、多线程cpu的区别