在程序中通过: String fileName = Environment.getExternalStorageDirectory() + "/" + apkname;
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(new File(fileName)), "application/vnd.android.package-archive");
mService.startActivity(intent);来安装指定apk,但是如何监控这个程序安装是否成功呢?有没有什么类似的回调方法?都是这用通过intent来实现的功能,如何得知安装状态呢?我要根据安装状态来做一些处理,包括list的更新和提示等。
在线等~
谢谢
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(new File(fileName)), "application/vnd.android.package-archive");
mService.startActivity(intent);来安装指定apk,但是如何监控这个程序安装是否成功呢?有没有什么类似的回调方法?都是这用通过intent来实现的功能,如何得知安装状态呢?我要根据安装状态来做一些处理,包括list的更新和提示等。
在线等~
谢谢
MIME type是什么东西啊?
adb permission denied....
不是不支持,是权限的问题,应用程序权限很低,而且很难获取到root
installPackage (Uri packageURI, IPackageInstallObserver observer, int flags)然后如果安装成功:
public static final int INSTALL_SUCCEEDED Installation return code: this is passed to the IPackageInstallObserver by installPackage(android.net.Uri, IPackageInstallObserver, int) on success.这样能否在IPackageInstallObserver里面监听对比INSTALL_SUCCEEDED这个CODE值了 , 就知道安装成功没
http://blog.csdn.net/Zengyangtech/archive/2010/07/16/5738940.aspx
IPackageInstallObserver这个类能直接调么 我试过好像不行
<intent-filter>
<category android:name="android.intent.category.DEFAULT" />
<action android:name="android.intent.action.PACKAGE_ADDED"></action>
<data android:scheme="package"/>
</intent-filter>
<intent-filter>
<category android:name="android.intent.category.DEFAULT" />
<action android:name="android.intent.action.PACKAGE_REMOVED"></action>
<data android:scheme="package"/>
</intent-filter>
</receiver>
实现这个广播接收者就行了 在接受者中根据获得的ACTION判断是安装还是卸载了 已经试验过了 可以的