新大陆 pda 广播模式兼容
This commit is contained in:
@ -11,7 +11,7 @@ android {
|
||||
minSdk 28
|
||||
targetSdk 28
|
||||
versionCode 1
|
||||
versionName "1.12"
|
||||
versionName "1.13"
|
||||
|
||||
// 1.0 IDATA广播模式处理
|
||||
// 1.1 霍尼韦尔的监听修改(扫描网站二维码跳出程序,监听失效,调整)、斑马PDA广播模式设置
|
||||
@ -26,6 +26,7 @@ android {
|
||||
// 1.10 bug 代码判断没有结束
|
||||
// 1.11 霍尼韦尔EDA52
|
||||
// 1.12 屏幕旋转,采取配置化模式(只能竖屏、横屏);取消旋转屏幕就重置activity生命周期
|
||||
// 1.13 新大陆pda 兼容广播模式;NLS-NFT10
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
|
||||
|
||||
@ -10,6 +10,7 @@ package chaoran.business;
|
||||
|
||||
public enum BrandEnum {
|
||||
//枚举名即为valueOf()
|
||||
NEW_LAND("新大陆", "newland"),
|
||||
HISENSE("海信", "hisense"),
|
||||
UROVO("DT50 Lite", "urovo"),
|
||||
LACHESIS("联新", "lachesis"),
|
||||
|
||||
@ -135,6 +135,9 @@ public class MainActivity extends AppCompatActivity implements ResultListener{
|
||||
case HKWS:
|
||||
adapter = new HkwsAdapter(this, this);
|
||||
break;
|
||||
case NEW_LAND:
|
||||
adapter = new NewlandAdapter(this, this);
|
||||
break;
|
||||
}
|
||||
if (null != adapter) {
|
||||
adapter.start();
|
||||
|
||||
@ -0,0 +1,53 @@
|
||||
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 NewlandAdapter implements Adapter {
|
||||
private Context context;
|
||||
private ResultListener resultListener;
|
||||
private Strategy strategy;
|
||||
|
||||
|
||||
public NewlandAdapter(Context context, ResultListener resultListener) {
|
||||
this.context = context;
|
||||
this.resultListener = resultListener;
|
||||
strategy = new 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("SCAN_BARCODE1"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeStrategy(ResultListener resultListener) {
|
||||
IntentFilter filter = new IntentFilter();
|
||||
filter.addAction("nlscan.action.SCANNER_RESULT");
|
||||
filter.setPriority(2);
|
||||
context.registerReceiver(this, filter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exclusiveStrategy() {
|
||||
context.unregisterReceiver(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user