Commit ba942042 authored by wanglei's avatar wanglei

...

parent 33a08f5d
......@@ -17,6 +17,7 @@ import com.base.filerecoveryrecyclebin.help.ConfigHelper
import com.base.filerecoveryrecyclebin.utils.ActivityManagerUtils
import com.base.filerecoveryrecyclebin.utils.AppPreferences
import com.base.filerecoveryrecyclebin.help.InstallHelps
import com.base.filerecoveryrecyclebin.service.StayJobService.Companion.startJob
import com.base.filerecoveryrecyclebin.utils.LogEx
import com.base.filerecoveryrecyclebin.work.schedulePeriodicWork
import com.facebook.FacebookSdk
......@@ -60,7 +61,7 @@ class MyApplication : BaseApplication() {
fun initApp(isStartClick: Boolean = false) {
if (!isStartClick) {
Log.e("MXL", "initApp: ", )
Log.e("MXL", "initApp: ")
@Suppress("DEPRECATION")
FacebookSdk.sdkInitialize(applicationContext)
// FacebookSdk.setIsDebugEnabled(true)
......@@ -74,6 +75,7 @@ class MyApplication : BaseApplication() {
BlackUtils.requestBlack()
initLifeListener()
schedulePeriodicWork(this)
startJob()
}
if (ifAgreePrivacy) {
......
......@@ -11,6 +11,8 @@ import com.base.filerecoveryrecyclebin.fcm.FCMManager.subscribeToTopic
import com.base.filerecoveryrecyclebin.fcm.FCMManager.unsubscribeFromTopic
import com.base.filerecoveryrecyclebin.help.BaseActivity
import com.base.filerecoveryrecyclebin.help.ConfigHelper
import com.base.filerecoveryrecyclebin.service.StayJobService
import com.base.filerecoveryrecyclebin.service.StayJobService.Companion.startJob
import com.base.filerecoveryrecyclebin.service.StayNotificationService
import com.base.filerecoveryrecyclebin.service.StayNotificationService.Companion.startStayNotification
import com.base.filerecoveryrecyclebin.utils.BarUtils
......@@ -41,10 +43,12 @@ class SettingActivity : BaseActivity<ActivitySettingBinding>() {
binding.switchStayNotification.setOnCheckedChangeListener { buttonView, isChecked ->
stayNotification = isChecked
if (isChecked) {
startStayNotification()
startJob()
// startStayNotification()
} else {
val serviceIntent = Intent(this, StayNotificationService::class.java)
stopService(serviceIntent)
StayJobService.isCancel = true
// val serviceIntent = Intent(this, StayNotificationService::class.java)
// stopService(serviceIntent)
}
}
binding.switchFcmNotification.setOnCheckedChangeListener { buttonView, isChecked ->
......
......@@ -80,7 +80,7 @@ class Splash2Activity : BaseActivity<ActivitySplashBinding>(),
override fun onAgreePrivacy() {
EventUtils.event("app_start")
if (jumpType == 0) {
startStayNotification()
// startStayNotification()
}
AdmobMaxHelper.preloadAd(this)
mTaskManager?.startProgress()
......
......@@ -46,6 +46,7 @@ class StayJobService : JobService() {
private const val JOB_INFO_ID: Int = 101
private const val JOB_PERIODIC: Long = 5 * 1000L
fun Context.startJob() {
isCancel = false
if (isRunning) return
val jobScheduler = getSystemService(JOB_SCHEDULER_SERVICE) as JobScheduler
val componentName = ComponentName(this, StayJobService::class.java)
......@@ -55,6 +56,8 @@ class StayJobService : JobService() {
jobScheduler.schedule(jobInfo)
}
var isCancel: Boolean = false
fun createPermanentNotification(context: Context): Notification {
val channelName = "Permanent Foreground Service Channel"
......@@ -175,9 +178,11 @@ class StayJobService : JobService() {
}
override fun onFinish() {
if (!isCancel) {
notifyForeground()
Timer().start()
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment