I could solve it. This is the code.
Intent intent = new Intent();
intent.setAction("com.motorolasolutions.emdk.datawedge.api.ACTION_SOFTSCANTRIGGER");
intent.putExtra("com.motorolasolutions.emdk.datawedge.api.EXTRA_PARAMETER", "TOGGLE_SCANNING");
getActivity().sendBroadcast(intent);
getActivity().registerReceiver(new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String code = intent.getExtras().getString("com.motorolasolutions.emdk.datawedge.data_string");
// do something
getActivity().unregisterReceiver(this);
}
}
, new IntentFilter("MyIntentAction"));
The profile in the DataWedge
has to enable the output via intent and disable the keystroke output. As intent action is to set a String
which is the same as "MyIntentAction"
. Then I get the scanned barcode directly in my Fragment after scanning.