|
|
|
|
@ -1,6 +1,10 @@
|
|
|
|
|
package com.example.writeepc.base;
|
|
|
|
|
|
|
|
|
|
import android.app.ProgressDialog;
|
|
|
|
|
import android.content.BroadcastReceiver;
|
|
|
|
|
import android.content.Context;
|
|
|
|
|
import android.content.Intent;
|
|
|
|
|
import android.content.IntentFilter;
|
|
|
|
|
import android.media.MediaPlayer;
|
|
|
|
|
import android.os.Bundle;
|
|
|
|
|
import android.util.Log;
|
|
|
|
|
@ -27,15 +31,22 @@ public class BaseActivity extends AppCompatActivity {
|
|
|
|
|
public TipsDialog tipsDialog;
|
|
|
|
|
public MediaType mediaType = MediaType.parse("text/xml; charset=utf-8");
|
|
|
|
|
public Gson gson;
|
|
|
|
|
public MyReceiver myReceiver;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
|
|
|
|
super.onCreate(savedInstanceState);
|
|
|
|
|
tipsDialog = new TipsDialog(this);
|
|
|
|
|
gson = new Gson();
|
|
|
|
|
// tipsDialog = new TipsDialog(this);
|
|
|
|
|
// gson = new Gson();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void initReceiver() {
|
|
|
|
|
myReceiver = new MyReceiver();
|
|
|
|
|
IntentFilter intentFilter = new IntentFilter();
|
|
|
|
|
intentFilter.addAction("android.rfid.FUN_KEY");
|
|
|
|
|
registerReceiver(myReceiver, intentFilter);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void initDialog() {
|
|
|
|
|
dialog = new ProgressDialog(this);
|
|
|
|
|
@ -70,7 +81,6 @@ public class BaseActivity extends AppCompatActivity {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 1- 读取TID
|
|
|
|
|
public void readTid() {
|
|
|
|
|
byte[] rdata = new byte[12];
|
|
|
|
|
@ -118,11 +128,38 @@ public class BaseActivity extends AppCompatActivity {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void writeUserData(String writeData) {
|
|
|
|
|
byte[] bytes = Tools.HexString2Bytes(writeData);
|
|
|
|
|
Reader.READER_ERR readerErr = uhfrManager.writeTagData((char) 3, 0,
|
|
|
|
|
bytes, bytes.length, accesspwd, timeOut);
|
|
|
|
|
Log.e("TAG", "写入状态:" + readerErr.name());
|
|
|
|
|
if (readerErr == Reader.READER_ERR.MT_OK_ERR) {
|
|
|
|
|
music.start();
|
|
|
|
|
Toast.makeText(this, "写入成功", Toast.LENGTH_SHORT).show();
|
|
|
|
|
} else {
|
|
|
|
|
Toast.makeText(this, "写入失败", Toast.LENGTH_SHORT).show();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected void readTidReault(boolean readState, String result, byte[] rdata) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void receiverSan() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class MyReceiver extends BroadcastReceiver {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onReceive(Context context, Intent intent) {
|
|
|
|
|
|
|
|
|
|
var keydown = intent.getBooleanExtra("keydown", false);
|
|
|
|
|
if (!keydown) {
|
|
|
|
|
receiverSan();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// @Override
|
|
|
|
|
// protected void onDestroy() {
|
|
|
|
|
// super.onDestroy();
|
|
|
|
|
|