Diese Seite mit anderen teilen ...

Informationen zum Thema:
Forum:
WinDev Forum
Beiträge im Thema:
3
Erster Beitrag:
vor 7 Monaten, 2 Wochen
Letzter Beitrag:
vor 7 Monaten, 2 Wochen
Beteiligte Autoren:
Ben Adams, Danny Lauwers

[WM21] Automatic procedure running whilst device is locked?

Startbeitrag von Ben Adams am 05.01.2017 13:48

Hi Guys,

I am running a procedure every 10 seconds using the in-built automatic procedure control.
In my procedure, i create a notification if a certain piece of information is obtained through a webservice. However, my notification only pops up if the device screen is on. The device can be locked with the screen on and the procedure runs to give me a notification, but when the screen is off and locked, it appears as though the procedure doesn't even run.

Is there anyway i can wake the device upon creating a notification when the device is locked?

Any help is very much appreciated :)

Antworten:

Hi,

In Java you can wake the device and display the screen toplevel. I use this in my application.

You need to use a persistent thread else Android OS will sleep or kill your application.


public static boolean JWakeDevice(boolean bWakeup)
{
// Wake or rest the device
try {
if (bWakeup) {
// Awake the Device
Activity tmpActivity = getCurrentActivity();
tmpActivity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED | WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
else {
// Reset stuff
//callWLProcedure("ShowMessage","Rest");
Activity tmpActivity = getCurrentActivity();
tmpActivity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED | WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
} catch(Exception e) {
e.printStackTrace();
return false;

}
return true;
}


If you receive data via your webservice and need to show a notification with active screen, you just call JWakeDevice, and your current active screen will show even if your device is locked.

When you need to do some actions, you need to login (pin.swipe) or whatever lock is on your device.

hopes this works for you !

Danny

von Danny Lauwers - am 05.01.2017 14:34
Perfect! thank you very much Danny!

von Ben Adams - am 05.01.2017 14:43
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.