Skip to content

Commit

Permalink
change context to applicationcontext
Browse files Browse the repository at this point in the history
  • Loading branch information
Tokito-Kun authored and Tokito-Kun committed Jun 29, 2023
1 parent c8f4416 commit dda6cdf
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import mattecarra.accapp.viewmodel.ProfilesViewModel
import mattecarra.accapp.viewmodel.SharedViewModel
import xml.*
import com.topjohnwu.superuser.ShellUtils
import com.topjohnwu.superuser.ips.RootService.getApplicationContext
import mattecarra.accapp.Preferences
import mattecarra.accapp.databinding.EditChargingLimitOnceDialogBinding
import mattecarra.accapp.utils.LogExt
Expand Down Expand Up @@ -130,13 +131,13 @@ class BatteryDialogActivity : ScopedAppActivity()
{
val intent = Intent()
intent.action = "android.settings.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS"
intent.data = Uri.parse("package:" + context.packageName)
intent.data = Uri.parse("package:" + applicationContext.packageName)
startActivity(intent)
finish()
}
catch (e: Exception)
{
Toast.makeText(context, getString(R.string.battery_optimization_fail), Toast.LENGTH_SHORT).show()
Toast.makeText(applicationContext, getString(R.string.battery_optimization_fail), Toast.LENGTH_SHORT).show()
}
}

Expand All @@ -147,11 +148,11 @@ class BatteryDialogActivity : ScopedAppActivity()
LogExt().d(javaClass.simpleName, "onClick_OpenAccA")
finish()

ContextCompat.startActivity(context.applicationContext,
Intent(context.applicationContext, MainActivity::class.java)
ContextCompat.startActivity(applicationContext.applicationContext,
Intent(applicationContext.applicationContext, MainActivity::class.java)
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK).putExtras(intent), null)

//val intent = context.packageManager.getLaunchIntentForPackage(packageName)
//val intent = applicationContext.packageManager.getLaunchIntentForPackage(packageName)
//startActivity(intent?.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK))
}

Expand Down

0 comments on commit dda6cdf

Please sign in to comment.