PC SOFT

GRUPOS DE DISCUSSÃO PROFISSIONAL
WINDEVWEBDEV e WINDEV Mobile

Inicio → WINDEV 25 → WD - Procedure JAVA para Windev Mobile detectar o nivel da bateria do celular / tablet
WD - Procedure JAVA para Windev Mobile detectar o nivel da bateria do celular / tablet
Iniciado por BOLLER ADRIANO, jul., 26 2016 8:04 PM - 11 respostas
Membro registado
3.651 mensagems
Popularité : +175 (223 votes)
Publicado em julho, 26 2016 - 8:04 PM
Prezados,

Segue exemplo de uma Procedure JAVA para Windev Mobile detectar o nivel da bateria do celular / tablet:

// Affiche le pourcentage de batterie restant dans un champ de saisie
import android.content.*;

PUBLIC static void LitEtatBatterie(string champDeSaisie) {
// Récupération du champ de saisie qui affichera le niveau de batterie
contentTxt = (TextView) getView(champDeSaisie);
getActiviteEnCours().registerReceiver(mBatInfoReceiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
}

// champ de saisie qui affichera le niveau de batterie
static TextView contentTxt;

static BroadcastReceiver mBatInfoReceiver = new BroadcastReceiver(){
PUBLIC void onReceive(Context arg0, Intent intent) {
int level = intent.getIntExtra("level", 0);
contentTxt.setText(string.valueOf(level));
}
};


Obrigado Pedroso!

:merci:

--
Adriano José Boller
______________________________________________
Consultor e Representante Oficial da
PcSoft no Brasil
+55 (41) 9949 1800
adrianoboller@gmail.com
skype: adrianoboller
http://wxinformatica.com.br/
Membro registado
3.651 mensagems
Popularité : +175 (223 votes)
Publicado em julho, 27 2016 - 1:18 PM
// Affiche le pourcentage de batterie restant dans un champ de saisie
import android.content.*;

PUBLIC static void LitEtatBatterie(string champDeSaisie) {
// Récupération du champ de saisie qui affichera le niveau de batterie
contentTxt = (TextView) getView(champDeSaisie);
getActiviteEnCours().registerReceiver(mBatInfoReceiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
}

// champ de saisie qui affichera le niveau de batterie
static TextView contentTxt;

static BroadcastReceiver mBatInfoReceiver = new BroadcastReceiver(){
PUBLIC void onReceive(Context arg0, Intent intent< /FONT>) {
int level = intent.getIntExtra("level", 0);
contentTxt.setText(string.valueOf(level));
}
};



And you can call it like this:

LitEtatBatterie("SAI_Batterie") // <----------------------- coloque o nome do controle text que exibirá o valor



LitEtatBatterie is the name of the procedure

SAI_Batterie is the name of the control to show the value.

Please do not hesitate to contact me for any additional information.

Best Regards

Jerome Aerts

:merci:

--
Adriano José Boller
______________________________________________
Consultor e Representante Oficial da
PcSoft no Brasil
+55 (41) 9949 1800
adrianoboller@gmail.com
skype: adrianoboller
http://wxinformatica.com.br/
Membro registado
3.651 mensagems
Popularité : +175 (223 votes)
Publicado em agosto, 10 2016 - 11:00 PM
RESULTADO:





--
Adriano José Boller
______________________________________________
Consultor e Representante Oficial da
PcSoft no Brasil
+55 (41) 9949 1800
adrianoboller@gmail.com
skype: adrianoboller
http://wxinformatica.com.br/
Membro registado
3.651 mensagems
Popularité : +175 (223 votes)
Publicado em agosto, 10 2016 - 11:02 PM
CÓDIGO ORIGINAL:





:merci:

--
Adriano José Boller
______________________________________________
Consultor e Representante Oficial da
PcSoft no Brasil
+55 (41) 9949 1800
adrianoboller@gmail.com
skype: adrianoboller
http://wxinformatica.com.br/
Membro registado
123 mensagems
Popularité : +46 (46 votes)
Publicado em agosto, 11 2016 - 8:32 PM
Outro metodo , menos convencional seria este (este metodo, não requer de uma tela ou campo text, podendo ser usada em background)






--
Atte. Willian Fernando
Mensagem modificada, agosto, 11 2016 - 8:39 PM
Membro registado
3.651 mensagems
Popularité : +175 (223 votes)
Publicado em agosto, 12 2016 - 1:29 PM
:merci: Willian!!!!

--
Adriano José Boller
______________________________________________
Consultor e Representante Oficial da
PcSoft no Brasil
+55 (41) 9949 1800
adrianoboller@gmail.com
skype: adrianoboller
http://wxinformatica.com.br/
Publicado em dezembro, 23 2016 - 11:19 AM
Hello Adriano,

Code Windev : LitEtatBatterie("SAI_Batterie")

code java:
// Affiche le pourcentage de batterie restant dans un champ de saisie
import android.content.*;

PUBLIC static void LitEtatBatterie(string champDeSaisie) {
// Récupération du champ de saisie qui affichera le niveau de batterie
contentTxt = (TextView) getView(champDeSaisie);
getActiviteEnCours().registerReceiver(mBatInfoReceiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
}

// champ de saisie qui affichera le niveau de batterie
static TextView contentTxt;

static BroadcastReceiver mBatInfoReceiver = new BroadcastReceiver(){
PUBLIC void onReceive(Context arg0, Intent intent) {
int level = intent.getIntExtra("level", 0);
contentTxt.setText(string.valueOf(level));
}
};

Errors in APK generation:

Echec de la création de l'application Android <E:\WMobile20\EXPRESS_Mon_Projet\Exe\EXPRESS_Application Android\EXPRESS_xxxx.apk>.


Ligne de commande : "C:\Program Files\Java\jdk1.8.0_72\bin\java.exe" "-Dorg.gradle.appname=E:\WMobile20\EXPRESS_Mon_Projet\Android\Generation" -classpath "E:\WMobile21express\Personnel\Android\Gradle\lib\gradle-launcher-2.8.jar" org.gradle.launcher.GradleMain assembleDebug -b build.gradle


Erreur retournée :
E:\WMobile20\EXPRESS_Mon_Projet\Android\Generation\src\com\yyy\xxxx\wdgen\GWDCPProceduresJAVA.java:79: error: <identifier> expected
PUBLIC static void LitEtatBatterie(string champDeSaisie) {
^
E:\WMobile20\EXPRESS_Mon_Projet\Android\Generation\src\com\yyy\xxxx\wdgen\GWDCPProceduresJAVA.java:89: error: <identifier> expected
PUBLIC void onReceive(Context arg0, Intent intent) {
^
E:\WMobile20\EXPRESS_Mon_Projet\Android\Generation\src\com\yyy\xxxx\wdgen\GWDCPProceduresJAVA.java:89: error: invalid method declaration; return type required
PUBLIC void onReceive(Context arg0, Intent intent) {
^
3 errors
FAILED

An idea?
Merry Christmas

Carlos
Membro registado
3.651 mensagems
Popularité : +175 (223 votes)
Publicado em dezembro, 23 2016 - 11:37 AM
Good morning.

Change the minuscule magnitude that works, the forum changes to Upper the word PUBLIC and it is not.

Only that

Call me on skype: adrianoboller and I'll send the source.

===

Bom dia

Altere o maiusculo minusculo que da certo, o forum muda para Upper a palavra PUBLIC e nao é.

Só isso

Me chame no skype: adrianoboller que te mando o fonte.

OK

--
Adriano José Boller
______________________________________________
Consultor e Representante Oficial da
PcSoft no Brasil
+55 (41) 9949 1800
adrianoboller@gmail.com
skype: adrianoboller
http://wxinformatica.com.br/
Mensagem modificada, dezembro, 23 2016 - 11:37 AM
Publicado em março, 29 2017 - 5:41 PM
Tentei fazer o código funcionar mas quando tentei gerar ocorreram esses 2 erros:

error: cannot find symbol static TextView contentTxt;

error: cannot find symbol contentTxt = (TextView) getView(champDeSaisie);

symbol: class TextView
location: class GWDCPGlobalProcedures
2 errors
FAILED


Busquei resolver mas não consegui...
Publicado em setembro, 08 2017 - 3:41 PM
Hello sir,

I am contacting you about the post you left on the PC Soft forum in July 2016.

I can not run this code, Windev always returns the following error: "Invalid parameter type".

Yet the code is the same as the one you presented:

// Affiche le pourcentage de batterie restant dans un champ de saisie
import android.content.*;

PUBLIC static void LitEtatBatterie(string champDeSaisie) {
// Récupération du champ de saisie qui affichera le niveau de batterie
contentTxt = (TextView) getView(champDeSaisie);
getActiviteEnCours().registerReceiver(mBatInfoReceiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
}

// champ de saisie qui affichera le niveau de batterie
static TextView contentTxt;

static BroadcastReceiver mBatInfoReceiver = new BroadcastReceiver(){
PUBLIC void onReceive(Context arg0, Intent intent< /FONT>) {
int level = intent.getIntExtra("level", 0);
contentTxt.setText(string.valueOf(level));
}
};

I work with Windev Mobile 22, latest version.

Could you help me because I do not see any solution?

Thank you in advance.

Best Regards,

Gaël L.
Membro registado
3.651 mensagems
Popularité : +175 (223 votes)
Publicado em setembro, 08 2017 - 5:07 PM
MAIUSCULO NO LUGAR ERRADO
VEJA A IMAGEM ABAIXO:





--
Adriano José Boller
______________________________________________
Consultor e Representante Oficial da
PcSoft no Brasil
+55 (41) 99949 1800
adrianoboller@gmail.com
skype: adrianoboller
http://wxinformatica.com.br/
Membro registado
123 mensagems
Popularité : +46 (46 votes)
Publicado em setembro, 08 2017 - 9:28 PM
JAVA is case Sensitive

PUBLIC is different from public


Gaël L. a écrit :
Hello sir,

I am contacting you about the post you left on the PC Soft forum in July 2016.

I can not run this code, Windev always returns the following error: "Invalid parameter type".

Yet the code is the same as the one you presented:

// Affiche le pourcentage de batterie restant dans un champ de saisie
import android.content.*;

PUBLIC static void LitEtatBatterie(string champDeSaisie) {
// Récupération du champ de saisie qui affichera le niveau de batterie
contentTxt = (TextView) getView(champDeSaisie);
getActiviteEnCours().registerReceiver(mBatInfoReceiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
}

// champ de saisie qui affichera le niveau de batterie
static TextView contentTxt;

static BroadcastReceiver mBatInfoReceiver = new BroadcastReceiver(){
PUBLIC void onReceive(Context arg0, Intent intent< /FONT>) {
int level = intent.getIntExtra("level", 0);
contentTxt.setText(string.valueOf(level));
}
};

I work with Windev Mobile 22, latest version.

Could you help me because I do not see any solution?

Thank you in advance.

Best Regards,

Gaël L.


--
Atte. Willian Fernando