Brian Long has a new comprehensive article up which covers launching activities and returning the result in Delphi XE6 Firemonkey on Android. Delphi XE6 has expanded functionality to get the results returned from an activity which was much more difficult to do in Delphi XE5. In addition to the activity results the article demonstrates how to show an Android Toast, show the Android battery usage screen, launch a URL, send an SMS, send an email, and launch a QR Scanner. The most important part of the article is the code demonstrating how to get results from the launched activity. Previously with the QR Scanner for example the tricky way to do it was via the Clipboard. Now with Delphi XE6 Firemonkey you can actually return and process the results of the startActivityForResult() Android API call. Here is a sample of the source code that starts the activity and then processes the results:
procedure TMainForm.BarcodeScannerButtonClick(Sender: TObject);
FMessageSubscriptionID := TMessageManager.DefaultManager.SubscribeToMessage(TMessageResultNotification,
procedure TMainForm.HandleActivityMessage(const Sender: TObject; const M: TMessage);
if M is TMessageResultNotification then
function TMainForm.OnActivityResult(RequestCode, ResultCode: Integer; Data: JIntent): Boolean;
ScanContent, ScanFormat: string;
Result := False;
FMessageSubscriptionID := 0;
// For more info see https://github.com/zxing/zxing/wiki/Scanning-Via-Intent
if RequestCode = ScanRequestCode then
if ResultCode = TJActivity.JavaClass.RESULT_OK then
if Assigned(Data) then
ScanContent := JStringToString(Data.getStringExtra(StringToJString('SCAN_RESULT')));
ScanFormat := JStringToString(Data.getStringExtra(StringToJString('SCAN_RESULT_FORMAT')));
Toast(Format('Found %s format barcode:'#10'%s', [ScanFormat, ScanContent]), LongToast);
else if ResultCode = TJActivity.JavaClass.RESULT_CANCELED then
Toast('You cancelled the scan', ShortToast);
Result := True;
At the top of the article there is also a link to a similar article for Delphi XE5.
Head over and read the full article about starting an Activity on Android and processing the results with Delphi XE6.
In delphi XE7 SharedActivity.startActivity(JIntent); not working in android apps. It is giving error while building the app. Can you please look into this and help us ?
And also TextPrompt (Water Marks) are not working in TEdits in android.
You can also just stick a TLabel inside of your TEdit and align it to Content or Client. Set it’s HitTest property to false. In the onChange event show it or hide it based on if the Text property is blank. TextPrompt had issues in previous versions too so I used this workaround instead.
But it is working fine in Delphi XE6 Update 1 ?
What about SharedActivity ? Please guide on this. Other wise shall we go back to the XE6 ?