生活随笔
收集整理的這篇文章主要介紹了
android蓝牙打印机
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
您還未登錄!|登錄|注冊(cè)|幫助
首頁(yè) 業(yè)界 移動(dòng) 云計(jì)算 研發(fā) 論壇 博客 下載 更多 reality_jie的專(zhuān)欄 編程的過(guò)程是一種微妙的享受 CSDN2013年度博客之星評(píng)選? ?????
文思海輝第一屆在線編程大賽? ?????
消滅0回答,贏下載分? ?????
訂閱CSDN社區(qū)周刊,及時(shí)了解社區(qū)精華內(nèi)容? ?????
辦公大師系列經(jīng)典叢書(shū) 誠(chéng)聘譯者? ????
[置頂] ?安卓手機(jī)連接藍(lán)牙打印機(jī)實(shí)現(xiàn)打印功能 分類(lèi):?android 2013-09-22 14:22 ?
958人閱讀 ??
收藏 ?
舉報(bào) android藍(lán)牙打印
最近在做一個(gè)安卓應(yīng)用,其中有一個(gè)需求是要求用藍(lán)牙連接打印機(jī)實(shí)現(xiàn)打印功能。一開(kāi)始沒(méi)有一點(diǎn)頭緒,網(wǎng)上找了很多資料也找不到有用的數(shù)據(jù)。所以自己就去研究,最終,功夫不負(fù)有心人,順利的完成了這個(gè)功能。下邊貼出我寫(xiě)的代碼,共有需要的IT哥們參考學(xué)習(xí)。
完整源碼下載
?
我們先看看運(yùn)行效果圖吧。。。
1.這是主界面的效果圖
貼上布局文件的代碼:bluetooth_layout.xml
?
[html] ?view plaincopy
< span ?style ="font-size:12px" > <? xml ?version ="1.0" ?encoding ="utf-8" ?> ??< RelativeLayout ??????android:layout_width ="match_parent" ?? ????android:layout_height ="match_parent" ?> ?? ?? ????< Button ?? ????????android:id ="@+id/openBluetooth_tb" ?? ????????android:layout_width ="130dp" ?? ????????android:layout_height ="wrap_content" ?? ????????android:layout_alignParentRight ="true" ?? ????????android:layout_marginRight ="18dp" ?? ????????android:layout_marginTop ="5dp" ?? ????????android:text ="打開(kāi)藍(lán)牙" ?/> ?? ?? ????< Button ?? ????????android:id ="@+id/searchDevices" ?? ????????android:layout_width ="match_parent" ?? ????????android:layout_height ="wrap_content" ?? ????????android:layout_alignParentLeft ="true" ?? ????????android:layout_below ="@+id/openBluetooth_tb" ?? ????????android:layout_marginTop ="20dp" ?? ????????android:text ="搜索設(shè)備" ?/> ?? ?? ????< View ?? ????????android:layout_width ="match_parent" ?? ????????android:layout_height ="3dp" ?? ????????android:layout_alignParentLeft ="true" ?? ????????android:layout_below ="@+id/searchDevices" ?? ????????android:background ="@android:color/darker_gray" ?/> ?? ?? ????< LinearLayout ?? ????????android:id ="@+id/linearLayout1" ?? ????????android:layout_width ="match_parent" ?? ????????android:layout_height ="150dp" ?? ????????android:layout_marginTop ="125dp" ?? ????????android:orientation ="vertical" ?> ?? ?? ????????< TextView ?? ????????????android:layout_width ="match_parent" ?? ????????????android:layout_height ="wrap_content" ?? ????????????android:text ="未配對(duì)設(shè)備" ?/> ?? ?? ????????< ListView ?? ????????????android:id ="@+id/unbondDevices" ?? ????????????android:layout_width ="wrap_content" ?? ????????????android:layout_height ="wrap_content" ?/> ?? ????</ LinearLayout > ?? ?? ????< View ?? ????????android:layout_width ="match_parent" ?? ????????android:layout_height ="3dp" ?? ????????android:layout_alignParentLeft ="true" ?? ????????android:layout_below ="@+id/searchDevices" ?? ????????android:layout_marginTop ="160dp" ?? ????????android:background ="@android:color/darker_gray" ?/> ?? ?? ????< LinearLayout ?? ????????android:layout_width ="match_parent" ?? ????????android:layout_height ="190dp" ?? ????????android:layout_marginTop ="288dp" ?? ????????android:orientation ="vertical" ?> ?? ?? ????????< TextView ?? ????????????android:layout_width ="match_parent" ?? ????????????android:layout_height ="wrap_content" ?? ????????????android:text ="已配對(duì)設(shè)備" ?/> ?? ??????????< ListView ?? ????????????android:id ="@+id/bondDevices" ?? ????????????android:layout_width ="wrap_content" ?? ???????????android:layout_height ="wrap_content" ?? ???????????android:layout_alignParentLeft ="true" ?? ???????????android:layout_below ="@+id/linearLayout1" ?> ?? ?????????</ ListView > ?? ????</ LinearLayout > ?? ?? ????< Button ?? ????????android:id ="@+id/return_Bluetooth_btn" ?? ????????android:layout_width ="100dp" ?? ????????android:layout_height ="wrap_content" ?? ????????android:layout_above ="@+id/searchDevices" ?? ????????android:layout_alignParentLeft ="true" ?? ????????android:text ="返回" ?/> ?? ?? </ RelativeLayout > </ span > ?? ?
?
從上邊的布局文件中不難看出,其中有兩個(gè)ListView,OK,那下邊貼出對(duì)應(yīng)的兩個(gè)item布局文件
?
? --> 第一個(gè)item:unbonddevice_item.xml
?
[html] ?view plaincopy
< span ?style ="font-size:14px" > <? xml ?version ="1.0" ?encoding ="utf-8" ?> ????< RelativeLayout ??????android:layout_width ="match_parent" ???? ????android:layout_height ="match_parent" ?> ???? ???? ????< TextView ???? ????????android:id ="@+id/device_name" ???? ????????android:layout_width ="match_parent" ???? ????????android:layout_height ="wrap_content" ???? ????????android:layout_alignParentLeft ="true" ???? ????????android:layout_alignParentTop ="true" ???? ????????android:text ="未綁定設(shè)備" ???? ????????android:textAppearance ="?android:attr/textAppearanceLarge" ?/> ???? ???? </ RelativeLayout > </ span > ?? -->第二個(gè)item:bonddevice_item.xml
?
?
[html] ?view plaincopy
< span ?style ="font-size:14px" > <? xml ?version ="1.0" ?encoding ="utf-8" ?> ????< RelativeLayout ??????android:layout_width ="match_parent" ???? ????android:layout_height ="match_parent" ?> ???? ???? ????< TextView ???? ????????android:id ="@+id/device_name" ???? ????????android:layout_width ="match_parent" ???? ????????android:layout_height ="wrap_content" ???? ????????android:layout_alignParentLeft ="true" ???? ????????android:layout_alignParentTop ="true" ???? ????????android:text ="已綁定設(shè)備" ???? ????????android:textAppearance ="?android:attr/textAppearanceLarge" ?/> ???? ???? </ RelativeLayout > </ span > ?? 2.還有另外一個(gè)布局文件,就是當(dāng)點(diǎn)擊已綁定藍(lán)牙設(shè)備下邊的某個(gè)item時(shí)進(jìn)入打印的界面,不多說(shuō),看圖!
?
?
代碼如下:printdata_layout.xml
?
[html] ?view plaincopy
<? xml ?version ="1.0" ?encoding ="utf-8" ?> ????< RelativeLayout ????????android:layout_width ="match_parent" ???? ????android:layout_height ="match_parent" ?> ???? ???? ????< EditText ???? ????????android:id ="@+id/print_data" ???? ????????android:layout_width ="match_parent" ???? ????????android:layout_height ="200dp" ???? ????????android:layout_alignParentLeft ="true" ???? ????????android:layout_alignParentTop ="true" ???? ????????android:layout_marginTop ="46dp" ?> ???? ????</ EditText > ???? ???? ????< TextView ???? ????????android:id ="@+id/device_name" ???? ????????android:layout_width ="wrap_content" ???? ????????android:layout_height ="wrap_content" ???? ????????android:layout_alignParentLeft ="true" ???? ????????android:layout_alignParentTop ="true" ???? ????????android:layout_marginTop ="16dp" ???? ????????android:text ="Large?Text" ???? ????????android:textAppearance ="?android:attr/textAppearanceLarge" ?/> ???? ???? ????< TextView ???? ????????android:id ="@+id/connect_state" ???? ????????android:layout_width ="wrap_content" ???? ????????android:layout_height ="wrap_content" ???? ????????android:layout_alignBaseline ="@+id/device_name" ???? ????????android:layout_alignBottom ="@+id/device_name" ???? ????????android:layout_marginLeft ="42dp" ???? ????????android:layout_toRightOf ="@+id/device_name" ???? ????????android:text ="Large?Text" ???? ????????android:textAppearance ="?android:attr/textAppearanceLarge" ?/> ???? ???? ????< Button ???? ????????android:id ="@+id/send" ???? ????????android:layout_width ="match_parent" ???? ????????android:layout_height ="wrap_content" ???? ????????android:layout_alignParentLeft ="true" ???? ????????android:layout_below ="@+id/print_data" ???? ????????android:layout_marginTop ="21dp" ???? ????????android:text ="打印" ?/> ???? ???? ????< Button ???? ????????android:id ="@+id/command" ???? ????????android:layout_width ="match_parent" ???? ????????android:layout_height ="wrap_content" ???? ????????android:layout_alignParentLeft ="true" ???? ????????android:layout_below ="@+id/send" ???? ????????android:text ="指令" ?/> ???? ???????? </ RelativeLayout > ?? 至此,布局文件就搞定了,接下來(lái)就要編寫(xiě)java代碼了。主要有一下這么幾個(gè)類(lèi),一個(gè)一個(gè)來(lái)哈
?
BluetoothActivity.java
這個(gè)類(lèi)的主要作用是初始化主界面,看代碼
[java] ?view plaincopy
public ?class ?BluetoothActivity?extends ?Activity?{????????private ?Context?context?=?null ;???? ???? ????public ?void ?onCreate(Bundle?savedInstanceState)?{???? ????????super .onCreate(savedInstanceState);???? ????????this .context?=?this ;???? ????????setTitle("藍(lán)牙打印" );???? ????????setContentView(R.layout.bluetooth_layout);???? ????????this .initListener();???? ????}???? ???? ????private ?void ?initListener()?{???? ????????ListView?unbondDevices?=?(ListView)?this ???? ????????????????.findViewById(R.id.unbondDevices);???? ????????ListView?bondDevices?=?(ListView)?this .findViewById(R.id.bondDevices);???? ????????Button?switchBT?=?(Button)?this .findViewById(R.id.openBluetooth_tb);???? ????????Button?searchDevices?=?(Button)?this .findViewById(R.id.searchDevices);???? ???? ????????BluetoothAction?bluetoothAction?=?new ?BluetoothAction(this .context,???? ????????????????unbondDevices,?bondDevices,?switchBT,?searchDevices,???? ????????????????BluetoothActivity.this );???? ???? ????????Button?returnButton?=?(Button)?this ???? ????????????????.findViewById(R.id.return_Bluetooth_btn);???? ????????bluetoothAction.setSearchDevices(searchDevices);???? ????????bluetoothAction.initView();???? ???? ????????switchBT.setOnClickListener(bluetoothAction);???? ????????searchDevices.setOnClickListener(bluetoothAction);???? ????????returnButton.setOnClickListener(bluetoothAction);???? ????}???? ?????? ????public ?boolean ?onKeyDown(int ?keyCode,KeyEvent?event)???? ????{???? ????????switch (keyCode)???? ????????{???? ????????????case ?KeyEvent.KEYCODE_BACK:return ?true ;???? ????????}???? ????????return ?super .onKeyDown(keyCode,?event);???? ????}???? }?? BluetoothAction.java ?
這個(gè)類(lèi)顧名思義,是處理bluetoothActivity中各種操作事件的action類(lèi),看代碼
[java] ?view plaincopy
<span?style="font-size:14px" >public ?class ?BluetoothAction?implements ?OnClickListener?{???? ???? ????private ?Button?switchBT?=?null ;???? ????private ?Button?searchDevices?=?null ;???? ????private ?Activity?activity?=?null ;???? ???? ????private ?ListView?unbondDevices?=?null ;???? ????private ?ListView?bondDevices?=?null ;???? ????private ?Context?context?=?null ;???? ????private ?BluetoothService?bluetoothService?=?null ;???? ???? ????public ?BluetoothAction(Context?context,?ListView?unbondDevices,???? ????????????ListView?bondDevices,?Button?switchBT,?Button?searchDevices,???? ????????????Activity?activity)?{???? ????????super ();???? ????????this .context?=?context;???? ????????this .unbondDevices?=?unbondDevices;???? ????????this .bondDevices?=?bondDevices;???? ????????this .switchBT?=?switchBT;???? ????????this .searchDevices?=?searchDevices;???? ????????this .activity?=?activity;???? ????????this .bluetoothService?=?new ?BluetoothService(this .context,???? ????????????????this .unbondDevices,?this .bondDevices,?this .switchBT,???? ????????????????this .searchDevices);???? ????}???? ???? ????public ?void ?setSwitchBT(Button?switchBT)?{???? ????????this .switchBT?=?switchBT;???? ????}???? ???? ????public ?void ?setSearchDevices(Button?searchDevices)?{???? ????????this .searchDevices?=?searchDevices;???? ????}???? ???? ????public ?void ?setUnbondDevices(ListView?unbondDevices)?{???? ????????this .unbondDevices?=?unbondDevices;???? ????}???? ???? ????? ? ???? ????public ?void ?initView()?{???? ???? ????????if ?(this .bluetoothService.isOpen())?{???? ????????????System.out.println("藍(lán)牙有開(kāi)!" );???? ????????????switchBT.setText("關(guān)閉藍(lán)牙" );???? ????????}???? ????????if ?(!this .bluetoothService.isOpen())?{???? ????????????System.out.println("藍(lán)牙沒(méi)開(kāi)!" );???? ????????????this .searchDevices.setEnabled(false );???? ????????}???? ????}???? ???? ????private ?void ?searchDevices()?{???? ????????bluetoothService.searchDevices();???? ????}???? ???? ????? ? ???? ????@Override ???? ????public ?void ?onClick(View?v)?{???? ????????if ?(v.getId()?==?R.id.searchDevices)?{???? ????????????this .searchDevices();???? ????????}?else ?if ?(v.getId()?==?R.id.return_Bluetooth_btn)?{???? ????????????activity.finish();???? ????????}?else ?if ?(v.getId()?==?R.id.openBluetooth_tb)?{???? ????????????if ?(!this .bluetoothService.isOpen())?{???? ?????????????????? ????????????????System.out.println("藍(lán)牙關(guān)閉的情況" );???? ????????????????this .bluetoothService.openBluetooth(activity);???? ????????????}?else ?{???? ?????????????????? ????????????????System.out.println("藍(lán)牙打開(kāi)的情況" );???? ????????????????this .bluetoothService.closeBluetooth();???? ???? ????????????}???? ???? ????????}???? ????}???? ???? }</span>?? ?
?
這個(gè)類(lèi)會(huì)把各種請(qǐng)求動(dòng)作分門(mén)別類(lèi),交給BluetoothService.java 來(lái)處理,看代碼
?
?
[java] ?view plaincopy
public ?class ?BluetoothService?{????????private ?Context?context?=?null ;???? ????private ?BluetoothAdapter?bluetoothAdapter?=?BluetoothAdapter???? ????????????.getDefaultAdapter();???? ????private ?ArrayList<BluetoothDevice>?unbondDevices?=?null ;??? ????private ?ArrayList<BluetoothDevice>?bondDevices?=?null ;?? ????private ?Button?switchBT?=?null ;???? ????private ?Button?searchDevices?=?null ;???? ????private ?ListView?unbondDevicesListView?=?null ;???? ????private ?ListView?bondDevicesListView?=?null ;???? ???? ????? ? ???? ????private ?void ?addBondDevicesToListView()?{???? ????????ArrayList<HashMap<String,?Object>>?data?=?new ?ArrayList<HashMap<String,?Object>>();???? ????????int ?count?=?this .bondDevices.size();???? ????????System.out.println("已綁定設(shè)備數(shù)量:" ?+?count);???? ????????for ?(int ?i?=?0 ;?i?<?count;?i++)?{???? ????????????HashMap<String,?Object>?map?=?new ?HashMap<String,?Object>();???? ????????????map.put("deviceName" ,?this .bondDevices.get(i).getName());???? ????????????data.add(map);?? ????????}???? ????????String[]?from?=?{?"deviceName" ?};???? ????????int []?to?=?{?R.id.device_name?};???? ????????SimpleAdapter?simpleAdapter?=?new ?SimpleAdapter(this .context,?data,???? ????????????????R.layout.bonddevice_item,?from,?to);???? ?????????? ????????this .bondDevicesListView.setAdapter(simpleAdapter);???? ???? ????????this .bondDevicesListView???? ????????????????.setOnItemClickListener(new ?OnItemClickListener()?{???? ???? ????????????????????@Override ???? ????????????????????public ?void ?onItemClick(AdapterView<?>?arg0,?View?arg1,???? ????????????????????????????int ?arg2,?long ?arg3)?{???? ????????????????????????BluetoothDevice?device?=?bondDevices.get(arg2);???? ????????????????????????Intent?intent?=?new ?Intent();???? ????????????????????????intent.setClassName(context,???? ????????????????????????????????"com.lifeng.jdxt.view.PrintDataActivity" );???? ????????????????????????intent.putExtra("deviceAddress" ,?device.getAddress());???? ????????????????????????context.startActivity(intent);???? ????????????????????}???? ????????????????});???? ???? ????}???? ???? ????? ? ???? ????private ?void ?addUnbondDevicesToListView()?{???? ????????ArrayList<HashMap<String,?Object>>?data?=?new ?ArrayList<HashMap<String,?Object>>();???? ????????int ?count?=?this .unbondDevices.size();???? ????????System.out.println("未綁定設(shè)備數(shù)量:" ?+?count);???? ????????for ?(int ?i?=?0 ;?i?<?count;?i++)?{???? ????????????HashMap<String,?Object>?map?=?new ?HashMap<String,?Object>();???? ????????????map.put("deviceName" ,?this .unbondDevices.get(i).getName());???? ????????????data.add(map);?? ????????}???? ????????String[]?from?=?{?"deviceName" ?};???? ????????int []?to?=?{?R.id.device_name?};???? ????????SimpleAdapter?simpleAdapter?=?new ?SimpleAdapter(this .context,?data,???? ????????????????R.layout.unbonddevice_item,?from,?to);???? ???? ?????????? ????????this .unbondDevicesListView.setAdapter(simpleAdapter);???? ???? ?????????? ????????this .unbondDevicesListView???? ????????????????.setOnItemClickListener(new ?OnItemClickListener()?{???? ???? ????????????????????@Override ???? ????????????????????public ?void ?onItemClick(AdapterView<?>?arg0,?View?arg1,???? ????????????????????????????int ?arg2,?long ?arg3)?{???? ????????????????????????try ?{???? ????????????????????????????Method?createBondMethod?=?BluetoothDevice.class ???? ????????????????????????????????????.getMethod("createBond" );???? ????????????????????????????createBondMethod???? ????????????????????????????????????.invoke(unbondDevices.get(arg2));???? ?????????????????????????????? ????????????????????????????bondDevices.add(unbondDevices.get(arg2));???? ?????????????????????????????? ????????????????????????????unbondDevices.remove(arg2);???? ????????????????????????????addBondDevicesToListView();???? ????????????????????????????addUnbondDevicesToListView();???? ????????????????????????}?catch ?(Exception?e)?{???? ????????????????????????????Toast.makeText(context,?"配對(duì)失敗!" ,?Toast.LENGTH_SHORT)???? ????????????????????????????????????.show();???? ????????????????????????}???? ???? ????????????????????}???? ????????????????});???? ????}???? ???? ????public ?BluetoothService(Context?context,?ListView?unbondDevicesListView,???? ????????????ListView?bondDevicesListView,?Button?switchBT,?Button?searchDevices)?{???? ????????this .context?=?context;???? ????????this .unbondDevicesListView?=?unbondDevicesListView;???? ????????this .bondDevicesListView?=?bondDevicesListView;???? ?????????? ????????this .unbondDevices?=?new ?ArrayList<BluetoothDevice>();???? ????????this .bondDevices?=?new ?ArrayList<BluetoothDevice>();???? ????????this .switchBT?=?switchBT;???? ????????this .searchDevices?=?searchDevices;???? ????????this .initIntentFilter();???? ???? ????}???? ???? ????private ?void ?initIntentFilter()?{???? ?????????? ????????IntentFilter?intentFilter?=?new ?IntentFilter();???? ????????intentFilter.addAction(BluetoothDevice.ACTION_FOUND);???? ????????intentFilter.addAction(BluetoothAdapter.ACTION_DISCOVERY_STARTED);???? ????????intentFilter.addAction(BluetoothAdapter.ACTION_DISCOVERY_FINISHED);???? ????????intentFilter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED);???? ?????????? ????????context.registerReceiver(receiver,?intentFilter);???? ???? ????}???? ???? ????? ? ???? ????public ?void ?openBluetooth(Activity?activity)?{???? ????????Intent?enableBtIntent?=?new ?Intent(???? ????????????????BluetoothAdapter.ACTION_REQUEST_ENABLE);???? ????????activity.startActivityForResult(enableBtIntent,?1 );???? ???? ????}???? ???? ????? ? ???? ????public ?void ?closeBluetooth()?{???? ????????this .bluetoothAdapter.disable();???? ????}???? ???? ????? ? ? ? ???? ????public ?boolean ?isOpen()?{???? ????????return ?this .bluetoothAdapter.isEnabled();???? ???? ????}???? ???? ????? ? ???? ????public ?void ?searchDevices()?{???? ????????this .bondDevices.clear();???? ????????this .unbondDevices.clear();???? ???? ?????????? ????????this .bluetoothAdapter.startDiscovery();???? ????}???? ???? ????? ? ? ? ???? ????public ?void ?addUnbondDevices(BluetoothDevice?device)?{???? ????????System.out.println("未綁定設(shè)備名稱:" ?+?device.getName());???? ????????if ?(!this .unbondDevices.contains(device))?{???? ????????????this .unbondDevices.add(device);???? ????????}???? ????}???? ???? ????? ? ? ? ???? ????public ?void ?addBandDevices(BluetoothDevice?device)?{???? ????????System.out.println("已綁定設(shè)備名稱:" ?+?device.getName());???? ????????if ?(!this .bondDevices.contains(device))?{???? ????????????this .bondDevices.add(device);???? ????????}???? ????}???? ???? ????? ? ???? ????private ?BroadcastReceiver?receiver?=?new ?BroadcastReceiver()?{???? ???? ????????ProgressDialog?progressDialog?=?null ;???? ???? ????????@Override ???? ????????public ?void ?onReceive(Context?context,?Intent?intent)?{???? ????????????String?action?=?intent.getAction();???? ????????????if ?(BluetoothDevice.ACTION_FOUND.equals(action))?{???? ????????????????BluetoothDevice?device?=?intent???? ????????????????????????.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);???? ????????????????if ?(device.getBondState()?==?BluetoothDevice.BOND_BONDED)?{???? ????????????????????addBandDevices(device);???? ????????????????}?else ?{???? ????????????????????addUnbondDevices(device);???? ????????????????}???? ????????????}?else ?if ?(BluetoothAdapter.ACTION_DISCOVERY_STARTED.equals(action))?{???? ????????????????progressDialog?=?ProgressDialog.show(context,?"請(qǐng)稍等..." ,???? ????????????????????????"搜索藍(lán)牙設(shè)備中..." ,?true );???? ???? ????????????}?else ?if ?(BluetoothAdapter.ACTION_DISCOVERY_FINISHED???? ????????????????????.equals(action))?{???? ????????????????System.out.println("設(shè)備搜索完畢" );???? ????????????????progressDialog.dismiss();???? ???? ????????????????addUnbondDevicesToListView();???? ????????????????addBondDevicesToListView();???? ?????????????????? ????????????}???? ????????????if ?(BluetoothAdapter.ACTION_STATE_CHANGED.equals(action))?{???? ????????????????if ?(bluetoothAdapter.getState()?==?BluetoothAdapter.STATE_ON)?{???? ????????????????????System.out.println("--------打開(kāi)藍(lán)牙-----------" );???? ????????????????????switchBT.setText("關(guān)閉藍(lán)牙" );???? ????????????????????searchDevices.setEnabled(true );???? ????????????????????bondDevicesListView.setEnabled(true );???? ????????????????????unbondDevicesListView.setEnabled(true );???? ????????????????}?else ?if ?(bluetoothAdapter.getState()?==?BluetoothAdapter.STATE_OFF)?{???? ????????????????????System.out.println("--------關(guān)閉藍(lán)牙-----------" );???? ????????????????????switchBT.setText("打開(kāi)藍(lán)牙" );???? ????????????????????searchDevices.setEnabled(false );???? ????????????????????bondDevicesListView.setEnabled(false );???? ????????????????????unbondDevicesListView.setEnabled(false );???? ????????????????}???? ????????????}???? ???? ????????}???? ???? ????};???? ???? }?? 到這里,第一個(gè)界面的代碼就寫(xiě)完了,當(dāng)我們點(diǎn)擊要打印的藍(lán)牙設(shè)備時(shí)就會(huì)跳轉(zhuǎn)到打印頁(yè)面,跳轉(zhuǎn)代碼在BluetoothService.java的addBondDevicesToListView()中
?
?
接下來(lái)讓我們來(lái)看看第二個(gè)界面的代碼,結(jié)構(gòu)和第一個(gè)界面的代碼一樣,分類(lèi)三個(gè)類(lèi),請(qǐng)看代碼。。。。。
?
PrintDataActivity.java
?
[java] ?view plaincopy
public ?class ?PrintDataActivity?extends ?Activity?{????????private ?Context?context?=?null ;???? ???? ????public ?void ?onCreate(Bundle?savedInstanceState)?{???? ????????super .onCreate(savedInstanceState);???? ????????this .setTitle("藍(lán)牙打印" );???? ????????this .setContentView(R.layout.printdata_layout);???? ????????this .context?=?this ;???? ????????this .initListener();???? ????}???? ???? ????? ? ? ???? ????private ?String?getDeviceAddress()?{???? ?????????? ????????Intent?intent?=?this .getIntent();???? ?????????? ????????if ?(intent?!=?null )?{???? ????????????return ?intent.getStringExtra("deviceAddress" );???? ????????}?else ?{???? ????????????return ?null ;???? ????????}???? ????}???? ???? ????private ?void ?initListener()?{???? ????????TextView?deviceName?=?(TextView)?this .findViewById(R.id.device_name);???? ????????TextView?connectState?=?(TextView)?this ???? ????????????????.findViewById(R.id.connect_state);???? ???? ????????PrintDataAction?printDataAction?=?new ?PrintDataAction(this .context,???? ????????????????this .getDeviceAddress(),?deviceName,?connectState);???? ???? ????????EditText?printData?=?(EditText)?this .findViewById(R.id.print_data);???? ????????Button?send?=?(Button)?this .findViewById(R.id.send);???? ????????Button?command?=?(Button)?this .findViewById(R.id.command);???? ????????printDataAction.setPrintData(printData);???? ???? ????????send.setOnClickListener(printDataAction);???? ????????command.setOnClickListener(printDataAction);???? ????}???? ???? ???????? ????@Override ???? ????protected ?void ?onDestroy()?{???? ????????PrintDataService.disconnect();???? ????????super .onDestroy();???? ????}???? ???????? }?? ?
PrintDataAction.java
?
?
[java] ?view plaincopy
<span?style="font-size:14px" >public ?class ?PrintDataAction?implements ?OnClickListener?{???? ????private ?Context?context?=?null ;???? ????private ?TextView?deviceName?=?null ;???? ????private ?TextView?connectState?=?null ;???? ????private ?EditText?printData?=?null ;???? ????private ?String?deviceAddress?=?null ;???? ????private ?PrintDataService?printDataService?=?null ;???? ???? ????public ?PrintDataAction(Context?context,?String?deviceAddress,???? ????????????TextView?deviceName,?TextView?connectState)?{???? ????????super ();???? ????????this .context?=?context;???? ????????this .deviceAddress?=?deviceAddress;???? ????????this .deviceName?=?deviceName;???? ????????this .connectState?=?connectState;???? ????????this .printDataService?=?new ?PrintDataService(this .context,???? ????????????????this .deviceAddress);???? ????????this .initView();???? ???? ????}???? ???? ????private ?void ?initView()?{???? ?????????? ????????this .deviceName.setText(this .printDataService.getDeviceName());???? ?????????? ????????boolean ?flag?=?this .printDataService.connect();???? ????????if ?(flag?==?false )?{???? ?????????????? ????????????this .connectState.setText("連接失敗!" );???? ????????}?else ?{???? ?????????????? ????????????this .connectState.setText("連接成功!" );???? ???? ????????}???? ????}???? ???? ????public ?void ?setPrintData(EditText?printData)?{???? ????????this .printData?=?printData;???? ????}???? ???? ????@Override ???? ????public ?void ?onClick(View?v)?{???? ????????if ?(v.getId()?==?R.id.send)?{???? ????????????String?sendData?=?this .printData.getText().toString();???? ????????????this .printDataService.send(sendData?+?"\n" );???? ????????}?else ?if ?(v.getId()?==?R.id.command)?{???? ????????????this .printDataService.selectCommand();???? ???? ????????}???? ????}???? }</span>?? PrintDataService.java
?
?
?
[java] ?view plaincopy
<span?style="font-size:14px" >public ?class ?PrintDataService?{???? ????private ?Context?context?=?null ;???? ????private ?String?deviceAddress?=?null ;???? ????private ?BluetoothAdapter?bluetoothAdapter?=?BluetoothAdapter???? ????????????.getDefaultAdapter();???? ????private ?BluetoothDevice?device?=?null ;???? ????private ?static ?BluetoothSocket?bluetoothSocket?=?null ;???? ????private ?static ?OutputStream?outputStream?=?null ;???? ????private ?static ?final ?UUID?uuid?=?UUID???? ????????????.fromString("00001101-0000-1000-8000-00805F9B34FB" );???? ????private ?boolean ?isConnection?=?false ;???? ????final ?String[]?items?=?{?"復(fù)位打印機(jī)" ,?"標(biāo)準(zhǔn)ASCII字體" ,?"壓縮ASCII字體" ,?"字體不放大" ,???? ????????????"寬高加倍" ,?"取消加粗模式" ,?"選擇加粗模式" ,?"取消倒置打印" ,?"選擇倒置打印" ,?"取消黑白反顯" ,?"選擇黑白反顯" ,???? ????????????"取消順時(shí)針旋轉(zhuǎn)90°" ,?"選擇順時(shí)針旋轉(zhuǎn)90°" ?};???? ????final ?byte [][]?byteCommands?=?{?{?0x1b ,?0x40 ?},?? ????????????{?0x1b ,?0x4d ,?0x00 ?},?? ????????????{?0x1b ,?0x4d ,?0x01 ?},?? ????????????{?0x1d ,?0x21 ,?0x00 ?},?? ????????????{?0x1d ,?0x21 ,?0x11 ?},?? ????????????{?0x1b ,?0x45 ,?0x00 ?},?? ????????????{?0x1b ,?0x45 ,?0x01 ?},?? ????????????{?0x1b ,?0x7b ,?0x00 ?},?? ????????????{?0x1b ,?0x7b ,?0x01 ?},?? ????????????{?0x1d ,?0x42 ,?0x00 ?},?? ????????????{?0x1d ,?0x42 ,?0x01 ?},?? ????????????{?0x1b ,?0x56 ,?0x00 ?},?? ????????????{?0x1b ,?0x56 ,?0x01 ?},?? ????};???? ???? ????public ?PrintDataService(Context?context,?String?deviceAddress)?{???? ????????super ();???? ????????this .context?=?context;???? ????????this .deviceAddress?=?deviceAddress;???? ????????this .device?=?this .bluetoothAdapter.getRemoteDevice(this .deviceAddress);???? ????}???? ???? ????? ? ? ? ???? ????public ?String?getDeviceName()?{???? ????????return ?this .device.getName();???? ????}???? ???? ????? ? ???? ????public ?boolean ?connect()?{???? ????????if ?(!this .isConnection)?{???? ????????????try ?{???? ????????????????bluetoothSocket?=?this .device???? ????????????????????????.createRfcommSocketToServiceRecord(uuid);???? ????????????????bluetoothSocket.connect();???? ????????????????outputStream?=?bluetoothSocket.getOutputStream();???? ????????????????this .isConnection?=?true ;???? ????????????????if ?(this .bluetoothAdapter.isDiscovering())?{???? ????????????????????System.out.println("關(guān)閉適配器!" );???? ????????????????????this .bluetoothAdapter.isDiscovering();???? ????????????????}???? ????????????}?catch ?(Exception?e)?{???? ????????????????Toast.makeText(this .context,?"連接失敗!" ,?1 ).show();???? ????????????????return ?false ;???? ????????????}???? ????????????Toast.makeText(this .context,?this .device.getName()?+?"連接成功!" ,???? ????????????????????Toast.LENGTH_SHORT).show();???? ????????????return ?true ;???? ????????}?else ?{???? ????????????return ?true ;???? ????????}???? ????}???? ???? ????? ? ???? ????public ?static ?void ?disconnect()?{???? ????????System.out.println("斷開(kāi)藍(lán)牙設(shè)備連接" );???? ????????try ?{???? ????????????bluetoothSocket.close();???? ????????????outputStream.close();???? ????????}?catch ?(IOException?e)?{???? ?????????????? ????????????e.printStackTrace();???? ????????}???? ???? ????}???? ???? ????? ? ???? ????public ?void ?selectCommand()?{???? ????????new ?AlertDialog.Builder(context).setTitle("請(qǐng)選擇指令" )???? ????????????????.setItems(items,?new ?DialogInterface.OnClickListener()?{???? ????????????????????@Override ???? ????????????????????public ?void ?onClick(DialogInterface?dialog,?int ?which)?{???? ????????????????????????try ?{???? ????????????????????????????outputStream.write(byteCommands[which]);???? ????????????????????????}?catch ?(IOException?e)?{???? ????????????????????????????Toast.makeText(context,?"設(shè)置指令失敗!" ,???? ????????????????????????????????????Toast.LENGTH_SHORT).show();???? ????????????????????????}???? ????????????????????}???? ????????????????}).create().show();???? ????}???? ???? ????? ? ???? ????public ?void ?send(String?sendData)?{???? ????????if ?(this .isConnection)?{???? ????????????System.out.println("開(kāi)始打印!!" );???? ????????????try ?{???? ????????????????byte []?data?=?sendData.getBytes("gbk" );???? ????????????????outputStream.write(data,?0 ,?data.length);???? ????????????????outputStream.flush();???? ????????????}?catch ?(IOException?e)?{???? ????????????????Toast.makeText(this .context,?"發(fā)送失敗!" ,?Toast.LENGTH_SHORT)???? ????????????????????????.show();???? ????????????}???? ????????}?else ?{???? ????????????Toast.makeText(this .context,?"設(shè)備未連接,請(qǐng)重新連接!" ,?Toast.LENGTH_SHORT)???? ????????????????????.show();???? ???? ????????}???? ????}???? ???? }</span>?? 到此,全部代碼貼完,也就大功告成了
?
?
對(duì)了對(duì)了,差點(diǎn)忘記一件很重要的事情!!清單文件忘記給權(quán)限啦!!
權(quán)限
[html] ?view plaincopy
< span ?style ="font-size:14px" > < uses-permission ?android:name ="android.permission.BLUETOOTH" ?/> ????????< uses-permission ?android:name ="android.permission.BLUETOOTH_ADMIN" ?/> ?</ span > ?? 注冊(cè)Activity ?
[html] ?view plaincopy
< span ?style ="font-size:14px" > < activity ?android:name =".BluetoothActivity" ?/> ????< activity ?android:name =".PrintDataActivity" ?/> ?</ span > < span ?style ="font-size:14px" > ????? </ span > ?? 這下子就真的搞定了!
?
更多 3
下一篇:java實(shí)現(xiàn)約瑟夫問(wèn)題 頂
5 踩
0 查看評(píng)論 12樓?
泓豆奶茶?昨天 10:32發(fā)表 ?[回復(fù)] 按你說(shuō)的還是成功不了,能加QQ聊嗎?qq:1584166172 11樓?
zywxsg0612?4天前 15:42發(fā)表 ?[回復(fù)] LZ 你好 問(wèn)個(gè)問(wèn)題createRfcommSocketToServiceRecord(uuid) 對(duì)于其中的UUID,我直接用生成器生成一個(gè)復(fù)制過(guò)去,在這里是可以用的嗎? 還是說(shuō)uuid有什么特殊的??百度了下 貌似這個(gè)識(shí)別碼生成后就可以用了。。 還有就是后邊的打印指令 0x1b, 0x40 1b應(yīng)該是esc 40是@ ?? 剛開(kāi)始學(xué)著寫(xiě)android 很多不是很懂,有些問(wèn)題 類(lèi)似USB 啊 打印機(jī) 搜出來(lái)的都是各種廣告,很少和開(kāi)發(fā)有關(guān)。。。 Re:?
reality_jie?4天前 16:25發(fā)表 ?[回復(fù)] 回復(fù)zywxsg0612:uuid沒(méi)有特殊的,直接用生成器生成一個(gè)復(fù)制過(guò)去可以 Re:?
zywxsg0612?前天 09:59發(fā)表 ?[回復(fù)] 回復(fù)reality_jie:謝謝。。。 10樓?
xingzjx?2013-12-06 15:07發(fā)表 ?[回復(fù)] 謝謝樓主分享!!! 9樓?
qq624196743?2013-11-29 17:52發(fā)表 ?[回復(fù)] 碉堡了,好文啊 Re:?
reality_jie?2013-11-29 18:09發(fā)表 ?[回復(fù)] 回復(fù)qq624196743:謝謝^_^o~ 努力! 8樓?
csaily504768527?2013-11-29 11:07發(fā)表 ?[回復(fù)] 樓主你好。我想請(qǐng)問(wèn)一下,你的那些打印指令還有么。使用你上面的代碼打印中文時(shí)候會(huì)出現(xiàn)亂碼。。 Re:?
reality_jie?2013-11-29 11:10發(fā)表 ?[回復(fù)] 回復(fù)csaily504768527:指令就這些。。但是我在我這里的幾臺(tái)打印機(jī)測(cè)試都不會(huì)出現(xiàn)亂碼哦,如果出現(xiàn)亂碼,你嘗試在里邊修改一下 byte[] data = sendData.getBytes("gbk"): 把gbk修改成utf-8 Re:?
csaily504768527?2013-11-29 11:33發(fā)表 ?[回復(fù)] 回復(fù)reality_jie:樓主。。還是不成功。。我測(cè)試的設(shè)備是HP 100 便攜式藍(lán)牙打印機(jī)。。還嘗試了。。GB2312 .. BIG5... GBK 。等。都還是亂碼。。這怎么搞起。。 好不科學(xué)啊。。-_-.......淚崩的節(jié)奏中。。 Re:?
reality_jie?2013-11-29 14:16發(fā)表 ?[回復(fù)] 回復(fù)csaily504768527:出現(xiàn)亂碼的根本原因是打印機(jī)和手機(jī)發(fā)送的數(shù)據(jù)的編碼不統(tǒng)一。你先去確認(rèn)一下你的打印機(jī)是用什么編碼來(lái)表示中文的 7樓?
蝸蝸牛快跑?2013-11-27 20:32發(fā)表 ?[回復(fù)] 樓主,您好,我最近也想實(shí)現(xiàn)一個(gè)藍(lán)牙打印的功能。但是在藍(lán)牙通信的時(shí)候遇到了點(diǎn)問(wèn)題,我的socket在connet這步,一直報(bào)錯(cuò):java.io.IOException: Service discovery failed。我用的UUID跟你是一樣的,我目前是想連接其他手機(jī)(已開(kāi)啟藍(lán)牙服務(wù))。您知道怎么解決么? Re:?
reality_jie?2013-11-27 21:12發(fā)表 ?[回復(fù)] 回復(fù)superbinbin1:這個(gè)代碼只能用于手機(jī)與打印機(jī)之間的連接哦 Re:?
蝸蝸牛快跑?2013-11-27 23:15發(fā)表 ?[回復(fù)] 回復(fù)reality_jie:這樣呀,那手機(jī)之間連接。。。用什么UUID?UUID的類(lèi)型不是根據(jù)服務(wù)來(lái)選的么?因?yàn)槲液芎闷?#xff0c;安卓自帶的藍(lán)牙分享功能,幾乎是無(wú)論對(duì)方是什么藍(lán)牙,都可以把文件分享過(guò)去,手機(jī)之間自然不用說(shuō),電腦端的藍(lán)牙適配器也可以傳,hp的打印機(jī)我也有試過(guò),可以直接發(fā)圖片過(guò)去打印。那么他是如何設(shè)計(jì)的???樓主大神幫忙解答疑惑呀,感激不盡。 Re:?
reality_jie?2013-11-29 18:11發(fā)表 ?[回復(fù)] 回復(fù)superbinbin1:親,這個(gè)問(wèn)題我也有待研究哦 6樓?
微揚(yáng)的嘴角?2013-11-07 14:31發(fā)表 ?[回復(fù)] 對(duì)任意型號(hào)藍(lán)牙打印機(jī)通用嗎? Re:?
reality_jie?2013-11-07 14:40發(fā)表 ?[回復(fù)] 回復(fù)feng52101:可以 5樓?
bhald6821935?2013-10-18 11:20發(fā)表 ?[回復(fù)] 樓主 能發(fā)個(gè)源碼麼。謝謝646965572@qq.com Re:?
reality_jie?2013-10-18 13:42發(fā)表 ?[回復(fù)] 回復(fù)bhald6821935:http://download.csdn.net/detail/reality_jie/6418413 完整源碼 4樓?
wang158210867?2013-10-12 16:01發(fā)表 ?[回復(fù)] 有沒(méi)有遇到 打不了中文 或者 中文亂碼問(wèn)題呀 Re:?
csaily504768527?2013-11-29 11:37發(fā)表 ?[回復(fù)] 回復(fù)wang158210867:哥們,你那個(gè)亂碼問(wèn)題找到解決辦法木有。。或者是思路。。 Re:?
reality_jie?2013-10-12 17:25發(fā)表 ?[回復(fù)] 回復(fù)wang158210867:我自己做的測(cè)試都沒(méi)有出現(xiàn)中文亂碼哦 3樓?
zhafei1311?2013-09-27 15:50發(fā)表 ?[回復(fù)] 有沒(méi)有打印圖片的代碼 Re:?
reality_jie?2013-09-27 17:38發(fā)表 ?[回復(fù)] 回復(fù)u012243481:暫時(shí)沒(méi)有 2樓?
紅姬茄子?2013-09-25 14:45發(fā)表 ?[回復(fù)] 樓主,我想問(wèn)下這個(gè)android手機(jī)連接藍(lán)牙打印能不能指定文件打印呢,譬如說(shuō)我指定一張圖片,或一個(gè)文檔什么的讓打印機(jī)打印,這種功能能否實(shí)現(xiàn)嘞,求指教,嘿嘿 Re:?
reality_jie?2013-09-25 17:08發(fā)表 ?[回復(fù)] public void send(String sendData) {? if (this.isConnection) {? System.out.println("開(kāi)始打印!!");? try {? byte[] data = sendData.getBytes("gbk");? outputStream.write(data, 0, data.length);? outputStream.flush();? } catch (IOException e) {? Toast.makeText(this.context, "發(fā)送失敗!", Toast.LENGTH_SHORT)? .show();? }? } else {? Toast.makeText(this.context, "設(shè)備未連接,請(qǐng)重新連接!", Toast.LENGTH_SHORT)? .show();? } 從這個(gè)打印方法可以看出,打印的數(shù)據(jù)是以二進(jìn)制流發(fā)送出去的。也就是說(shuō),如果你想打印外部文檔,只要用一個(gè)輸入流,比如BufferedReader把數(shù)據(jù)讀入再轉(zhuǎn)成二進(jìn)制流交給outputStream,應(yīng)該是能實(shí)現(xiàn)的。至于圖片。。。暫時(shí)我就不知道怎么弄了 1樓?
紅姬茄子?2013-09-24 17:04發(fā)表 ?[回復(fù)] 不錯(cuò)不錯(cuò),多謝樓主分享,學(xué)習(xí)了,贊一個(gè) Re:?
reality_jie?2013-09-24 17:31發(fā)表 ?[回復(fù)] Y(^_^)Y 您還沒(méi)有登錄,請(qǐng)[登錄](méi)或[注冊(cè)] * 以上用戶言論只代表其個(gè)人觀點(diǎn),不代表CSDN網(wǎng)站的觀點(diǎn)或立場(chǎng)
核心技術(shù)類(lèi)目 全部主題?Java?VPN?Android?iOS?ERP?IE10?Eclipse?CRM?JavaScript?Ubuntu?NFCWAP?jQuery?數(shù)據(jù)庫(kù)?BI?HTML5?Spring?Apache?Hadoop?.NET?API?HTML?SDK?IISFedora?XML?LBS?Unity?Splashtop?UML?components?Windows Mobile?Rails?QEMUKDE?Cassandra?CloudStack?FTC?coremail?OPhone?CouchBase?云計(jì)算?iOS6?RackspaceWeb App?SpringSide?Maemo?Compuware?大數(shù)據(jù)?aptech?Perl?Tornado?Ruby?HibernateThinkPHP?Spark?HBase?Pure?Solr?Angular?Cloud Foundry?Redis?Scala?DjangoBootstrap 個(gè)人資料 ?
reality_jie ?
訪問(wèn):4114次 積分:269分 排名:千里之外 原創(chuàng):17篇 轉(zhuǎn)載:0篇 譯文:0篇 評(píng)論:29條 2013年11月(4) 2013年10月(7) 2013年09月(6) android(11) javaSE(2) oracle(4) 安卓手機(jī)連接藍(lán)牙打印機(jī)實(shí)現(xiàn)打印功能(958) android通過(guò)服務(wù)實(shí)現(xiàn)消息推送(363) android加載大圖片到內(nèi)存(304) android從圖庫(kù)(gallery)選擇一張圖片(299) 安卓短信發(fā)送器(247) oracle變異表觸發(fā)器中ORA-04091錯(cuò)誤原因及解決方案(243) android.view.ViewRootImpl$CalledFromWrongThreadException異常處理(231) java多線程同步:生產(chǎn)者與消費(fèi)者問(wèn)題(203) android+lucene實(shí)現(xiàn)全文檢索并高亮關(guān)鍵字(192) andorid使用異步http框架和第三方HttpClinet上傳文件(171) 安卓手機(jī)連接藍(lán)牙打印機(jī)實(shí)現(xiàn)打印功能(28) android加載大圖片到內(nèi)存(1) android從圖庫(kù)(gallery)選擇一張圖片(0) android通過(guò)服務(wù)實(shí)現(xiàn)消息推送(0) 安卓短信發(fā)送器(0) java多線程同步:生產(chǎn)者與消費(fèi)者問(wèn)題(0) andorid使用異步http框架和第三方HttpClinet上傳文件(0) android.view.ViewRootImpl$CalledFromWrongThreadException異常處理(0) android.os.NetworkOnMainThreadException異常處理(0) adb server is out of date. killing解決方案(0) 安卓手機(jī)連接藍(lán)牙打印機(jī)實(shí)現(xiàn)打印功能 泓豆奶茶: 按你說(shuō)的還是成功不了,能加QQ聊嗎?qq:1584166172
安卓手機(jī)連接藍(lán)牙打印機(jī)實(shí)現(xiàn)打印功能 zywxsg0612: @reality_jie:謝謝。。。
安卓手機(jī)連接藍(lán)牙打印機(jī)實(shí)現(xiàn)打印功能 reality_jie: @zywxsg0612:uuid沒(méi)有特殊的,直接用生成器生成一個(gè)復(fù)制過(guò)去可以
安卓手機(jī)連接藍(lán)牙打印機(jī)實(shí)現(xiàn)打印功能 zywxsg0612: LZ 你好 問(wèn)個(gè)問(wèn)題createRfcommSocketToServiceRecord(uuid)對(duì)...
安卓手機(jī)連接藍(lán)牙打印機(jī)實(shí)現(xiàn)打印功能 xingzjx: 謝謝樓主分享!!!
安卓手機(jī)連接藍(lán)牙打印機(jī)實(shí)現(xiàn)打印功能 reality_jie: @superbinbin1:親,這個(gè)問(wèn)題我也有待研究哦
安卓手機(jī)連接藍(lán)牙打印機(jī)實(shí)現(xiàn)打印功能 reality_jie: @qq624196743:謝謝^_^o~ 努力!
安卓手機(jī)連接藍(lán)牙打印機(jī)實(shí)現(xiàn)打印功能 qq624196743: 碉堡了,好文啊
安卓手機(jī)連接藍(lán)牙打印機(jī)實(shí)現(xiàn)打印功能 reality_jie: @csaily504768527:出現(xiàn)亂碼的根本原因是打印機(jī)和手機(jī)發(fā)送的數(shù)據(jù)的編碼不統(tǒng)一。你先去確認(rèn)...
安卓手機(jī)連接藍(lán)牙打印機(jī)實(shí)現(xiàn)打印功能 csaily504768527: @wang158210867:哥們,你那個(gè)亂碼問(wèn)題找到解決辦法木有。。或者是思路。。
公司簡(jiǎn)介|招賢納士|廣告服務(wù)|銀行匯款帳號(hào)|聯(lián)系方式|版權(quán)聲明|法律顧問(wèn)|問(wèn)題報(bào)告 QQ客服?微博客服?論壇反饋?聯(lián)系郵箱:webmaster@csdn.net?服務(wù)熱線:400-600-2320 京?ICP?證?070598?號(hào) 北京創(chuàng)新樂(lè)知信息技術(shù)有限公司 版權(quán)所有 世紀(jì)樂(lè)知(北京)網(wǎng)絡(luò)技術(shù)有限公司 提供技術(shù)支持 江蘇樂(lè)知網(wǎng)絡(luò)技術(shù)有限公司 提供商務(wù)支持 Copyright ? 1999-2012, CSDN.NET, All Rights Reserved? ?
轉(zhuǎn)載于:https://www.cnblogs.com/liumengandorid/p/3473780.html
總結(jié)
以上是生活随笔 為你收集整理的android蓝牙打印机 的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
如果覺(jué)得生活随笔 網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔 推薦給好友。