SAMPLE CODE
package com.example.cipherlab;
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 TextView tv1 = null;
private IntentFilter filter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
tv1 = (TextView)findViewById(R.id.tv1);
// Register an intent filter to get the intent we want.
filter = new IntentFilter();
filter.addAction("com.cipherlab.barcodebaseapi.PASS_DATA_2_APP");
registerReceiver(myDataReceiver, filter);
}
@Override
protected void onDestroy() {
super.onDestroy();
unregisterReceiver(myDataReceiver);
}
// Create a broadcast object to get the intent sent from the service.
private final BroadcastReceiver myDataReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
// If the intent of the Intent_SOFTTRIGGER_DATA string is received,
// the following statements are excuted.
(intent.getAction().equals("com.cipherlab.barcodebaseapi.PASS_DATA_2_APP")) {
if
tv1.setText("");
// Fetch the data along with the intent.
String data = intent.getStringExtra("Decoder_Data");
// Fetch the original data along with the intent (not change
// to UTF-8 Format)
byte [] buffer =
intent.getByteArrayExtra("Decoder_DataArray");
// Fetch the code type along with the intent
int iCodeType = intent.getIntExtra("Decoder_CodeType", 0);
// Display the data.
tv1.setText(data);
Appendix V
103
Need help?
Do you have a question about the RK25 and is the answer not in the manual?
Questions and answers