I'm using Delphi 10.4 for developing android mobile application. I need to open PDF in both online and local.
By using this code I can able to open the PDF which is online but not able to open the file from local.
procedure openPdf(InpStrPDFPath: string);
var
LIntent: JIntent;
begin
LIntent := TJIntent.Create;
LIntent.setAction(TJIntent.JavaClass.ACTION_VIEW);
LIntent.setDataAndType(StrToJURI(InpStrPDFPath), StringToJString('application/pdf'));
SharedActivity.StartActivity(LIntent);
end;
And tried the following code:
procedure OpenPD_Local(InpStrPDFPath: string);
var
LIntent: JIntent;
LUri: Jnet_Uri;
begin
LIntent := TJIntent.JavaClass.init(TJIntent.JavaClass.ACTION_VIEW);
LUri := StrToJURI(InpStrPDFPath);
LIntent.SetDataAndType(LUri, StringToJString('application/pdf'));
LIntent.setFlags(TJIntent.JavaClass.FLAG_GRANT_READ_URI_PERMISSION);
TAndroidHelper.Activity.startActivity(LIntent);
end;
When I use the above code, it tries open the installed PDF reader but not able to open the file. Please provide me any suggestion to open the PDF file locally in android using Delphi.