如何在一台设备离线的情况下控制多台设备(仅限WIFI)

时间:2018-03-06 05:23:42

标签: java android remote-access

我不会让控制器通过WIFI控制多个设备(没有互联网连接)。

我检查Airdroid的工作方式是这样的,我创建的应用程序就像那些控制设备都具有相同的应用程序。如何在没有FCM或中介(服务器)的情况下控制这些

我尝试过类似AirDroid的工作

我使用此代码添加设备相同的网络连接设备

 final AlertDialog alertDialog = new AlertDialog.Builder(MainActivity.this).create();
    alertDialog.setView(new EditText(this));
    alertDialog.show();
    Window window = alertDialog.getWindow();
    window.setContentView(R.layout.dialog_new);
    final EditText editName = (EditText)window.findViewById(R.id.editName);
    final EditText editAddress = (EditText)window.findViewById(R.id.editAddress);
    Button btnSave = (Button)window.findViewById(R.id.btnSave);
    Button btnCancel = (Button)window.findViewById(R.id.btnCancel);
    btnSave.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            int primaryKey = database.getPrimaryKeyNum()+1;
            Device device = new Device(primaryKey,editName.getText().toString(),R.drawable.ad_ic_device_default,editAddress.getText().toString(),2027);
            database.createTable(device);
            database.insert(device);
            deviceList.add(device);
            deviceAdapter.notifyDataSetChanged();
            listDevices.setSelection(deviceList.size());
            alertDialog.dismiss();
            Toast.makeText(MainActivity.this,"Add succeed.",Toast.LENGTH_SHORT).show();
        }
    });
    btnCancel.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            alertDialog.dismiss();
        }
    });

you can check full example here

Also using Wifi P2p Connection

0 个答案:

没有答案