FS01指环扫描枪、FS02 二维指环扫描枪、MS3392迷你二维扫描枪通用SDK开发包
package com.example.bimsdkexemple;import java.io.UnsupportedEncodingException;import com.bim.io.OnDataReceive;import com.bimsdk.bluetooth.BluetoothConnect;import com.bimsdk.bluetooth.BluetoothSettings;import android.os.Bundle;import android.app.Activity;import android.view.View;import android.view.View.OnClickListener;import android.widget.Button;import android.widget.EditText;import android.widget.TextView;public class MainActivity extends Activity {Button button1;Button button2;Button button3;Button button4;Button button5;Button button6;Activity myActivity;EditText EditText2;TextView TextView3;//BluetoothConnect.Connect();@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);BluetoothConnect.BindService(MainActivity.this);EditText2=(EditText)findViewById(R.id.EditText2);TextView3=(TextView)findViewById(R.id.TextView3);myActivity =this; button1=(Button)findViewById(R.id.button1); button1.setOnClickListener(new OnClickListener() {@Overridepublic void onClick(View v) {// TODO Auto-generated method stubBluetoothSettings.ACTION_BLUETOOTH_SETTINGS(MainActivity.this);}}); button2=(Button)findViewById(R.id.button2); button2.setOnClickListener(new OnClickListener() {@Overridepublic void onClick(View v) {// TODO Auto-generated method stub BluetoothSettings.SetScaner(MainActivity.this);}}); button3=(Button)findViewById(R.id.button3); button3.setOnClickListener(new OnClickListener() {@Overridepublic void onClick(View v) {// TODO Auto-generated method stubBluetoothConnect.Connect(MainActivity.this);}}); button4=(Button)findViewById(R.id.button4); button4.setOnClickListener(new OnClickListener() {@Overridepublic void onClick(View v) {// TODO Auto-generated method stubBluetoothConnect.Stop(MainActivity.this);}}); button5=(Button)findViewById(R.id.button5); button5.setOnClickListener(new OnClickListener() {@Overridepublic void onClick(View v) {// TODO Auto-generated method stubString abcString =EditText2.getText().toString();if (!"".equals(abcString)&&abcString!=null) {BluetoothConnect.BluetoothSend(abcString.getBytes());}EditText2.setText("");}}); button6=(Button)findViewById(R.id.button6); button6.setOnClickListener(new OnClickListener() {@Overridepublic void onClick(View v) {// TODO Auto-generated method stub// 显示所有发送内容,详见SendList类// Please see Class SendListSendList SendList = new SendList(myActivity);SendList.ShowoDialog();}}); GetData();}/** * 设置数据接受 * Settings Data */private void GetData() {// 监听接受到的数据//Receive data from bluetooth scannerBluetoothConnect.SetOnDataReceive(new OnDataReceive() {@Overridepublic void DataReceive(byte[] data) {// TODO Auto-generated method stubString aString=null;try {aString = new String(data,"GB-2312"); //aString = new String(data,"US-ASCII"); //aString = new String(data,"ISO-8859-9"); //aString = new String(data,"UTF-8"); } catch (UnsupportedEncodingException e) {// TODO Auto-generated catch blocke.printStackTrace();aString = new String(data);}TextView3.append(aString);System.out.println("String(data):" aString);}});}}
评论