Android Open Source - Glass-IntentTunnel Device Select Activity






From Project

Back to project page Glass-IntentTunnel.

License

The source code is released under:

MIT License

If you think the Android project Glass-IntentTunnel listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.masterbaron.intenttunnel.android;
/*w  w w .  j a  va2s .  co m*/
import android.app.ListActivity;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.Toast;

import com.masterbaron.intenttunnel.router.RouterService;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Van Etten on 1/4/14.
 */
public class DeviceSelectActivity extends ListActivity {
    private static String TAG = DeviceSelectActivity.class.getName();
    List<BluetoothDevice> devices;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        List<String> deviceNames = new ArrayList<String>();
        BluetoothAdapter defaultAdapter = BluetoothAdapter.getDefaultAdapter();
        if (defaultAdapter != null) {
            devices = new ArrayList(defaultAdapter.getBondedDevices());
            for ( BluetoothDevice device : devices ) {
                deviceNames.add(device.getName());
            }
        }

        if (deviceNames.size() == 0) {
            Toast.makeText(this, "Unable to locate and Bluetooth Devices", Toast.LENGTH_SHORT).show();
            this.finish();
        } else {
            ListAdapter adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, android.R.id.text1, deviceNames);
            this.setListAdapter(adapter);
        }
    }

    @Override
    protected void onListItemClick(ListView l, View v, int position, long id) {
        super.onListItemClick(l, v, position, id);
        RouterService.setDeviceAddress(this, devices.get(position).getAddress());
        this.finish();
    }
}




Java Source Code List

com.masterbaron.intenttunnel.IntentTunnelActivity.java
com.masterbaron.intenttunnel.android.AndroidConfigureActivity.java
com.masterbaron.intenttunnel.android.DeviceSelectActivity.java
com.masterbaron.intenttunnel.glass.DeviceSelectActivity.java
com.masterbaron.intenttunnel.glass.GlassConfigureActivity.java
com.masterbaron.intenttunnel.router.BluetoothService.java
com.masterbaron.intenttunnel.router.ClientService.java
com.masterbaron.intenttunnel.router.Packet.java
com.masterbaron.intenttunnel.router.RouterService.java
com.masterbaron.intenttunnel.router.ServerService.java
com.masterbaron.intenttunnel.router.ServiceReceiver.java
com.masterbaron.musicpusher.MusicActivity.java
ktlab.lib.connection.CommandReceiveThread.java
ktlab.lib.connection.CommandSendThread.java
ktlab.lib.connection.ConnectionCallback.java
ktlab.lib.connection.ConnectionCommand.java
ktlab.lib.connection.ConnectionThread.java
ktlab.lib.connection.Connection.java
ktlab.lib.connection.bluetooth.BluetoothConnectionThread.java
ktlab.lib.connection.bluetooth.BluetoothConnection.java
ktlab.lib.connection.bluetooth.ClientBluetoothConnectionThread.java
ktlab.lib.connection.bluetooth.ClientBluetoothConnection.java
ktlab.lib.connection.bluetooth.ServerBluetoothConnectionThread.java
ktlab.lib.connection.bluetooth.ServerBluetoothConnection.java