Android Open Source - Android-BleEventAdapter Main Activity






From Project

Back to project page Android-BleEventAdapter.

License

The source code is released under:

Apache License

If you think the Android project Android-BleEventAdapter 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.vashisthg.ble;
/*from w  w w . java2 s .  c om*/
import android.app.Activity;
import android.bluetooth.BluetoothDevice;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;

import com.squareup.otto.Subscribe;
import com.thedamfr.android.BleEventAdapter.BleEventAdapter;
import com.thedamfr.android.BleEventAdapter.BleEventBus;
import com.thedamfr.android.BleEventAdapter.events.DiscoveredDevicesEvent;

/**
 * Created by vashisthg on 14/05/14.
 */
public class MainActivity extends Activity {

    private static final String LOGTAG = "MAIN";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    @Override
    protected void onResume() {
        super.onResume();
        BleEventBus.getInstance().register(this);
        BleEventAdapter.getInstance().startScanning(this);
    }

    @Subscribe
    public void onDiscoveredDevice(DiscoveredDevicesEvent event){
        BluetoothDevice device = event.getDevice();

        if(device != null) {
            Log.d(LOGTAG, "discovered device" + device.getName());
        }
    }

    @Override
    protected void onPause() {

        BleEventAdapter.getInstance().stopScanning(this);
        BleEventBus.getInstance().unregister(this);
        super.onPause();
    }
}




Java Source Code List

com.thedamfr.android.BleEventAdapter.BleEventAdapter.java
com.thedamfr.android.BleEventAdapter.BleEventBus.java
com.thedamfr.android.BleEventAdapter.EventLogger.java
com.thedamfr.android.BleEventAdapter.events.CharacteristicChangedEvent.java
com.thedamfr.android.BleEventAdapter.events.CharacteristicReadEvent.java
com.thedamfr.android.BleEventAdapter.events.CharacteristicWriteEvent.java
com.thedamfr.android.BleEventAdapter.events.DescriptorReadEvent.java
com.thedamfr.android.BleEventAdapter.events.DescriptorWriteEvent.java
com.thedamfr.android.BleEventAdapter.events.DiscoveredDevicesEvent.java
com.thedamfr.android.BleEventAdapter.events.DiscoveryServiceEvent.java
com.thedamfr.android.BleEventAdapter.events.GattConnectionStateChangedEvent.java
com.thedamfr.android.BleEventAdapter.events.ReadRemoteRssiEvent.java
com.thedamfr.android.BleEventAdapter.events.ReliableWriteCompleted.java
com.thedamfr.android.BleEventAdapter.events.ScanningEvent.java
com.thedamfr.android.BleEventAdapter.events.ServiceDiscoveredEvent.java
com.thedamfr.android.BleEventAdapter.service.discovery.device.DeviceDiscoveryService.java
com.thedamfr.android.BleEventAdapter.service.gatt.GattConnectionState.java
com.thedamfr.android.BleEventAdapter.service.gatt.GattService.java
com.vashisthg.ble.MainActivity.java