http://maps.apple.com?q=5617 Scotts Valley Drive, Scotts Valley, CA 95066 (需要URL encode)
Android特殊語法
content://contacts/people/
content://contacts/people/1
geo://0,0?q=5617 Scotts Valley Drive, Scotts Valley, CA 95066
geo://46.191200, -122.194400 (I think this one doesn’t like the URLEncode)
作者在文中有提到使用TidURL.URLEncode 。
[pascal]
unit OpenViewUrl;
interface
// URLEncode is performed on the URL
// so you need to format it protocol://path
function OpenURL(const URL: string; const DisplayError: Boolean = False): Boolean;
function OpenURL(const URL: string; const DisplayError: Boolean = False): Boolean;
{$IFDEF ANDROID}
var
Intent: JIntent;
begin
// There may be an issue with the geo: prefix and URLEncode.
// will need to research
Intent := TJIntent.JavaClass.init(TJIntent.JavaClass.ACTION_VIEW,
TJnet_Uri.JavaClass.parse(StringToJString(TIdURI.URLEncode(URL))));
try
SharedActivity.startActivity(Intent);
exit(true);
except
on e: Exception do
begin
if DisplayError then ShowMessage(‘Error: ‘ + e.Message);
exit(false);
end;
end;
end;
{$ELSE}
{$IFDEF IOS}
var
NSU: NSUrl;
begin
// iOS doesn’t like spaces, so URL encode is important.
NSU := StrToNSUrl(TIdURI.URLEncode(URL));
if SharedApplication.canOpenURL(NSU) then
exit(SharedApplication.openUrl(NSU))
else
begin
if DisplayError then
ShowMessage(‘Error: Opening "’ + URL + ‘" not supported.’);
exit(false);
end;
end;
{$ELSE}
begin
raise Exception.Create(‘Not supported!’);
end;
{$ENDIF IOS}
{$ENDIF ANDROID}
[pascal]
if Switch1.IsChecked then begin
if CameraComponent1.HasFlash then
CameraComponent1.TorchMode := TTorchMode.tmModeOn;
end else begin
if CameraComponent1.HasFlash then
CameraComponent1.TorchMode := TTorchMode.tmModeOff;
end;
[/pascal]