Install: From sdcard
-
- String filename = environment. getexternalstoragedirectory () +"/Myapp.apk";
-
- Intent intent =NewIntent (intent. action_view );
-
- Intent. setdataandtype (URI. parse ("File ://"+ Filepath ),"Application/vnd. Android. Package-Archive");
-
- Or
- // Intent. setdataandtype (URI. fromfile (new file (filename), "application/vnd. Android. Package-Archive ");
-
- Startactivity (intent );
String filename = environment. getexternalstoragedirectory () + "/myapp.apk"; <br/> intent = new intent (intent. action_view); <br/> intent. setdataandtype (URI. parse ("file: //" + filepath), "application/vnd. android. package-Archive "); <br/> or <br/> // intent. setdataandtype (URI. fromfile (new file (filename), "application/vnd. android. package-Archive "); <br/> startactivity (intent );
Uninstall
- Uri packageuri = URI. parse ("Package: COM. Android. MyApp");
- Intent uninstallintent =NewIntent (intent. action_delete, packageuri );
- Startactivity (uninstallintent );
Uri packageuri = Uri. parse ("package: COM. android. myApp "); <br/> intent uninstallintent = new intent (intent. action_delete, packageuri); <br/> startactivity (uninstallintent );
Original http://blog.csdn.net/fenghome/archive/2010/06/16/5673757.aspx