我已经使用下载管理器 api 从 localhost 服务器下载了 apk 文件,并且还显示了我下载了哪些文件,但问题是如果我单击该 .apk 文件,无法安装,它会给出解析包错误。这是我的 xml 页面
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="onClick"
android:text="Start Download" >
</Button>
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="showDownload"
android:text="View Downloads" >
</Button>
这里是我的代码
BroadcastReceiver broad = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
// TODO Auto-generated method stub
String action = intent.getAction();
if (DownloadManager.ACTION_DOWNLOAD_COMPLETE.equals(action)) {
long downloadId = intent.getLongExtra(
DownloadManager.EXTRA_DOWNLOAD_ID, 0);
Query query = new Query();
query.setFilterById(enqueue);
Cursor c = dm.query(query);
if (c.moveToFirst()) {
int columnIndex = c
.getColumnIndex(DownloadManager.COLUMN_STATUS);
if (DownloadManager.STATUS_SUCCESSFUL == c
.getInt(columnIndex)) {
// ImageView view = (ImageView)
// findViewById(R.id.imageView1);
final String uriString = c
.getString(c
.getColumnIndex(DownloadManager.COLUMN_LOCAL_URI));
// search.setImageURI(Uri.parse(uriString));
}
}
}
}
};
registerReceiver(broad, new IntentFilter(
DownloadManager.ACTION_DOWNLOAD_COMPLETE));
public void showDownload(View view) {
Intent i = new Intent();
i.setAction(DownloadManager.ACTION_VIEW_DOWNLOADS);
startActivity(i);
}
安装下载管理器中的apk文件的程序是什么?