0

So I want to write a simple Delphi application with a button. When you click on this button then it should open the Settings App on Android. It should not open anything within the settings, but just the Settings app itself.

I want to do this programmatically. What's the code for this? How does one do this in Delphi?

Shaun Roselt
  • 1,650
  • 5
  • 18
  • 44
  • Where is this a duplicate question? Please link me to that question. – Shaun Roselt Apr 30 '18 at 21:35
  • The [linked duplication question](https://stackoverflow.com/questions/19517417/) explains how to launch the Settings app by starting an `Intent`. You can start an `Intent` in Delphi via `SharedActivity().startActivity()` or `TAndroidHelper.Activity.startActivity()`, depending on your version of Delphi. – Remy Lebeau Apr 30 '18 at 21:52
  • Yes, but that doesn't really help me much in Delphi as the code isn't exactly the same. It looks different in Delphi. – Shaun Roselt Apr 30 '18 at 22:07
  • There are plenty of examples floating around of how to use Android Intents in Delphi, if you search around. – Remy Lebeau Apr 30 '18 at 22:46

2 Answers2

2

I asked something similar ... I did not test for your application, but I believe it works the same way:

How to call the native window of Bluetooth settings on Android in Delphi?

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
wBB
  • 821
  • 1
  • 18
  • 39
  • How would the code look if you just want to open the Settings app and not something inside of the settings app? I tried removing the bluetooth part, I tried removing the entire StringToJString function for the bluetooth part and I tried adding a 0 instead of the StringToJString for bluetooth one. – Shaun Roselt Apr 30 '18 at 22:02
2

Try something like this:

uses
  Androidapi.JNI.GraphicsContentViewText, Androidapi.JNI.Provider, Androidapi.Helpers;

procedure TForm1.Button1Click(Sender: TObject);
var
  LIntent: JIntent;
begin
  LIntent := TJIntent.JavaClass.init(TJSettings.JavaClass.ACTION_SETTINGS);
  LIntent.addFlags(TJIntent.JavaClass.FLAG_ACTIVITY_NEW_TASK); // <-- this might be optional
  TAndroidHelper.Context.startActivity(LIntent);
end;
Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770