###前提・実現したいこと
Andoroidのアプリで自動アップデートを実装したいです。
###発生している問題・エラーメッセージ
×アプリはインストールされていません。 名前が同じで、署名が競合するパッケージが既にインストールされています。
###該当のソースコード
//インストール
Intent intent = new Intent(Intent.ACTION_VIEW);
Uri dataUri = Uri.fromFile(tempApkFile);
intent.setDataAndType(dataUri, "application/vnd.android.package-archive");
startActivity(intent);
//ダウンロード
private class downloadTask extends AsyncTask<Object, Object, Object> {
@Override
protected Object doInBackground(Object... param) {
try {
File cacheDir = activity.getExternalCacheDir();
tempApkFile = File.createTempFile("apk", ".apk", cacheDir);
tmpFilePath = tempApkFile.getPath();
Util.urlToFile(updateApkFileUrl, tempApkFile);
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
@Override
protected void onPostExecute(Object result) {
if(tempApkFile!=null && tempApkFile.exists()){
updateListeners.downloadCompleteNotify();
}else{
updateListeners.downloadErrorNotify();
}
}
}
//apkファイルバージョン確認
private void getCurrentVersionInfo() throws Exception {
PackageManager pm = activity.getPackageManager(); String packageName = activity.getPackageName(); PackageInfo info = pm.getPackageInfo(packageName, PackageManager.GET_META_DATA); currentVersionCode = info.versionCode; currentVersionName = info.versionName;
}
private void getLatestVersionInfo() throws Exception{
HashMap<String, String> map = parseUpdateXml(updateXmlUrl); latestVersionCode = Integer.parseInt(map.get("versionCode")); latestVersionName = map.get("versionName"); updateApkFileUrl = map.get("url"); latestDescription = map.get("description");
}
//
###試したこと
・端末を変えての実行
###補足情報(言語/FW/ツール等のバージョンなど)
・参考サイト:http://fukure.sakura.ne.jp/wordpress/archives/689
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。