0

I have a mobile app (kotlin/android studio) does not have an activity openned. This is a background service. My app is connected by socket with my server. Via this server, I can ask to the mobile app to start an another app. I found the code to do that and this works well. But I have a problem. I need to turn on my screen when I start a new app. I have seen many solutions with different flags to setwith getWindow(). But getWidnow() works only on an activity class.

So can I turn on the screen in a class which does not inherit "Activity"? If this is possible, can you explain me how?

Thank you.

var intent = contextTmp.packageManager.getLaunchIntentForPackage(packageName)
if (intent == null) {
   // Bring user to the market or let them choose an app?
   intent = Intent(Intent.ACTION_VIEW)
   intent.data = Uri.parse("market://details?id=$packageName")
}
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
contextTmp.startActivity(intent)

0 Answers0