Android上层怎样读写proc节点(示例)
发布日期:2021-06-30 18:52:33
浏览次数:2
分类:技术文章
本文共 1691 字,大约阅读时间需要 5 分钟。
import android.app.Activity; import android.os.Bundle; import android.widget.CompoundButton; import android.widget.CompoundButton.OnCheckedChangeListener; import android.widget.ToggleButton; import android.os.SystemProperties; import android.util.Log; import android.widget.Toast; //wang import java.util.Timer; import java.util.TimerTask; import android.os.PowerManager; import java.io.*; import android.os.Looper; public class DebugOptionActivity extends Activity { private static final String TAG = "tpDebug"; private int checkValue = 0; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.debug); ToggleButton toggle = (ToggleButton)findViewById(R.id.toggle); try{ File readFile = new File("proc/tp_debug/debug_switch"); FileReader inCmd = new FileReader(readFile); try{ checkValue = inCmd.read(); if(checkValue != 0) { toggle.setChecked(true); } else { toggle.setChecked(false); } }catch (IOException e){ e.printStackTrace(); } } catch (FileNotFoundException e){ e.printStackTrace(); } //ToggleButton toggle = (ToggleButton)findViewById(R.id.toggle); toggle.setOnCheckedChangeListener(new OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton arg0, boolean arg1) { if (arg1) { //open File awakeTimeFile = new File("proc/tp_debug/debug_switch"); FileWriter fr; try { fr = new FileWriter(awakeTimeFile); fr.write("1"); fr.close(); } catch (IOException e) { e.printStackTrace(); } } else { //close File awakeTimeFile = new File("proc/tp_debug/debug_switch"); FileWriter fr; try { fr = new FileWriter(awakeTimeFile); fr.write("0"); fr.close(); } catch (IOException e) { e.printStackTrace(); } } } }); } }转载地址:https://linus.blog.csdn.net/article/details/42239285 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!
发表评论
最新留言
感谢大佬
[***.8.128.20]2024年05月01日 07时03分33秒
关于作者
喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
【深度学习笔记】卷积层,全连接层,池化层的相关输出参数计算
2019-04-30
【NLP学习笔记】文本分类概述
2019-04-30
【深度学习笔记】文本分类
2019-04-30
【转载】炼丹实验室:深度学习网络调参技巧
2019-04-30
【论文阅读笔记】文本分类论文汇总
2019-04-30
【NLP学习笔记】One-hot encoding:独热编码
2019-04-30
【工具使用】CSDN编辑器markdown字体、颜色与字号的设置
2019-04-30
【NLP学习笔记】词共现矩阵
2019-04-30
【NLP学习笔记】NLP基础知识框架图
2019-04-30
【深度学习笔记】卷积的输入输出的通道、维度或尺寸变化过程
2019-04-30
【NLP学习笔记】训练集、验证集和测试集的概念及划分
2019-04-30
【NLP学习笔记】conda换源
2019-04-30
【深度学习笔记】标准卷积
2019-04-30
【深度学习笔记】组卷积
2019-04-30
【深度学习笔记】循环神经网络和递归神经网络区别
2019-04-30
【学习笔记】英文科技论文常见英语句式积累
2019-04-30
【深度学习笔记】PixelShuffle
2019-04-30