I am building a piece of code that imitates an activity when the phone receives an active Bluetooth connection. This is to run as a service so it can be picked up on in the moment.
Here is the code I am working with. Right now its not launching the intent but its not failing either. How do I get this to run properly?
import android.app.Service;
import android.bluetooth.BluetoothDevice;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.IBinder;
public class detectService extends Service{
@Override
public IBinder onBind(Intent intent) {
// TODO Auto-generated method stub
return null;
}
private BroadcastReceiver ConnectListener = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent)
{
String action = intent.getAction();
if (BluetoothDevice.ACTION_ACL_CONNECTED.equals(action))
{
intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
//Start Second Activity
Intent secondIntent = new Intent(detectService.this, otherClass.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(secondIntent);
}
}
};
}