91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 7KB
    文件類型: .rar
    金幣: 2
    下載: 0 次
    發布日期: 2021-05-16
  • 語言: 其他
  • 標簽:

資源簡介

Xamarin藍牙打印,已經封裝好了代碼,直接移植過去使用,可自行擴展,按照使用例子直接調用打印。注意:需要打開設備的藍牙。

資源截圖

代碼片段和文件信息

using?System;
using?System.Collections.Generic;
using?System.IO;
using?System.Linq;
using?System.Text;

using?Android.App;
using?Android.Bluetooth;
using?Android.Content;
using?Android.OS;
using?Android.Runtime;
using?Android.Views;
using?Android.Widget;
using?Java.Util;

namespace?MshSelf.Helper
{
????///?
????///?藍牙打印幫助類
????///?

????public?class?BluetoothUtil
????{
????????private?static?UUID?PRINTER_UUID?=?UUID.FromString(“00001101-0000-1000-8000-00805F9B34FB“);

????????private?static?string?Innerprinter_Address?=?“00:11:22:33:44:55“;

????????private?static?BluetoothSocket?bluetoothSocket;

????????private?static?BluetoothAdapter?getBTAdapter()
????????{
????????????return?BluetoothAdapter.DefaultAdapter;
????????}

????????private?static?BluetoothDevice?getDevice(BluetoothAdapter?bluetoothAdapter)
????????{
????????????BluetoothDevice?innerprinter_device?=?null;
????????????List?devices?=?bluetoothAdapter.BondedDevices.ToList();
????????????foreach?(BluetoothDevice?device?in?devices)
????????????{
????????????????if?(device.Address.Equals(Innerprinter_Address))
????????????????{
????????????????????innerprinter_device?=?device;
????????????????????break;
????????????????}
????????????}
????????????return?innerprinter_device;
????????}

????????private?static?BluetoothSocket?getSocket(BluetoothDevice?device)
????????{
????????????BluetoothSocket?socket?=?null;
????????????socket?=?device.CreateRfcommSocketToServiceRecord(PRINTER_UUID);
????????????socket.Connect();
????????????return?socket;
????????}

????????/**
?????????*?連接藍牙
?????????*
?????????*?@param?context
?????????*?@return
?????????*/
????????public?static?bool?connectBlueTooth(Context?context)
????????{
????????????if?(bluetoothSocket?==?null)
????????????{
????????????????if?(getBTAdapter()?==?null)
????????????????{
????????????????????return?false;
????????????????}
????????????????if?(!getBTAdapter().IsEnabled)
????????????????{
????????????????????return?false;
????????????????}
????????????????BluetoothDevice?device;
????????????????if?((device?=?getDevice(getBTAdapter()))?==?null)
????????????????{
????????????????????return?false;
????????????????}

????????????????try
????????????????{
????????????????????bluetoothSocket?=?getSocket(device);
????????????????}
????????????????catch?(Exception?e)
????????????????{
????????????????????return?false;
????????????????}
????????????}
????????????return?true;
????????}

????????/**
?????????*?斷開藍牙
?????????*/
????????public?static?void?disconnectBlueTooth(Context?context)
????????{
????????????if?(bluetoothSocket?!=?null)
????????????{
????????????????try
????????????????{
????????????????????Stream?mOut?=?bluetoothSocket.OutputStream;
????????????????????mOut.Close();
????????????????????bluetoothSocket.Close();
????????????????????bluetoothSocket?=?null;
????????????????}
?????????????

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----

?????文件???????3881??2018-07-18?19:12??Xamarin藍牙打印例子\BluetoothUtil.cs

?????文件???????7029??2018-07-18?19:12??Xamarin藍牙打印例子\BytesUtil.cs

?????文件??????18072??2018-07-18?19:12??Xamarin藍牙打印例子\ESCUtil.cs

?????文件??????11690??2018-07-18?19:12??Xamarin藍牙打印例子\PrinterHelper.cs

?????文件?????????98??2018-08-13?12:49??Xamarin藍牙打印例子\使用例子.txt

?????目錄??????????0??2018-08-13?12:48??Xamarin藍牙打印例子

-----------?---------??----------?-----??----

????????????????40770????????????????????6


評論

共有 條評論

相關資源