我的应用程序使用由BOOT_COMPLETE 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);
}
}
Run Code Online (Sandbox Code Playgroud)
错误:
java.lang.RuntimeException: Unable to start receiver com.example.projet: android.content.ReceiverCallNotAllowedException: BroadcastReceiver components are not allowed to bind to services
Run Code Online (Sandbox Code Playgroud) 我将如何捕获按下“ Ctrl +空格+空格”的用户!
我使用以下代码成功测试了“ Ctrl +空格”:
RegisterHotKey(0, 1, MOD_CONTROL, VK_SPACE);
Run Code Online (Sandbox Code Playgroud)