編輯:關於android開發
升級時碰見的異常
private void installPackage(String appName,final File apk) { if (!apk.exists()) { setHasNewVersion(appName,false); hideProgressDialog(); return; } apk.setReadable(true, false); apk.setExecutable(true, false); //走完installPackage之後就結束了,回調observer內的代碼是異步執行了 final PackageManager pm = getPackageManager(); PackageInstallObserver observer = new PackageInstallObserver(appName); Log.i(TAG, "install the apk begin : "+appName+";;getAbsolutePath="+apk.getAbsolutePath()); pm.installPackage( Uri.parse("file://" + apk.getAbsolutePath()), observer, PackageManager.INSTALL_REPLACE_EXISTING, null); }
private class PackageInstallObserver extends IPackageInstallObserver.Stub { private String appname; public PackageInstallObserver(String appName) { appname=appName; } public void packageInstalled(final String packageName, int returnCode) { setHasNewVersion(appname,false); String appPath = getFilesDir().getAbsolutePath()+"/apps/"+appname+".apk"; File apk = new File(getFilesDir(), appname+".apk"); Log.i(TAG, "install is end and delete "+apk.getAbsoluteFile()); apk.delete(); hideProgressDialog(); if(returnCode==1){ installReturnCode=3; }else{ if(returnCode<0){ installReturnCode=returnCode; }else{ installReturnCode=-123455; } } Log.i(TAG, "installReturnCode "+installReturnCode+"; packageName = "+packageName); new Thread(){ public void run() { postUpdateResult(packageName,appname,installReturnCode);//安裝成功 }; }.start(); } }
異常
W/asset ( 1245): Asset path /data/data/com.****.******/files/apps/pjlauncher.apk is neither a directory nor file (type=0).
W/DefContainer( 1245): Failed to parse package
W/ActivityManager( 535): No content provider found for permission revoke: file:///data/data/com.****.***/files/apps/*****.apk
D/dalvikvm( 535): GC_EXPLICIT freed 573K, 24% free 4589K/6028K, paused 2ms+3ms, total 35ms
I/AppUpgradeService( 1227): install is end and delete /data/data/com.****.******/files/apps/*****.apk
查了好半天有說是要添加權限的,有說是要在使用時給apk修改權限的,試了半天都沒有效果。
最後修改了apk文件的下載存放路徑,結果安裝成功。
* 如果apk下載到這個目錄/data/data/com.****.******/files/apps
* 會出現No content provider found for permission這個異常
* 如果是這個目錄/data/data/com.****.******/files
* 則沒有問題
感覺很奇怪我在其他機頂盒上測試的時候,即使是在/data/data/com.****.******/files/apps這個目錄也可以順利安裝apk,但是換了一台機頂盒之後就不可以了
可能是不同機頂盒系統有差異吧!
ps:這個功能需要進行系統簽名,以及配置android:sharedUserId="android.uid.system"
Android 用Canvas畫textview、bitmap、矩形(裁剪)、橢圓、線、點、弧 初始化對象 private Paint mPaint;//畫筆 pri
[android] 天氣app布局練習(二),androidapp主要練習一下GridView MainActivity.java package com.examp
Android Material Design 兼容庫的使用,androidmaterialAndroid Material Design 兼容庫的使用 mecury
Android Design Support Library——Navigation View,androidnavigation前沿 Android 從5.0開始引
android入門系列- TextView EditText Butto