Új hozzászólás Aktív témák
-
thiclyoon
aktív tag
válasz
Ablakos
#4972
üzenetére
A kód jó
valószínűleg a gond az android api miatt van: "If your app targets Android 8.0 or higher, you cannot use the manifest to declare a receiver for most implicit broadcasts (broadcasts that don't target your app specifically)" [link]Ha a kódot így szeretnéd ellenőrizni, akkor a module szintű build.gradle targetSdkVersion-jét vedd kisebbre (pl. 22), és egy ugyanilyen api-val rendelkező emulátoron teszeld. Viszont éles projekt, stb. esetén tedd is vissza a target-et, és próbáld meg kódból (manifest-ből töröld a kódodat):
val intentFilter = IntentFilter("android.intent.action.AIRPLANE_MODE")
val receiver: BroadcastReceiver = object : BroadcastReceiver() {
override fun onReceive(context: Context?, intent: Intent?) {
Toast.makeText(this@MainActivity, "changed", Toast.LENGTH_SHORT).show()
}
}
this.registerReceiver(receiver, intentFilter)
Új hozzászólás Aktív témák
- LÉZEREZÉS! külföldi billentyűzet magyarra kb. 20-30p alatt!
- 193 - Lenovo Legion 5 (15IRX10) - Intel Core i7-14700HX, RTX 5070 (ELKELT)
- GYÖNYÖRŰ iPhone XR 128GB White-1 ÉV GARANCIA - Kártyafüggetlen, MS4294
- Gamer PC - Számítógép // i7 // GTX 1060 // Számla // Garancia //
- Geforce GTX 1050, 1050 Ti, 1060, 1650, 1660 / GT 1030 - Low profile is (LP)
Állásajánlatok
Cég: Laptopműhely Bt.
Város: Budapest
valószínűleg a gond az android api miatt van: "If your app targets Android 8.0 or higher, you cannot use the manifest to declare a receiver for most implicit broadcasts (broadcasts that don't target your app specifically)" 