Jump to content

NecoArc

Members
  • Content Count

    26
  • Joined

  • Last visited

Community Reputation

1 Neutral

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. NecoArc

    delphi 13 full screen on android 10 or less

    TJView.JavaClass.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION and TJView.JavaClass.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN are the ones causing the application to crash. Meanwhile, SYSTEM_UI_FLAG_LAYOUT_STABLE prevents the weird layout shifts, but it also turns the Android system UI into a white bar at the bottom of the app, which makes it unusable as well.
  2. NecoArc

    delphi 13 full screen on android 10 or less

    Thank you for your reply. However, one of these flags is causing the application to crash on an Android 9 device. I’ll test each flag individually to find out which one is responsible.
  3. After updating to Delphi 13, I noticed that on some devices my applications would close immediately after launch. After analyzing the ADB logs, I found that the following error message was causing the app to crash: ClassNotFoundException: Didn't find class "android.view.WindowInsets$Type" After further investigation, I discovered that the line responsible for this issue was: form.FullScreen := true; I contacted Embarcadero support, and they explained that Delphi 13 uses the class android.view.WindowInsets, which was introduced in Android 11. In other words, the FullScreen command no longer works on devices running Android versions below 10. Embarcadero basically told me: “That’s how Delphi 13 works, it’s your problem.” So, I’m looking for an alternative way to replace the fullscreen command on older Android versions. I’m currently using this method: class procedure TScreenHelper.HideAndroidInterface; begin {$IFDEF ANDROID} var Activity: JActivity; var Window: JWindow; var View: JView; var Flags: Integer; TThread.Queue(nil, procedure begin Activity := TAndroidHelper.Activity; if Assigned(Activity) then begin Window := Activity.getWindow; if Assigned(Window) then begin View := Window.getDecorView; if Assigned(View) then begin Flags := TJView.JavaClass.SYSTEM_UI_FLAG_HIDE_NAVIGATION or TJView.JavaClass.SYSTEM_UI_FLAG_FULLSCREEN or TJView.JavaClass.SYSTEM_UI_FLAG_IMMERSIVE_STICKY; View.setSystemUiVisibility(Flags); end; end; end; end); {$ENDIF} end; However, this approach doesn’t work very well — it causes weird layout adjustments on the screen, and whenever the Android virtual keyboard appears, the system UI becomes visible again, forcing me to manually hide it again. Does anyone have any suggestions or a better workaround for this?
  4. NecoArc

    How on Mobile optimize memory usage ?

    not related but you can reduce app size by runing VACUUM command on your database.s3db file i had an apk with 100mb and after vaccum it was reduced to 40mb
  5. I tried that, but it didn’t work. So, checking the logs, I attempted some additional fixes. First, I found the class codescanner.SetActivity inside my .jar file: package br.com.gertec.easylayer.codescanner; import android.content.Intent; import android.os.Bundle; import androidx.appcompat.app.AppCompatActivity; import br.com.gertec.easylayer.R; public class SetActivity extends AppCompatActivity { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.setContentView(R.layout.activity_set); Intent intent = this.getIntent(); String s = intent.getStringExtra("result"); if (s != null) { Intent returnIntent = new Intent(); returnIntent.putExtra("content", s); this.setResult(-1, returnIntent); this.finish(); } else { this.finish(); } } Then I implemented the interface in my .jni file: JSetActivity = interface; JSetActivityClass = interface(JObjectClass) ['{D0B8C7AF-92C5-4BB5-8E1A-B76164E7AB10}'] end; [JavaSignature('br/com/gertec/easylayer/codescanner/SetActivity')] JSetActivity = interface(JObject) ['{EBB78E1F-92A4-4E1E-B55C-67130FCEB2A3}'] procedure onCreate(bundle: JBundle); cdecl; end; TJSetActivity = class(TJavaGenericImport<JSetActivityClass, JSetActivity>) end; TRegTypes.RegisterType('android.jni.easylayersk210.JSetActivity', TypeInfo(android.jni.easylayersk210.JSetActivity)); However, I don’t think my declaration is correct. SetActivity extends AppCompatActivity, but I can’t extend this class properly in Delphi. What I think it should be, but I couldn’t make it work because delphi do not recognize JAppCompatActivity, or i didn't find the correct uses path for it JSetActivityClass = interface(JAppCompatActivityClass) JSetActivity = interface(JAppCompatActivity) After this change, the log showed that I need to declare the activity: 09-26 10:51:28.083 I/ActivityTaskManager(1070): START u0 {cmp=com.embarcadero.Project1/br.com.gertec.easylayer.codescanner.SetActivity (has extras)} from uid 10129 09-26 10:51:28.086 E/JavaBinder(21949): android.content.ActivityNotFoundException: Unable to find explicit activity class {com.embarcadero.Project1/br.com.gertec.easylayer.codescanner.SetActivity}; have you declared this activity in your AndroidManifest.xml, or does your intent not match its declared <intent-filter>? 09-26 10:51:28.086 E/JavaBinder(21949): at br.com.gertec.easylayer.codescanner.CodeScanner$1.onResult(CodeScanner.java:281) so i did <activity android:name="br.com.gertec.easylayer.codescanner.SetActivity" android:exported="true"> </activity> Now, instead of the previous error, the app crashes, saying that codescanner.SetActivity closed the app due to timeout, because it didn’t find the activity to return the result, i think. 09-26 11:05:35.026 W/ActivityTaskManager( 1070): Force finishing activity com.embarcadero.Project3/br.com.gertec.easylayer.codescanner.SetActivity 0 09-26 11:05:35.527 W/ActivityTaskManager( 1070): Activity top resumed state loss timeout for ActivityRecord{6f4eb43 u0 com.embarcadero.Project3/br.com.gertec.easylayer.codescanner.SetActivity} t272 f}} 09-26 11:05:35.528 W/ActivityTaskManager( 1070): Activity pause timeout for ActivityRecord{6f4eb43 u0 com.embarcadero.Project3/br.com.gertec.easylayer.codescanner.SetActivity} t272 f}} idk what i can do anymore
  6. I’m working with the TOPWISE SK210 device, which is a mini kiosk with a built-in printer and barcode scanner. Here in Brazil, this device is distributed by Gertec, and they provided me with the .jar files and the device manuals. I’m currently trying to integrate the scanner into a Delphi 12 test application. I can successfully call the scanner and trigger a reading, but I cannot retrieve the scanned result. Below is my Delphi code: procedure TForm1.FormCreate(Sender: TObject); begin // Registra o listener para interceptar mensagens de resultado de atividade FMessageSubscriptionID := TMessageManager.DefaultManager.SubscribeToMessage(TMessageResultNotification, HandleActivityMessage); FScannerAtivo := False; end; procedure TForm1.Button1Click(Sender: TObject); var scanner: JCodeScanner; config: JScanConfig; begin Activity := TAndroidHelper.Activity; if not Assigned(Activity) then begin LogDebug('ERRO'); Exit; end; scanner := TJCodeScanner.JavaClass.getInstance(Activity); scanner.scanCode(Activity); end; procedure TForm1.HandleActivityMessage(const Sender: TObject; const M: TMessage); var ResultMsg: TMessageResultNotification; Intent: JIntent; ExtraString: JString; begin if not (M is TMessageResultNotification) then begin Exit; end; ResultMsg := TMessageResultNotification(M); if ResultMsg.ResultCode = TJActivity.JavaClass.RESULT_OK then begin logDebug('it work!') end else if ResultMsg.ResultCode = TJActivity.JavaClass.RESULT_CANCELED then begin logDebug('did not work') end; end; For comparison, here is the Java example that works as expected: @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_code_scanner); codeScanner = CodeScanner.getInstance(this); btnStart = findViewById(R.id.btnStart); btnStart.setOnClickListener(view -> { codeScanner.scanCode(this); }); } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (resultCode == RESULT_OK) { String content = data.getStringExtra("content"); if (content != null) { consultaOrder.add(content); adapter.notifyDataSetChanged(); } }else { super.onActivityResult(requestCode, resultCode, data); } } Problem When running the Delphi code, the HandleActivityMessage method is always triggered with TJActivity.JavaClass.RESULT_CANCELED. It never returns RESULT_OK, so I cannot capture the scan result. Using Logcat, I found the following error message: 09-25 16:56:43.681 I/ActivityTaskManager( 1063): START u0 {cmp=com.embarcadero.Project1/br.com.gertec.easylayer.codescanner.SetActivity (has extras)} from uid 10126 09-25 16:56:43.685 E/JavaBinder(28668): android.content.ActivityNotFoundException: Unable to find explicit activity class {com.embarcadero.Project1/br.com.gertec.easylayer.codescanner.SetActivity}; have you declared this activity in your AndroidManifest.xml, or does your intent not match its declared <intent-filter>? 09-25 16:56:43.685 E/JavaBinder(28668): at br.com.gertec.easylayer.codescanner.CodeScanner$1.onResult(CodeScanner.java:281) Investigation After checking, I noticed that my JNI file generated by java2op does not include codescanner.SetActivity. When I regenerated the JNI bindings using java2op, I confirmed that it was not created because of the following issue: br.com.gertec.easylayer.codescanner.SetActivity: the parent class (androidx.appcompat.app.AppCompatActivity) is not found Essentially, the problem seems to be that the SetActivity class is missing from my Delphi project because its parent (androidx.appcompat.app.AppCompatActivity) is not being resolved during JNI generation. does someone know what i can do to solve it? thanks in advance everyone
  7. thank you hans! this revelation about the ownership of scrolls just saved my life i couldn't unsderstand why one of my projects the scroll was working and on the other project was not working
  8. yeah i notice that extra space after the print, i made some test without it and it keeps crashing the aplication from what i've understood putting any kind of provider tag on the manifest.template.xml just break the application so i took it out before finding a solution then we can conclude that the tag is not necessary but still in some other situation it may be necessary since my solution does not use the native startup runtime (but I don't know if it would be possible because simply adding the provider tag breaks the application) i tested with other types of tag and they were ok
  9. So after a lot of struggle, I finally managed to make this damn thing work. The real issue was the startup-runtime, and I still don’t know how to make it run automatically. I noticed that in the JNI I had, the classes that needed the startup-runtime were commented out, as if java2op hadn’t created their interfaces. To fix the problem, I took the startup-runtime-1.1.1.jar from Embarcadero’s folder and created a new JNI along with this .jar. Right away, I saw that the interfaces using startup-runtime were no longer commented. But that still wasn’t enough to make it work—I had to manually call the methods created by the startup-runtime in Delphi. In my case: jConfigInitializer := TJConfigFileInitializer.Create; usb := TJConUSB.Create; usb.create(TAndroidHelper.Context); and after that it worked
  10. nah it just crashes bro 😕 even if i only add the provider tag without the meta-data the aplication just close when starting
  11. Well now my application crashes instantly when I open it I think this is the right way
  12. thank you for the sugestion i need edit this one inside my aplication folder?
  13. I have an FMX self-service application designed to run on kiosks/tablets with printers and scanners. The application already works on various device models by integrating with their respective AAR/JAR libraries provided by the manufacturers (extracting the .jar files and generating the JNI interface using java2op). This past month, I have been working on integrating two devices sent by a new manufacturer: the Mini Kiosk Model and the Plus Kiosk Model. According to the manufacturer, the same AAR and method calls are used for both devices. On the Mini Kiosk, I was able to make everything work without any issues. However, on the Plus Kiosk, which should work the same way, Delphi returns the following error: java.lang.NullPointerException: Attempt to invoke virtual method 'java.util.HashMap android.hardware.usb.UsbManager.getDeviceList()' on a null object reference. So i created a test project in Java that worked fine on both devices, the issue is not with the AAR itself. After talking to the manufacturer’s support, I was advised that the Plus Kiosk requires the startup-runtime-1.1.0 library (Startup Runtime initializes objects and components automatically when the application starts). I checked the manifest.xml inside the AAR and found the following declaration: <application> <provider android:name="androidx.startup.InitializationProvider" android:authorities="${applicationId}.androidx-startup" android:exported="false" tools:node="merge" > <meta-data android:name="com.e1.Comunicacao.ConUSB" android:value="androidx.startup" /> <meta-data android:name="com.e1.Pagamento.Brigde.ConfigFileInitializer" android:value="androidx.startup" /> </provider> </application> This explains the "null object reference" error, as the UsbManager class is not being initialized properly. However, as far as I understand, Delphi already includes this library internally. So I am looking for suggestions on how I can try to solve this issue: Is there a way to check if startup-runtime is correctly interacting with the manufacturer's libraries? Do I need to regenerate the JNI interface, adding startup-runtime to it? (I’m going to try this now, but I don’t see much sense in doing so.) Can someone please help me? I've already spent several days trying to understand and fix this error.
  14. NecoArc

    Memory leak on parsing json

    In my understanding, FASMM shouldn't cause an increase of 20mb either, but that's the best guess because when I remove the FASMM call from the .dpr of my project the situation stops happening. i attached the memory leak report AutoatendimentoRefatorado_MemoryManager_EventLog.zip
×