这里可以参看http://www.anddev.org/viewtopic.php?p=23928
权限之类的不比说了
Java:
URL sourceUrl = new URL(source);
Object data = sourceUrl.getContent();
String fileName = sourceUrl.getFile().substring(fileName.lastIndexOf('/') + 1);
// create/open file in the 'data/data/<app namespace>/files' directory
FileOutputStream fos = openFileOutput(fileName, Context.MODE_PRIVATE);
int read = 0;
byte[] buffer = new byte[512];
BufferedInputStream bis = new BufferedInputStream((InputStream) data);
do{
read = bis.read(buffer);
if(read > 0){
fos.write(buffer, 0, read);
}
}while(read != -1);
new Intent
(Intent.
ACTION_VIEW
);
intent.
setDataAndType
(Uri.
fromFile
(
new
File
(fileName
)
),
"application/vnd.android.package-archive"
);
startActivity
(intent
);
哲理诗关键 装的
<activity android:name=".PackageInstallerActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="content" />
<data android:scheme="file" />
<data android:mimeType="application/vnd.android.package-archive" />
</intent-filter>
</activity>
卸载的
<activity android:name=".UninstallerActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.DELETE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="package" />
</intent-filter>
</activity>
2.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://Yoururl.com")));