This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var socket = io.connect('/notifications'); | |
socket.on('notifications', function(notification) { | |
notification = $.parseJSON(notification); | |
var eventName = notification.event_name; | |
var payload = notification.payload; | |
dispatcher.trigger(eventName, payload); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Intent intent = new Intent(android.provider.Settings.ACTION_BLUETOOTH_SETTINGS); | |
startActivityForResult(intent, REQUEST_DEVICE_PAIR); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private BluetoothReceiver mBluetoothReceiver; | |
private BluetoothAdapter mBluetoothAdapter; | |
@Override | |
public void onCreate(Bundle savedInstanceState) { | |
... | |
// Register a BroadcastReceiver for Bluetooth Intents | |
mBluetoothReceiver = new BluetoothReceiver(); | |
IntentFilter filter = new IntentFilter(BluetoothDevice.ACTION_FOUND); | |
filter.addAction(BluetoothAdapter.ACTION_DISCOVERY_STARTED); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private class BluetoothReceiver extends BroadcastReceiver { | |
public void onReceive(Context context, Intent intent) { | |
String action = intent.getAction(); | |
if (BluetoothDevice.ACTION_FOUND.equals(action)) { | |
// Found a Bluetooth device | |
BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE); | |
onDeviceFound(device); // Do something with it | |
} else if (BluetoothAdapter.ACTION_DISCOVERY_STARTED.equals(action)) { | |
// Discovery has started, display progress spinner |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public boolean pairDevice(BluetoothDevice device) { | |
try { | |
Method createBond = BluetoothDevice.class.getMethod("createBond"); | |
return (boolean) createBond.invoke(device); | |
} catch (Exception e) { | |
e.printStackTrace(); | |
return false; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
filter.addAction(BluetoothDevice.ACTION_BOND_STATE_CHANGED); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private class BluetoothReceiver extends BroadcastReceiver { | |
public void onReceive(Context context, Intent intent) { | |
String action = intent.getAction(); | |
if (BluetoothDevice.ACTION_FOUND.equals(action)) { | |
// Found a Bluetooth device | |
BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE); | |
onDeviceFound(device); //Do something with it | |
} else if (BluetoothDevice.ACTION_BOND_STATE_CHANGED.equals(action)) { | |
// Device pairing/unpairing occurred |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<bean id="fooBean" class="com.foo.bar.FooBean" /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Component | |
public class FooBean { | |
// ... | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for (Class<?> clazz : getClasspathClasses("com.foo.bar")) { | |
if (clazz.isAnnotationPresent(Component.class)) { | |
// Found bean | |
} | |
} |