在rk主板上,节点是用的很频繁的一个东西,在cmd命令行中使用使用echo命令传参,在安卓怎么使用呢?
package com.example import android.util.Log import java.io.BufferedWriter import java.io.FileWriter class SignTypeManger { var WorkUpWriter: BufferedWriter? = null fun sendCmdToMachine(id: String, fileName: String) { Log.e(TAG, "mWorkUpDecectNode========================" + fileName + " id====:" + id) try { WorkUpWriter = BufferedWriter(FileWriter(fileName)) } catch (e: Exception) { Log.e(TAG, "mWorkUpDecectNode error!!" + e.message) } try { WorkUpWriter!!.write(id) WorkUpWriter!!.flush() } catch (e: Exception) { Log.i(TAG, "node error!!") } try { WorkUpWriter!!.close() } catch (e: Exception) { } } companion object { var TAG = "mSignTypeManger" var mSignTypeManger: SignTypeManger? = SignTypeManger() fun getSignTypeMangerr(): SignTypeManger { if (mSignTypeManger == null) { mSignTypeManger = SignTypeManger() } return mSignTypeManger as SignTypeManger } } }调用方式:SignTypeManger.getSignTypeMangerr().sendCmdToMachine("传参", "节点地址"),注意节点需要给读写权限!
转载:https://blog.csdn.net/qq_36333309/article/details/112215989
查看评论