키오스크 서비스를 안드로이드13 버전에서 개발해야 하는 상황입니다.
이전 버전에서는 정상작동을 확인했으나, 안드로이드13 버전으로 버전이 올라가면서 제대로 동작하지 않는 듯 합니다.
참고로 잘 동작했던 이전버전은 28이며, 현재 타겟버전은 33입니다!
이거 하나 때문에 며칠 째 고생중이네요..
원래 안드로이드 개발자가 아닌데 어쩌다보니 키오스크 관련 업무를 맡게 돼서 관련 지식이 얕은 편입니다..
혹시 기존 코드를 올려드릴테니 관련 해결법에 대해 실마리라도 제공해 주실 분 계신가요 ㅠㅠ
설정에서 확인해보니 BatterySaver관련 문제도 아닌 것 같습니다..
xml 일부 입니다.
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
<receiver
android:name=".utils.BootReceiver"
android:enabled="true"
android:exported="true"
android:permission="android.permission.RECEIVE_BOOT_COMPLETED">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</receiver>
BootReceiver 코드입니다.
class BootReceiver : BroadcastReceiver() {
companion object {
private const val TAG = "BootReceiver"
}
override fun onReceive(context: Context, intent: Intent) {
Log.d(TAG, "onReceive() called with: context = $context, intent = $intent")
if (intent.action == "android.intent.action.BOOT_COMPLETED") {
val i = Intent(context, MainActivity::class.java)
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
val pendingIntent = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
PendingIntent.getActivity(
context,
0,
i,
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE
)
} else {
PendingIntent.getActivity(context, 0, i, PendingIntent.FLAG_UPDATE_CURRENT)
}
try {
pendingIntent.send()
} catch (e: PendingIntent.CanceledException) {
e.printStackTrace()
}
} else {
context.startActivity(i)
}
}
}
}