我有一个通过蓝牙连接到设备的项目.它曾经相当可靠地工作,但现在它BluetoothSocket.connect()
每次都无法通话.(好吧,我在4小时内的数千次尝试中连接了一次.)大部分代码都取自API中的标准示例聊天代码,但获取BluetoothSocket
设备本身的常见修改除外:
Method m = device.getClass().getMethod(
"createRfcommSocket", new Class[] { int.class });
tmp = (BluetoothSocket) m.invoke(device, Integer.valueOf(1));
Run Code Online (Sandbox Code Playgroud)
这是感兴趣的方法,一旦BluetoothSocket
获得就会运行:
public void run() {
setName("ConnectThread" + mSocketType);
// Always cancel discovery because it will slow down a connection
mAdapter.cancelDiscovery();
// Make a connection to the BluetoothSocket
try {
mmSocket.connect();
} catch (Exception e) {
Log.e(TAG, "Connection to " + mmDevice.getName() + " at "
+ mmDevice.getAddress() + " failed:" + e.getMessage());
// Close the socket
try { …
Run Code Online (Sandbox Code Playgroud) 我正在制作一个扩展,将当前活动网页中的选定文本存储到localstorage中,然后当用户在我的扩展程序弹出窗口中单击此选定文本时,扩展程序将触发chrome.tabs.create并打开所选文本所在的网站选择.这些功能有效,但我不知道在新标签打开时如何触发'find'功能.我希望新创建的选项卡高度显示我的扩展程序存储的选定文本.我认为有两种方法可以做到这一点......
以某种方式触发默认浏览器具有的"查找"功能.使用"Ctrl + F"或"Command + F"触发并在其中插入所选文本
通过突出显示所选文本来编辑新创建页面的HTML.
new_source = { "url" : tab[0].url, "title" : tab[0].title, "quote" : selectedQuote, "id" : idSource};
sources.push(new_source);
localStorage["sources"] = JSON.stringify(sources);
Run Code Online (Sandbox Code Playgroud)
这就是我存储信息的方式
是否有可能EditText
在android 2.x中制作一个看起来像EditText
Android 4的?我的意思是蓝色背光,下面有法兰边缘.