How to check “Myapp” running or not , and if not start it

R
rathasatekun Bronze Contributor
Gosoft (Thailand) Co.,Ltd.

In Android device 

I found that Android will kill application when screen off for save battery ,  but I don’t want

i want to start “my app” always

so how to start app always even screen off

Have some script to do that.

next

Have javascript  to check “myapp”  start or not it stop , so start it ?

a year ago
Android Scripting
ANSWERS

There are several possibilitys i think but the best which comes into my mind would be following:

  1. disable doze mode via feature control profile (or maybe even via oem config, see 2.)
  2. use oem config app for your devices to turn off battery optimization (for all or specified apps) and turn off maybe screen off as well (you need to check if there's something available form manufacturer side!)
  3. Provide lockdown profile adding "your app" to it and enable "
  4. If not already done, you need then also to provide an authentication Profile to the device (needed for the lockdown profile and in genereal recommended by me)

This will then end up in a Kiosk screen starting on every device boot by default "your app" (and if single mode is turned on) keep it displayed. Also if you were able to disable battery saver and/or screen off, the screen won't turn off and always display that app.

Then you also don't need to check if the app is running or not (if single app mode is turned on).

ZC
Zafer Cigdem Platinum Contributor
a year ago

Hi,

In addition to what Rafael, for your question about JS, you can check whether your app is running on the foreground or not and execute start app JS if required by using below:

start bundleIDYourApp --> to start the app via JS

example: start com.android.chrome

    var surf = 'net.soti.surf';

    var foregroundActivities = mobicontrol.app.foregroundActivities;

    if (foregroundActivities != null) {

        foregroundActivities.forEach(function (activity) {

            if (activity.packageName == surf) { mobicontrol.message.createInfoDialog("SURF app is open on the foreground").show(); }

        });

    }

  Resurce: Namespace: app | Android Agent JavaScript (soti.net)

You can edit above if/else and trigger start app.

Zafer

A
AKMOD@SOTI
a year ago

Hi rathasatekun,

Thanks for posting on SOTI Pulse, Thanks Rafael, and Zafer Cigdem for responding to the post, your expertise and willingness to help are greatly appreciated!

Have you had an opportunity to test the suggested solutions by Zafer Cigdem and Rafael, and has it successfully addressed your query?

If not, or If you have any additional questions or concerns, please don't hesitate to reach out. We're dedicated to providing assistance and support.