• 大小: 1.99MB
    文件类型: .zip
    金币: 2
    下载: 1 次
    发布日期: 2023-10-21
  • 语言: 其他
  • 标签: 安卓  

资源简介

stm32采集经纬度通过蓝牙模块发送给手机,手机解析经纬度,通过webview进行加载到地图,进行位置标记。此app开发使用的是eclipse。

资源截图

代码片段和文件信息

package com.test.BTClient;



import java.io.IOException;
import java.io.OutputStream;
import java.util.UUID;

import android.app.Activity;
import android.bluetooth.BluetoothAdapter;
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.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

public class BTClient extends Activity {

private TextView text0;
    private EditText edit0;
    
  //按钮动作,监听服务端口,打开UUID服务

    BluetoothDevice _device = null;
    BluetoothSocket _socket = null;
    boolean _discoveryFinished = false;

    private BluetoothAdapter _bluetooth = BluetoothAdapter.getDefaultAdapter();



    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        text0 = (TextView)findViewById(R.id.Text0);
        edit0 = (EditText)findViewById(R.id.Edit0);

        
      //打开本地设备
        if (_bluetooth == null){
         Toast.makeText(this “Bluetooth is not available“ Toast.LENGTH_LONG).show();
          //  finish();
            return;
        }
        
        // 设置设备可以被搜索  
        _bluetooth.enable();
        if(_bluetooth.isEnabled()==false){
         Toast.makeText(this “Bluetooth can‘t be discorvered“ Toast.LENGTH_LONG).show();
         //finish();
         return;
        }
        
        
        text0.setText(“打个本地蓝牙服务成功!“);
    }
    

    //定义广播接收器
    private BroadcastReceiver _foundReceiver = new BroadcastReceiver() {
public void onReceive(Context context Intent intent) {
/* 从intent中取得搜索结果数据 */
//BluetoothDevice _device0 = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
//if (_device0.getName().equals(“linvor“) )
_device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);;
text0.setText(“找寻到设备:“+_device.getName());
}
};
private BroadcastReceiver _discoveryReceiver = new BroadcastReceiver() {

@Override
public void onReceive(Context context Intent intent) 
{
/* 卸载注册的接收器 */
unregisterReceiver(_foundReceiver);
unregisterReceiver(this);
_discoveryFinished = true;
}
};
    
    //连接搜寻服务
public void onSearchButtonclicked(View v){

IntentFilter discoveryFilter = new IntentFilter(BluetoothAdapter.ACTION_DISCOVERY_FINISHED);
registerReceiver(_discoveryReceiver discoveryFilter);
IntentFilter foundFilter = new IntentFilter(BluetoothDevice.ACTION_FOUND);
registerReceiver(_foundReceiver foundFilter);
new Thread(){
     public void run() 
     {
     //开始搜索 
     _bluetooth.startDiscovery();
     for (;;) 
     {
     if (_discoveryFinished) 
     {
     break;
     }
     try 
     {
     Thread.sleep(10

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2019-05-07 08:39  BTClient\
     文件         475  2018-05-31 22:23  BTClient\.classpath
     文件         844  2010-12-01 16:58  BTClient\.project
     目录           0  2019-05-07 08:39  BTClient\.settings\
     文件         177  2014-02-08 09:41  BTClient\.settings\org.eclipse.jdt.core.prefs
     文件        1405  2019-11-08 19:05  BTClient\AndroidManifest.xml
     目录           0  2019-11-08 20:40  BTClient\assets\
     目录           0  2019-05-07 08:39  BTClient\backup\
     文件        4558  2010-12-11 17:00  BTClient\backup\BTClient.java
     目录           0  2019-11-08 20:31  BTClient\bin\
     文件        1405  2019-11-08 19:05  BTClient\bin\AndroidManifest.xml
     文件      171360  2019-11-08 20:31  BTClient\bin\BTClient.apk
     目录           0  2019-11-08 20:30  BTClient\bin\classes\
     目录           0  2019-11-08 20:30  BTClient\bin\classes\com\
     目录           0  2019-11-08 20:30  BTClient\bin\classes\com\test\
     目录           0  2019-11-08 20:30  BTClient\bin\classes\com\test\BTClient\
     文件        2260  2019-11-08 20:30  BTClient\bin\classes\com\test\BTClient\BTClient$1.class
     文件         853  2019-11-08 20:30  BTClient\bin\classes\com\test\BTClient\BTClient$2$1.class
     文件        2320  2019-11-08 20:30  BTClient\bin\classes\com\test\BTClient\BTClient$2.class
     文件         819  2019-11-08 20:30  BTClient\bin\classes\com\test\BTClient\BTClient$3.class
     文件        2609  2019-11-08 20:30  BTClient\bin\classes\com\test\BTClient\BTClient$4.class
     文件         795  2019-11-08 20:30  BTClient\bin\classes\com\test\BTClient\BTClient$5.class
     文件        9263  2019-11-08 20:30  BTClient\bin\classes\com\test\BTClient\BTClient.class
     文件         343  2019-11-08 20:30  BTClient\bin\classes\com\test\BTClient\BuildConfig.class
     文件        1989  2019-11-08 20:30  BTClient\bin\classes\com\test\BTClient\DeviceListActivity$1.class
     文件        2226  2019-11-08 20:30  BTClient\bin\classes\com\test\BTClient\DeviceListActivity$2.class
     文件         875  2019-11-08 20:30  BTClient\bin\classes\com\test\BTClient\DeviceListActivity$3.class
     文件        4280  2019-11-08 20:30  BTClient\bin\classes\com\test\BTClient\DeviceListActivity.class
     文件         337  2019-11-08 20:30  BTClient\bin\classes\com\test\BTClient\R$attr.class
     文件         397  2019-11-08 20:30  BTClient\bin\classes\com\test\BTClient\R$drawable.class
     文件         994  2019-11-08 20:30  BTClient\bin\classes\com\test\BTClient\R$id.class
............此处省略61个文件信息

评论

共有 条评论