i still get problems
1 i cant import com.codename1.impl.android.AndroidNativeUtil
when building on the server i get the problem
Compiling with JDK Java compiler API.
/tmp/build1637479177142233945xxx/TalkingGps/src/main/java/com/Bellproductions/TalkingGps/BrightImpl.java:12:
error: cannot find symbol
import com.codename1.impl.android.AndroidNatativeUti;
^
symbol: class AndroidNatativeUti
location: package com.codename1.impl.android
2 wheb i dont include the import
i cant reach the class BrightImpl
Bright.Issurported doesnt return true
i trigger native interface
private Bright bright;
bright = (Bright)NativeLookup.create(Bright.class);
private void dimlistner() {
if (dim.isSelected()) {
Boolean B = true;
int brght = 55;
if (bright.isSupported()) {
B = bright.brightset(brght);
}
Dialog.show("Check", B.toString() , "OK", null);
} else {
int brght = 255;
Boolean B = true;
if (bright.isSupported()) {
B = bright.brightset(brght); }
Dialog.show("Check", B.toString() , "OK", null);
}
}
Bright,java
import com.codename1.system.NativeInterface;
public interface Bright extends NativeInterface {
public boolean brightset(int brightness) ;
}
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.provider.Settings;
import android.view.View;
import android.view.WindowManager;
import android.app.Activity;
import android.view.Window;
import com.codename1.impl.android.AndroidNativeUtil;
public class BrightImpl extends Activity {
public boolean brightset(int brightness ) {
try {
Context context = getApplicationContext();
// Check whether has the write settings permission or not.
if
(!com.codename1.impl.android.AndroidNatativeUtil.checkForPermissions(Manifest.permission.WRITE_SETTINGS,
"permission asked ")) {}
changeScreenBrightness(context, brightness);
return false;
} catch (Exception e) {}
return false;
}
// This function only take effect in real physical android device,
// it can not take effect in android emulator.
private void changeScreenBrightness(Context context, int
screenBrightnessValue)
{
// Change the screen brightness change mode to manual.
Settings.System.putInt(context.getContentResolver(),
Settings.System.SCREEN_BRIGHTNESS_MODE,
Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL);
// Apply the screen brightness value to the system, this will
change the value in Settings ---> Display ---> Brightness level.
// It will also change the screen brightness for the device.
Settings.System.putInt(context.getContentResolver(),
Settings.System.SCREEN_BRIGHTNESS, screenBrightnessValue);
//refreshes the screen
/* int br = Settings.System.getInt(context.getContentResolver(),
Settings.System.SCREEN_BRIGHTNESS);
WindowManager.LayoutParams lp = getWindow().getAttributes();
lp.screenBrightness = (float) screenBrightnessValue / 255;
getWindow().setAttributes(lp);
*/
Window window = getWindow();
WindowManager.LayoutParams layoutParams = window.getAttributes();
layoutParams.screenBrightness = screenBrightnessValue / 255f;
window.setAttributes(layoutParams);
getWindow().addFlags(WindowManager.LayoutParams.FLAGS_CHANGED);
}
public boolean isSupported() {
return true;
}
}
Op zondag 3 november 2019 10:32:41 UTC+1 schreef Peter Bell:
>
> Ii didnt ment that you have to debug the code, but do you hve any clue
> what can be wrong with the code
>
> Op donderdag 31 oktober 2019 03:55:13 UTC+1 schreef Shai Almog:
>>
>> If your device is an Android 5 device then the previous code might have
>> worked as it predates the Android 6 update. Still I haven't tried this
>> myself so I'm not sure what could happen there. I suggest connecting a
>> cable and looking through logcat logs. You can also debug on Android Studio
>> if that would help see:
>> https://www.codenameone.com/how-do-i---use-the-include-sources-feature-to-debug-the-native-code-on-iosandroid-etc.html
>>
>
--
You received this message because you are subscribed to the Google Groups
"CodenameOne Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/codenameone-discussions/16d45f97-b835-4159-96ea-a1787c3ed246%40googlegroups.com.