android - BroadcastReceiver not found in Manifest -
android - BroadcastReceiver not found in Manifest -
i want start service on bluetooth turn on/off. facing issues. here few things. here manifest:
<application android:label="justanylabel"> <receiver android:name=".mybroadcastreceiver"> <intent-filter> <action android:name="android.bluetooth.adapter.action.state_changed" /> </intent-filter> </receiver> </application> here broadcastreceiver:
public class mybroadcastreceiver : broadcastreceiver { private intent theserviceintent; public mybroadcastreceiver () : base() {} public override void onreceive (context context, intent intent) { string action = intent.action; if (action.equals (bluetoothadapter.actionstatechanged)) { int state = intent.getintextra (bluetoothadapter.extrastate, bluetoothadapter.error); bool bluetoothenabled = bluetoothadapter.defaultadapter.isenabled; switch (bluetoothenabled) { case false: if(theserviceintent != null) { context.stopservice (theserviceintent); theserviceintent = null; } break; case true: if(theserviceintent == null) { theserviceintent = new intent (context, typeof(theservice)); context.startservice (theserviceintent); } break; } } } } and here error:
so basically, class not beingness found , have no thought why. help appreciated.
thanks.
i have same issue , work fine me. registration:
<receiver android:name="packagename.bluetoothbr"> <intent-filter> <action android:name="android.bluetooth.adapter.action.state_changed"/> </intent-filter> </receiver> and receiver:
public class bluetoothbr extends broadcastreceiver {
@override public void onreceive(context context, intent intent) { final string action = intent.getaction(); if (action.equals(bluetoothadapter.action_state_changed)) { intent intentb; final int state = intent.getintextra(bluetoothadapter.extra_state, bluetoothadapter.error); switch (state) { case bluetoothadapter.state_off: // stop service... break; case bluetoothadapter.state_turning_off: // stop service.... break; case bluetoothadapter.state_on: // init service ... break; } } } }
hope helps you!! :)
android bluetooth monodroid android-manifest classnotfoundexception
Comments
Post a Comment