I have an Android app written in Delphi.
When launching the app and initializing another app by Intent
, after closing the second app and going back to the first app, the first app is restarted.
Note: I saw that there is something about the onSaveState
event, but I need my app not to restart because I use the return data from the second app in it.
I performed the initialization of the second app by Intent
and when closing the second app, it should go back to the first one at a point where I can manipulate the Intent
information where I opened the second app, but it is restarting the first app.
UPDATE: --//--//--//--//--//--// Here is my code:
procedure TForm1.btnEnviarTransacaoClick(Sender: TObject);
begin
try
var AURI:string:= 'payment-app://pay?return_scheme=retorno&amount=9999&editable_amount=0&transaction_type=credit';
var AIntent: JIntent := TJIntent.Create;
AIntent := TJIntent.JavaClass.init(TJIntent.JavaClass.ACTION_VIEW);
AIntent.addFlags(TJIntent.JavaClass.FLAG_ACTIVITY_NEW_TASK);
AIntent.setData(TJNet_Uri.JavaClass.parse(StringToJString(TIdURI.URLEncode(AURI))));
TAndroidHelper.Activity.startActivityForResult(AIntent, 0);
Timer1.Enabled:= True;
except
on E: Exception do begin
TThread.Synchronize(nil, procedure
begin
lOG.D(E.Message);
end);
end;
end;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
Timer1.Enabled:= False;
var ADLg:= TForm2.Create(Self);
ADLg.Show;
end;
note: after start activity , I trigger a 4 second timer to create a new form and show it, but after finishing the second app and returning to the home app, the home app restarts. Sometimes debugging I managed to catch the exception:
> cant perform this action after onSaveInstanceState
this is my AndroidManifest, where to use explicit intent by scheme
{<activity
android:name=".PaymentActivity"
android:launchMode="singleTop"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="pay-response"
android:scheme="retorno" />
</intent-filter>
</activity>}