0

I'm trying to create an automatic update for my application, without the use of Android Market, for an application that will be distributed only to my clients. I have the code below but it is not working. It gives me the error Android.content.ActivityNotFoundException : In Actitivy found to handle intent { ....

Has anyone managed to do this in Delphi auto update XE5?

TFrmMain.BtnInstalarClick procedure (Sender : TObject ) ;
var
    Intent : JIntent ;
    Uri : TJnet_Uri ;
begin
    Intent : = TJIntent.Create ;
    Intent.setAction ( TJIntent.JavaClass.ACTION_VIEW );
    Intent.setDataAndType(TJnet_Uri.JavaClass.parse(StringToJString('/storage/sdcard0/Android/data/com.CloudCon.AtualizacaoAutomatica/files/Rota.apk')),StringToJString('application/vnd.android.package-archive')); 
    SharedActivity.startActivity ( Intent ) ;
end ;

The path is correct. The permissions of INTERNET, WRITE_EXTERNAL_STORAGE, and INSTALL_PACKAGES were also set.

Apparently I can do the following in Java:

" String command = " chmod 666 " + PATH ;
Runtime.getRuntime ( ) . Exec (command ) ; "

How can I do this in Delphi.

JensG
  • 13,148
  • 4
  • 45
  • 55
Cloudcon
  • 21
  • 7

1 Answers1

2

You can try this code,

var
  aFile:Jfile;
  Intent:JIntent;
begin    

  aFile:=TJfile.JavaClass.init(stringtojstring('/storage/sdcard0/Android/data/com.CloudCon.AtualizacaoAutomatica/files/'),stringtojstring('Rota.apk'));
  Intent := TJIntent.Create ;
  Intent.setAction(TJIntent.JavaClass.ACTION_VIEW);
  Intent.addFlags(TJIntent.JavaClass.FLAG_ACTIVITY_NEW_TASK);
  Intent.setDataAndType(TJnet_Uri.JavaClass.fromFile(aFile),StringToJString('application/vnd.android.package-archive'));
  SharedActivityContext.startActivity(Intent);
end;   
Balaji Kandasamy
  • 4,446
  • 10
  • 40
  • 58