Commit ba942042 authored by wanglei's avatar wanglei

...

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