I have a very simple application that can work with any scanner via standard Android feature "BroadcastReceiver".
Unfortunately, I could not find in documentation, what SendBroadCast ACTION happen when scan barcode on scanner MC67 and etc.
I need ACTION NAME, for example "com.symbol.SCAN_ACTION" and what GetEXTRA anme for scanned data , for example "com.symbol.SCAN_EXTRA".
I tried to setup DataWedge as Broadcast receiver, it doesn't give me any help.
Also I tried to disable DataWedge - however it still popup DEMO application.
If this feature doesn't exist and scan event doesn't send brodcast, I need some documentation how to use SDK to create own application to create own broadcast send option.
Also will be helpful to have one SDK documentation with sample codes (Not datawedge implementation)
FYI: My application is not using to fillout and EditTexts, All operations happen on background via BroadCastReciver, nothing must not be started by default and etc...
For now, If even I disabled DataWedge and Demo app, it still run these apps and popup a screen of demo app, this is not acceptable.
Android SDK - Scan via BroadCastReceiver |
1 Replies
I want to use this logic and I'm not able to do DataWedge configuration, looks like this scenario doesn't work
//MainActivity.java
package com.motorolasolutions.emdk.sample.dwdemosample;
import android.os.Bundle;
import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.view.View;
import android.widget.TextView;
import android.widget.Button;
public class MainActivity extends Activity {
private static final String DATA_STRING_TAG = "com.motorolasolutions.emdk.datawedge.data_string";
private IntentFilter fltIntentAction ;
private BroadcastReceiver _newItemsReceiver;
private int iCount = 0;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Let's set the cursor at the end of any text in the editable text field
TextView et = (TextView)findViewById(R.id.editbox);
et.setText("Scan Now!");
final Button btn = (Button)findViewById(R.id.button1);
btn.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// Perform action on click
iCount++;
Intent intent = new Intent();
intent.setAction(getString(R.string.intentAction));
intent.putExtra(DATA_STRING_TAG, String.format("Test broadcast! #%d", iCount));
sendBroadcast(intent);
}
});
_newItemsReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
if(intent!=null)
{
// get the data from the intent
String data = intent.getStringExtra(DATA_STRING_TAG);
// let's get our edit box view
TextView et = (TextView)findViewById(R.id.editbox);
et.setText(data);
}
}
};
fltIntentAction = new IntentFilter(getString(R.string.intentAction));
registerReceiver(_newItemsReceiver, fltIntentAction);
}
@Override
protected void onDestroy() {
super.onDestroy();
// unregister the notifications
unregisterReceiver(_newItemsReceiver);
}
}