PC SOFT

FORUMS PROFESSIONNELS
WINDEVWEBDEV et WINDEV Mobile

Accueil → WINDEV Mobile 2024 → PROBLEM WITH NATIVE JAVA CODE
PROBLEM WITH NATIVE JAVA CODE
Débuté par Bellini lorenzo, 15 déc. 2013 18:17 - 13 réponses
Posté le 15 décembre 2013 - 18:17
Hi,

I tried to use the java code in windev mobile but when I call the procedure always returns the following error:
"The call to native code is not available."

The procedure is very simple:

public static int NewProcedure()
{
return 1;
}

can someone help me?

thanks
Membre enregistré
3 651 messages
Popularité : +175 (223 votes)
Posté le 14 mai 2014 - 18:32
//ExecRun - Funcional - Perfeito

import android.app.Activity;
import android.content.Intent;
import java.lang.*;
import android.util.*;
import java.lang.Exception;
import android.util.Log;

public static boolean ExecRun(String Aplicativo){
try {

if (Aplicativo == null){
return false;
}
else{
Intent Apk = getActiviteEnCours().getPackageManager().getLaunchIntentForPackage(Aplicativo);
getActiviteEnCours().startActivity(Apk);
return true;
}

}
catch(Exception e) {
Log.e("WM",e.toString());
return false;
}
}
Membre enregistré
3 651 messages
Popularité : +175 (223 votes)
Posté le 14 mai 2014 - 18:33
//Simula o click na Tecla Home do Android

import android.app.Activity;
import android.content.Intent;
import java.lang.*;
import android.util.*;
import java.lang.Exception;
import android.util.Log;

public static void KeyHome()
{
Intent startMain = new Intent(Intent.ACTION_MAIN);
startMain.addCategory(Intent.CATEGORY_HOME);
startMain.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
getActiviteEnCours().startActivity(startMain);
}
Membre enregistré
3 651 messages
Popularité : +175 (223 votes)
Posté le 14 mai 2014 - 18:33
//Desativar Bloqueio de Tela, protecao de tela, hibernar
import android.app.Activity;
import android.view.Window;
import android.view.WindowManager.LayoutParams;

public static void DesativarBloqueioTela(boolean keepScreenOn) {
Activity xa = getCurrentActivity();
Window xw = xa.getWindow();
if (keepScreenOn == true) {
xw.addFlags(android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
} else {
xw.clearFlags(android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
}
}
Membre enregistré
3 651 messages
Popularité : +175 (223 votes)
Posté le 14 mai 2014 - 18:34
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.os.Bundle;
import android.telephony.TelephonyManager;
import android.util.Log;
import android.widget.Toast;
import android.provider.Settings.Secure;

public static String CelularGetDeviceId()
{

TelephonyManager tm;
tm = (TelephonyManager)getApplicationContext().getSystemService(Context.TELEPHONY_SERVICE);
String num = tm.getDeviceId();

if (num == ""){
num = "Celular sem chip instalado";
}

else if (num == null){
num = "Celular sem chip instalado";
}

return(num);

}
Membre enregistré
3 651 messages
Popularité : +175 (223 votes)
Posté le 14 mai 2014 - 18:34
//Funcionando abre janela para ajustar as configuracoes
import android.app.Activity;
import java.lang.*;
import android.util.*;
import java.lang.Exception;
import android.util.Log;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;

public static void HabilitaWifiGps()
{
Intent i = new
Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS);
getActiviteEnCours().startActivity(i);
}
Posté le 15 mai 2014 - 02:06
Como llamo al procedimiento en java?

How to call java procedure?
Posté le 15 mai 2014 - 02:14
Como llamo a un procedimiento en Java?

How to call a java procedure?
Posté le 15 mai 2014 - 07:30
Resolviste el problema: "The call to native code is not available."

a mi me sale lo mismo y no se como resolverlo.
Membre enregistré
3 651 messages
Popularité : +175 (223 votes)
Posté le 15 mai 2014 - 14:02
//in screem use my code global:


//Execute never black screen if open app.

DesativarBloqueioTela(true)



//Execute disable never black screen if open app.

DesativarBloqueioTela(false)
Membre enregistré
3 651 messages
Popularité : +175 (223 votes)
Posté le 15 mai 2014 - 14:04
//Or button code:

KeyHome()


//is code up descript examples sends ok
Posté le 31 mai 2014 - 00:05
Hola. El simulador de WM no puede ejecutar codigo java. Debes probarlo en un terminal real o en el emulador de Android.


Rubén
Membre enregistré
3 651 messages
Popularité : +175 (223 votes)
Posté le 02 juin 2014 - 13:36
This I know

use in simulator inibe code error:

if simulatormode () = false
KeyHome()
end

The problem is how to use and extend in Place in WINDEV.

That I do not know.

I spent above examples of codes that I developed with WINDEV Mobile and they are functional. The great difficulty implemetar. Yard and new classes in code Windev Mobile'm finding that when the r.class, creating classes, subclasses and extend in Place is necessary because the commands are not recognized and did not find examples. If you have any example that allows to perform these tasks in WINDEV Mobile I appreciate now.

Att

Adriano
Posté le 19 février 2021 - 22:55
What a great contribution, I would like to know if you know how I could return a variable to use it in the code of a windev mobile window?