snowpigppp 2017-04-04 04:17 采纳率: 50%
浏览 1539
已结题

从Github上下载的android蓝牙代码,显示外部无法调用非公共

https://github.com/pkarira/Androble
这个是代码链接
我用的是他提供的参考MainActivity
具体代码是

package com.example.snowpig.myble;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.Toast;
import com.mdg.androble.BluetoothActivity;
import com.mdg.androble.BluetoothManager;
import com.mdg.androble.DeviceList;
import java.util.Observable;
import java.util.Observer;

public class MainActivity extends BluetoothActivity {


    BluetoothManager bluetoothManager;
    receiveMassage rm;
    DeviceList dl;
    String type="";
    ListView listview;
    int c=0;
    EditText et1;
    EditText et2;
    private ArrayAdapter adapter;


    @Override
    protected void onCreate(Bundle saveInstanceState){
        super.onCreate(saveInstanceState);
        setContentView(R.layout.activity_main);
        bluetoothManager=BluetoothManager.getInstance();
        rm=new receiveMassage();
        dl=new DeviceList();
        listview=(ListView)findViewById(R.id.select_dialog_listview);
        et1=(EditText)findViewById(R.id.text);
        et2=(EditText)findViewById(R.id.text2);
        listview.setOnItemClickListener(new AdapterView.OnItemClickListener(){
            @Override
                    public void onItemClick(AdapterView<?>parent, View view,int position,long id){
                String itemValue=(String) listview.getItemAtPosition(position);
                bluetoothManager.connectTo(itemValue);
            }
        });
        adapter=new ArrayAdapter(this,android.R.layout.simple_list_item_1);
        listview.setAdapter(adapter);
    }


    public void client(View v) {
    type = "CLIENT";
    bluetoothManager.Type(type);
    }

    public void server(View v){
        type="SERVER";
        bluetoothManager.Type(type);
    }

    public void start(View v){
        bluetoothManager.setMessageObject(rm);
        bluetoothManager.setListObject(dl);
        if (type.equals("CLIENT")){
            enableBluetooth();
        }
        if (type.equals("SERVER")){
            enableBluetooth();
        }
    }

    public void clienttoclient(View v){
        bluetoothManager.clientToClient(et1.getText().toString(),Integer.parseInt(et2.getText().toString()));
    }

    public void devicelist(View v){
        if(type.equals("SERVER"))
            Toast.makeText(getApplicationContext(), bluetoothManager.getAllConnectedDevices(), Toast.LENGTH_LONG).show();
        else
            bluetoothManager.getAllConnectedDevices();
    }

    public void send(View v){
        if(type.equals("CLIENT")){
            bluetoothManager.sendText(et1.getText().toString());
        }
        if (type.equals("SERVER")){
            bluetoothManager.sendText(et1.getText().toString(),Integer.parseInt(et2.getText().toString()));
        }
    }

    public void disconnect(View v){
        Toast.makeText(getApplicationContext(),bluetoothManager.disconnect(),Toast.LENGTH_LONG).show();
    }

    class receiveMassage implements Observer{

        @Override
         public void update(Observable observable,Object data){
            final String msg=((receivemsg)observable).getMessage();
             runOnUiThread(new Runnable(){
                 public void run(){
                    Toast.makeText(MainActivity.this,msg,Toast.LENGTH_LONG).show();
                 }
             });
        }
    }

    class DeviceList implements Observer{
    @Override
        public void update(Observable observable,Object data){
            if(((com.mdg.androble.DeviceList)observable).getContent().equals("bluetooth enabled")){
                bluetoothManager.scanClients();
            }
            else
                adapter.add(((com.mdg.androble.DeviceList)observable).getContent());
        }

    }
}


报错的内容是
1、类MainActivity
没有变量bm
——改为bluetoothManager出现新错误:unhandled exception:java.io.IOException

2、类MainActivity.receiveMassage
没有类receivemsg

3&5、getContent()在DeviceList中不是公共的

4、scanClients()在BluetoothManager中不是公共的

  • 写回答

1条回答

  • bambi2017 2017-04-04 05:53
    关注

    你下载其他源码试试。

    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog