第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

誰(shuí)能幫我把下面的 藍(lán)牙通訊代碼寫(xiě)下 翻譯啊,最好每一行都寫(xiě)一下 或者偽代碼寫(xiě)出來(lái)。謝謝;啊

誰(shuí)能幫我把下面的 藍(lán)牙通訊代碼寫(xiě)下 翻譯啊,最好每一行都寫(xiě)一下 或者偽代碼寫(xiě)出來(lái)。謝謝;啊

慕粉3468678 2016-06-09 17:18:38
package com.dashan.bluth.service;import java.io.IOException;import java.io.InputStream;import java.io.OutputStream;import java.util.UUID;import android.app.Service;import android.bluetooth.BluetoothDevice;import android.bluetooth.BluetoothSocket;import android.content.BroadcastReceiver;import android.content.Context;import android.content.Intent;import android.content.IntentFilter;import android.os.IBinder;import android.util.Log;import com.dashan.bluth.base.BaseApplication;import com.dashan.bluth.bean.MessageInfo;import com.google.gson.Gson;public class BluthSocketService extends Service { public BluetoothSocket socket = null; // 藍(lán)牙通訊socket public final static String uuid = "00001101-0000-1000-8000-00805F9B34FB"; public final static String serviceName = "teacher"; public BluetoothDevice teacherBlueth;// 教師端藍(lán)牙 public MessageInfo minfo = null;// 通信消息 public Gson g = new Gson(); public boolean isrun = true; @Override public IBinder onBind(Intent intent) { // TODO Auto-generated method stub return null; } @Override public void onCreate() { // TODO Auto-generated method stub super.onCreate(); ScreenBroadcastReceiver mScreenReceiver = new ScreenBroadcastReceiver();// 注冊(cè)屏幕廣播監(jiān)聽(tīng) IntentFilter filter = new IntentFilter(); filter.addAction(Intent.ACTION_SCREEN_ON); filter.addAction(Intent.ACTION_SCREEN_OFF); filter.addAction(Intent.ACTION_USER_PRESENT); this.registerReceiver(mScreenReceiver, filter); BaseApplication ba = (BaseApplication) this.getApplication(); minfo = ba.getCurrentMinfo(); Log.d("msg", "service已經(jīng)啟動(dòng)了"); } public void connectToTeacher(final String msg) {// 建立通信連接 BaseApplication ba = (BaseApplication) this.getApplication(); teacherBlueth = ba.getCurrentService(); new Thread() { public void run() { boolean connected = true; try { socket = teacherBlueth .createRfcommSocketToServiceRecord(UUID .fromString(uuid)); socket.connect(); } catch (IOException e) { // TODO Auto-generated catch block、 connected = false; Log.d("msg", "老師端關(guān)閉了簽到服務(wù)"); stopSelf();// 關(guān)閉后臺(tái)監(jiān)聽(tīng)服務(wù) } if (connected) { sendMsgToTeacher(msg); } }; }.start(); } @Override @Deprecated public void onStart(Intent intent, int startId) { // TODO Auto-generated method stub super.onStart(intent, startId); } public void sendMsgToTeacher(final String msg) {// 發(fā)送消息給服務(wù)器 new Thread() { public void run() { try { Log.d("msg", msg); OutputStream outStream = socket.getOutputStream(); outStream.write(msg.getBytes()); } catch (IOException e) { Log.e("msg", "連接教師端通信失敗" + e.toString()); } }; }.start(); } private class ScreenBroadcastReceiver extends BroadcastReceiver { private String action = null; @Override public void onReceive(Context context, Intent intent) { action = intent.getAction(); if (Intent.ACTION_SCREEN_ON.equals(action)) { // 開(kāi)屏,學(xué)生開(kāi)屏后發(fā)給老師 } else if (Intent.ACTION_SCREEN_OFF.equals(action)) { // 鎖屏 } else if (Intent.ACTION_USER_PRESENT.equals(action)) { // 解鎖 minfo.msgType = "2"; minfo.qr.setPhoneactive(Integer.parseInt(minfo.qr.phoneactive) + 1 + ""); Log.d("msg", "用戶解開(kāi)屏幕了"); connectToTeacher(g.toJson(minfo)); } } }}
查看完整描述

目前暫無(wú)任何回答

  • 0 回答
  • 1 關(guān)注
  • 1877 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)