2.8 编写一个通用的广播模式,action:chaoran.crtech.cn.pda.scan key:barcode;并且写了一个固定的注册码,但是这个注册码只能注册一个小时
This commit is contained in:
@ -11,7 +11,7 @@ android {
|
||||
minSdk 28
|
||||
targetSdk 28
|
||||
versionCode 1
|
||||
versionName "2.7"
|
||||
versionName "2.8"
|
||||
|
||||
// 1.0 IDATA广播模式处理
|
||||
// 1.1 霍尼韦尔的监听修改(扫描网站二维码跳出程序,监听失效,调整)、斑马PDA广播模式设置
|
||||
@ -42,6 +42,7 @@ android {
|
||||
// 2、判断是否初始化成功(webview成功),如果已经加载完毕,那么apk不在拦截,调用js的方法让BS进行处理提示
|
||||
// 3、根据官方文档,将code的判断进行修改,添加了一个网络错误的页面进行提示(并且添加了一个重新加载的按钮,执行webview重新加载)
|
||||
// 2.7 海康威视 mv-idp5204 适配广播模式;和之前的idp5102厂家code不一样 宿州市立医院-李德
|
||||
// 2.8 编写一个通用的广播模式,action:chaoran.crtech.cn.pda.scan key:barcode
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
ndk {
|
||||
abiFilters 'armeabi-v7a'
|
||||
|
||||
@ -181,6 +181,8 @@ public class MainActivity extends AppCompatActivity implements ResultListener{
|
||||
case QUALCOMM:
|
||||
adapter = new QualcommAdapter(this, this);
|
||||
break;
|
||||
default:
|
||||
adapter = new DefaultAdapter(this, this);
|
||||
}
|
||||
if (null != adapter) {
|
||||
adapter.start();
|
||||
|
||||
@ -0,0 +1,51 @@
|
||||
package chaoran.business.adapter;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
|
||||
import chaoran.business.activity.ResultListener;
|
||||
import chaoran.business.strategy.Strategy;
|
||||
|
||||
public class DefaultAdapter implements Adapter {
|
||||
private Context context;
|
||||
private Strategy strategy;
|
||||
private ResultListener resultListener;
|
||||
|
||||
public DefaultAdapter(Context context, ResultListener resultListener) {
|
||||
this.context = context;
|
||||
this.resultListener = resultListener;
|
||||
strategy = new DefaultAdapter.Receiver();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
strategy.executeStrategy(resultListener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop() {
|
||||
strategy.exclusiveStrategy();
|
||||
}
|
||||
|
||||
public class Receiver extends BroadcastReceiver implements Strategy {
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
resultListener.result(intent.getStringExtra("barcode"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeStrategy(ResultListener resultListener) {
|
||||
IntentFilter filter = new IntentFilter();
|
||||
filter.addAction("chaoran.crtech.cn.pda.scan");
|
||||
context.registerReceiver(this, filter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exclusiveStrategy() {
|
||||
context.unregisterReceiver(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -69,9 +69,6 @@ public class LocalAddressUtil {
|
||||
@JavascriptInterface
|
||||
public String getMacAddress(){//可以兼容安卓7以下
|
||||
SharedPreferences spf = context.getSharedPreferences("chaoran_mac", Context.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor1 = context.getSharedPreferences("CrtechPdaConfig", Context.MODE_PRIVATE).edit();
|
||||
editor1.putString("checkMacTime", String.valueOf(System.currentTimeMillis() - 1 * 60 * 60 * 1000));
|
||||
editor1.commit();
|
||||
String saveMac = spf.getString("chaoran_mac", "");
|
||||
if (!"".equalsIgnoreCase(saveMac)) {
|
||||
return saveMac;
|
||||
@ -243,9 +240,9 @@ public class LocalAddressUtil {
|
||||
return "error";
|
||||
}
|
||||
if ("1".equals(sharedPreferences.getString("checkMacType", "0"))) {
|
||||
// 判断是否是强行注册的,强行注册的只允许使用一天;一但判断到,就取消注册
|
||||
// 判断是否是强行注册的,强行注册的只允许使用一个小时;一但判断到,就取消注册
|
||||
Long aLong = Long.valueOf(sharedPreferences.getString("checkMacTime", String.valueOf(System.currentTimeMillis())));
|
||||
if ((aLong + 1 * 60 * 1000) < System.currentTimeMillis()) {
|
||||
if ((aLong + 1 * 60 * 60 * 1000) < System.currentTimeMillis()) {
|
||||
SharedPreferences.Editor edit = sharedPreferences.edit();
|
||||
edit.putString("checkMac", "error");
|
||||
edit.commit();
|
||||
|
||||
Reference in New Issue
Block a user