0

I started from the Embarcadero template Advanced Android Kiosk Mode that is a kiosk app that launches the device wi-fi settings page. I want to launch another app instead of the wi-fi settings page. So I wrote my procedure to launch the app (following this):

procedure TDashboard.StartSA7;
var
  Intent: JIntent;
begin

  FKioskApp.ActiveOtherActivity := True;

  Intent := TJIntent.Create;

  Intent := MainActivity.getPackageManager.getLaunchIntentForPackage(StringToJString('com.embarcadero.SA7mp'));
  Intent.addFlags(TJIntent.JavaClass.FLAG_ACTIVITY_NEW_TASK); // <-- this might be optional

  if MainActivity.getPackageManager.queryIntentActivities(Intent, TJPackageManager.JavaClass.MATCH_ALL).size > 0 then
    begin
      TAndroidHelper.Context.startActivity(Intent);
      Label2.Text := 'OK!!';
    end
  else
    begin
      Label2.Text := 'NO!!!';
    end;
end;

Well, it does not work.

If the main app, the kiosk app, is not device-owner, and so it is not in kiosk mode, it works and the app com.embarcadero.SA7mp is launched, if the main app is device-owner the secondary app is not launched.

The original code to launch the wi-fi settings page is:

procedure TDashboard.GoToSettings;
var
  LIntent: JIntent;
begin
  FKioskApp.ActiveOtherActivity := True;
  // It is important to set the ActiveOtherActivity flag before opening another application in kiosk mode

  LIntent := TJIntent.JavaClass.init(TJSettings.JavaClass.ACTION_WIFI_SETTINGS);
  LIntent.addFlags(TJIntent.JavaClass.FLAG_ACTIVITY_NEW_TASK); // <-- this might be optional
  TAndroidHelper.Context.startActivity(LIntent);
end;

This code obviously works in kiosk mode.

The secondary app is not a device settings page so perhaps this behaviour is normal.

Someone can help me to solve this problem?

(the target device runs Android 11 and I use Delphi 12.2 patch 2)

Thanks

2
  • If you're going to use queryIntentActivities, you'll need to have a corresponding entry in the manifest in the queries section. In your case: <package android:name="com.embarcadero.SA7mp" /> Commented Dec 5, 2024 at 19:49
  • @DaveNottage I have added the queries section in the manifest file of the main app as you suggested but it does not work. But it works if the main app is not device-owner even without the queries section, why? Commented Dec 6, 2024 at 9:04

1 Answer 1

0

I have solved the problem. In the main app, the Kiosk one, I had to change the line:

FKioskApp.StartLockTask(['com.android.settings']);

in:

FKioskApp.StartLockTask(['com.embarcadero.SA7mp']);

In this way the secondary app is launced and it runs in kiosk mode.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.