1.17 霍尼韦尔EDA51、EDA50P,调用扫描枪的方法,在关闭的时候停止调用扫描枪

This commit is contained in:
2024-08-27 13:41:54 +08:00
parent 724e691188
commit 12c928f059
2 changed files with 8 additions and 4 deletions

View File

@ -57,7 +57,8 @@ public class ScanServiceEDA50P extends Service
super.onCreate();
notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
NotificationChannel channel = null;
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { //适配9.0service
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) { //适配9.0service
// if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { //适配9.0service
channel = new NotificationChannel(notificationId, notificationName, NotificationManager.IMPORTANCE_HIGH);
notificationManager.createNotificationChannel(channel);
Notification notification = new Notification.Builder(getApplicationContext(), notificationId).build();
@ -78,9 +79,11 @@ public class ScanServiceEDA50P extends Service
//Service被关闭之前回调
@Override
public void onDestroy() {
Log.i(TAG, "onDestory方法被调用!");
Log.i(TAG, "onDestroy方法被调用!");
super.onDestroy();
if (mBarcodeReader != null) {
mBarcodeReader.release();
}
if (this.mInternalScannerReader != null) {
this.mInternalScannerReader.removeBarcodeListener(this);
this.mInternalScannerReader.removeTriggerListener(this);