I want to create an application that will turn on and off power saver mode within itself programmatically with on a button click using android-Kotlin.
I have tried using the intent filter, but it goes to system settings, and then we turn it on or off manua开发者_JAVA百科lly.
code :-
buttonBatterySave.setOnClickListener {
beep() //sound effect
val batterySaverIntent = Intent()
batterySaverIntent.component = ComponentName(
"com.android.settings",
"com.android.settings.Settings\$BatterySaverSettingsActivity"
)
startActivityForResult(batterySaverIntent, 0)
}
I just want my application to turn on or off by itself within the application with a single button click.
Thank you
精彩评论