Results 1 to 3 of 3

Thread: .apk bestand installeren met code.

  1. #1

    .apk bestand installeren met code.

    Ik zoek een mogelijkheid om een .apk bestand te installeren met code.

    Ik zit hier naar te kijken:
    https://stackoverflow.com/questions/...ly-new-version

    En gebruik dit deel:
    --------------------------------------------
    Code:
    procedure TForm1.Button5Click(Sender: TObject);
    begin
      StartActivity('MMSoft/Test.apk');
    end;
    
    procedure TForm1.StartActivity(const FileName: string);
    var
     Path: JString;
     Name: JString;
     F: Jfile;
      Intent: JIntent;
    begin
     //rgineel:
     //Path := StringToJString(System.IOUtils.TPath.GetDirectoryName(FileName));
     //Name := StringToJString(System.IOUtils.TPath.GetFileName(FileName));
    
     Path := StringToJString(Path_MMSoft + '/');
     Name := StringToJString('Test.apk');
    
     F := TJfile.JavaClass.init(Path, Name);
    
     Intent := TJIntent.Create();
     Intent.setAction(TJIntent.JavaClass.ACTION_VIEW);
     Intent.addFlags(TJIntent.JavaClass.FLAG_ACTIVITY_NEW_TASK);
     Intent.setDataAndType(TJnet_Uri.JavaClass.fromFile(F), StringToJString('application/vnd.android.package-archive'));
    
     TAndroidHelper.Context.startActivity(Intent);
     Application.Terminate();
    end;
    --------------------------------------------

    Helaas krijg ik deze foutmelding:
    android.os.FileUriExposedException:
    file:///storage/emulated/o/MMSoft/Test.apk
    exposed beyond app through Intent.getData()
    --------------------------------------------

    Wat doe ik verkeerd en hoe is dit werkend te krijgen ?

  2. #2

  3. #3
    Het werkt:

    Ik heb de code van Dave gebruikt
    https://en.delphipraxis.net/topic/72...&comment=61723

    Aan het bestand "AndroidManifest.template.xml" hoeft niets gewijzigd te worden !

    Project -> Options -> Entitlement List: Secure File Sharing: Aanzetten

    Project -> Options -> Uses Permissions -> Signature (matching certificate): Request install packages: Aanzetten

    uses: Androidapi.JNI.Webkit;


    Rik en Dave bedankt !!!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •