Avatar ·

Android 8.1 में अपडेट के बाद startForeground त्रुटि: ForegroundServiceDidNotStartInTimeException के साथ ऐप क्रैश

सभी को नमस्ते! मैं Kotlin में एक शुरुआती Android डेवलपर हूँ। अपने डिवाइस को Android 8.1 (Oreo) पर अपडेट करने के बाद, बैकग्राउंड सर्विस शुरू करते समय मेरा ऐप त्रुटि के साथ क्रैश होने लगा। पहले Android 7.0 पर सब कुछ ठीक काम करता था। यहाँ मेरा सर्विस कोड है: ```kotlin class MyForegroundService : Service() { override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int { val notification = Notification.Builder(this, "my_channel") .setContentTitle("सर्विस चल रही है") .setContentText("डाउनलोड हो रहा है...") .setSmallIcon(R.drawable.ic_notification) .build() startForeground(1, notification) // ... लंबा बैकग्राउंड कार्य return START_STICKY } override fun onBind(intent: Intent?): IBinder? = null } ``` और यहाँ मैं Activity से सर्विस कैसे शुरू करता हूँ: ```kotlin startService(Intent(this, MyForegroundService::class.java)) ``` लॉग में त्रुटि: `android.app.ForegroundServiceDidN