Моё приложение использует сервис, который запускается с помощью BOOT_COMPLETE BroadcastReceiver, в перспективе я получаю ошибкуBinding службы по BroadcastReceiver
мой код:
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);
}
}
ошибка:
java.lang.RuntimeException: Unable to start receiver com.example.projet: android.content.ReceiverCallNotAllowedException: BroadcastReceiver components are not allowed to bind to services
http://skillgun.com/question/538/android/receivers/what-will-happen-if-broad-cast-receiver-binds-to-binder-service-is-there-any-problem –
Просто просто. Я создал пустую операцию (не пользовательский интерфейс, просто onCreate() для службы Bind) и finish(). В трансляции> Начать операцию с помощью Bundle (при необходимости). Проблема решена. – hungtdo