Einzelnen Beitrag anzeigen

philipp.hofmann

Registriert seit: 21. Mär 2012
Ort: Hannover
857 Beiträge
 
Delphi 10.4 Sydney
 
#6

AW: Fehler beim Android-FileProvider: Datei wird nicht geöffnet

  Alt 22. Mai 2019, 15:44
Der Vollständigkeithalber der angepasste Code:

Delphi-Quellcode:
uses Androidapi.JNI.Support;
...
  var fileuri: JNet_Uri;
    TheFile: JFile;
    Intent: JIntent;
  begin
    theFile := TJFile.JavaClass.init(StringToJString(appPath+'docs'), StringToJString('icTrainer.pdf'));
    fileuri := TAndroidHelper.JFileToJURI(theFile);
    Intent := TJIntent.Create;
    Intent.setAction(TJIntent.JavaClass.ACTION_VIEW);
    Intent.setDataAndType(fileuri,StringToJString('application/pdf'));
    Intent.setFlags(TJIntent.JavaClass.FLAG_GRANT_READ_URI_PERMISSION);
    TAndroidHelper.Activity.StartActivity(Intent);
  end;
und Project Options - Application - Entitlement-List - Secure File Sharing = true
und die Anpassungen im Manifest-Template und die Datei .\res\xml\fileprovider.xml.
  Mit Zitat antworten Zitat