Back to project page android-a2dpnostandby.
The source code is released under:
GNU General Public License
If you think the Android project android-a2dpnostandby listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package co.telnet.a2dpnostandby; /* w ww. j a v a 2 s .c o m*/ import android.bluetooth.BluetoothA2dp; import android.bluetooth.BluetoothProfile; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.util.Log; public class ConnectionStateReceiver extends BroadcastReceiver { private static final String TAG = "A2DP No Standby"; @Override public void onReceive(Context context, Intent intent) { String action = intent.getAction(); int newState = intent.getIntExtra(BluetoothProfile.EXTRA_STATE, 0); if (action.equals(BluetoothA2dp.ACTION_CONNECTION_STATE_CHANGED)) { if (newState == BluetoothProfile.STATE_CONNECTED) { Log.v(TAG, "Bluetooth connected"); if (context.startService(new Intent(context, A2dpPlayerService.class)) == null) Log.e(TAG, "Couldn't start service"); } else { Log.v(TAG, "Bluetooth not connected"); context.stopService(new Intent(context, A2dpPlayerService.class)); } } } }