PC SOFT

FORUMS PROFESSIONNELS
WINDEVWEBDEV et WINDEV Mobile

Accueil → WINDEV Mobile 2024 → Unlock Screen par programmation sur android
Unlock Screen par programmation sur android
Débuté par Lucas, 07 juin 2013 11:23 - 3 réponses
Membre enregistré
3 messages
Posté le 07 juin 2013 - 11:23
Bonjour,

Je suis a la recherche d'une solution pour déverrouiller/réveiller l'écran des mobiles Android par programmation et d'afficher sur le lock screen une popup contenant une image.

Existe t-il une solution ? Un code java permettant de faire ca ?

Cela fais 3 semaines que je recherche mais je n'ai rien trouvé de fonctionnel...

Je fais donc appelle à la communauté.

D'avance Merci :)
Membre enregistré
92 messages
Popularité : +2 (2 votes)
Posté le 07 juin 2013 - 13:16
Bonjour;

Tu peux utiliser Wake Lock pour réveiller un android.


Voir http://stackoverflow.com/questions/2039555/how-to-get-an-android-wakelock-to-work
Membre enregistré
3 messages
Posté le 07 juin 2013 - 13:42
Merci pour ton aide.

J'ai concocté un code Java qui en théorie devrai répondre à mes attentes mais ce n'est pas le cas. J'ai droit à 6 erreurs au moment de la compilation.

Si quelqu'un veut/peut m'aider voici le code en question :
import android.app.*;
import android.view.*;
import android.content.*;
import android.os.*;

PUBLIC static void JavaVerrouillageEcran() {
KeyguardManager km = (KeyguardManager)getSystemService(KEYGUARD_SERVICE);
final KeyguardManager.KeyguardLock kl = km.newKeyguardLock("IN");
kl.disableKeyguard();

PowerManager pm = (PowerManager) getSystemService(POWER_SERVICE);
PowerManager.WakeLock wl=pm.newWakeLock(PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.FULL_WAKE_LOCK, "My_App");
wl.acquire();

Builder adb = new AlertDialog.Builder(this);
adb.setMessage("Testing");
adb.setCancelable(False);
adb.setNeutralButton("Close",new DialogInterface.onclickListener(){
@Override
PUBLIC void onclick(DialogInterface Dialog, int which) {
kl.reenableKeyguard();
}
});
AlertDialog ad = adb.create();
ad.show();

wl.release();
}


ET voici les 6 erreurs qu'il me retourne :

Ligne de commande : "C:\Program Files\Java\jdk1.7.0_21\bin\javac.exe" -encoding UTF-16LE -nowarn -source 1.5 -target 1.5 -d bin\classes -bootclasspath "C:\Users\Lucas\AppData\Local\Android\android-sdk\platforms\android-17\android.jar" gen\com\appli\*.java src\com\appli\wdgen\*.java -classpath "libs"

Erreur retournée :
src\com\appli\wdgen\GWDCPCOL_ProceduresJava.java:32: error: cannot find symbol
KeyguardManager km = (KeyguardManager)getSystemService(KEYGUARD_SERVICE);
^
symbol: variable KEYGUARD_SERVICE
location: class GWDCPCOL_ProceduresJava
src\com\appli\wdgen\GWDCPCOL_ProceduresJava.java:36: error: cannot find symbol
PowerManager pm = (PowerManager) getSystemService(POWER_SERVICE);
^
symbol: variable POWER_SERVICE
location: class GWDCPCOL_ProceduresJava
src\com\appliwdgen\GWDCPCOL_ProceduresJava.java:40: error: cannot find symbol
Builder adb = new AlertDialog.Builder(this);
^
symbol: class Builder
location: class GWDCPCOL_ProceduresJava
src\com\appli\wdgen\GWDCPCOL_ProceduresJava.java:40: error: non-static variable this cannot be referenced from a static context
Builder adb = new AlertDialog.Builder(this);
^
src\com\appli\wdgen\GWDCPCOL_ProceduresJava.java:40: error: no suitable constructor found for Builder(GWDCPCOL_ProceduresJava)
Builder adb = new AlertDialog.Builder(this);
^
constructor Builder.Builder(Context,int) is not applicable
(actual and formal argument lists differ in length)
constructor Builder.Builder(Context) is not applicable
(actual argument GWDCPCOL_ProceduresJava cannot be converted to Context by method invocation conversion)
Note: src\com\appli\wdgen\GWDCPCOL_ProceduresJava.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
5 errors


Merci
Membre enregistré
92 messages
Popularité : +2 (2 votes)
Posté le 07 juin 2013 - 15:26
Pour moi il manque des imports comme KeyguardManager android.app.KeyguardManager

et (KeyguardManager)getSystemService(KEYGUARD_SERVICE);
S'ecrit (KeyguardManager)getContexteApplication().(KEYGUARD_SERVICE);