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

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个回答

你下载其他源码试试。

sinat_37690877
bambi2017 回复snowpigppp: 我也是小白,不懂啊。
大约 3 年之前 回复
qq_32428857
snowpigppp 主要是想用他这个library QAQ,我是个安卓小白,还希望大神再指点一下,下载其他的源码是指其他的MainActivity吗?应该去哪里下?
大约 3 年之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐