lundi 25 juillet 2016

Binding service by BroadcastReceiver

My Application uses a service that is started by a BOOT_COMPLETE BroadcastReceiver, in run i'm getting an error

my code:

public class projet extends BroadcastReceiver { 
 public void onReceive(Context context, Intent intent) { 

  intent = new Intent(context, ScreenshotService.class);
  intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  context.bindService(intent, aslServiceConn, Context.BIND_AUTO_CREATE);
}
}

error:

java.lang.RuntimeException: Unable to start receiver com.example.projet: android.content.ReceiverCallNotAllowedException: BroadcastReceiver components are not allowed to bind to services

Aucun commentaire:

Enregistrer un commentaire