Hello.
I have another barcode reader and i got SDK, but i dont know how to get broadcast.
Java code:
package com.wpx.barcode.broadcast.activity;
import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.widget.TextView;
public class MainActivity extends Activity {
private static final String BARCODE_ACTION = "com.barcode.sendBroadcast";
private static final String BARCODE_PARAM = "BARCODE";
private TextView tv_barcode,tv_count;
@override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
tv_barcode = (TextView)findViewById(R.id.tv_barcoce);
tv_count = (TextView)findViewById(R.id.tv_count);
}
@override
protected void onResume() {
// TODO Auto-generated method stubIntentFilter intentFilter = new IntentFilter(BARCODE_ACTION);
registerReceiver(barcodeBroadcastReceiver, intentFilter);
super.onResume();
}
@override
protected void onDestroy() {
// TODO Auto-generated method stubunregisterReceiver(barcodeBroadcastReceiver);
super.onDestroy();
}
int count = 0;
private BroadcastReceiver barcodeBroadcastReceiver = new BroadcastReceiver() {
@override
public void onReceive(Context context, Intent intent) {
// TODO Auto-generated method stubString action = intent.getAction();
if(BARCODE_ACTION.equals(action)){
String barcode = intent.getStringExtra(BARCODE_PARAM);
tv_barcode.setText(barcode);
tv_count.setText(String.valueOf(count++));
}
}
};
}