@Override public void run() { List<AppInfo> installedSoftList = Env.getInstalledAppsToList(application, false); CacheDB cacheDB = CacheDB.getInstance(application); appListDataSource = cacheDB.getUpdatedSoft(installedSoftList); Message msg = mHandler.obtainMessage(); msg.what = HANDLE_UPDATE_APP; mHandler.sendMessage(msg); }
@Override public void handleMessage(Message msg) { switch (msg.what) { case HANDLE_UPDATE_APP: updateAppListAdapter = new UpdateAppsListAdapter( getActivity(), appListDataSource, mHandler, application); mListView.setAdapter(updateAppListAdapter); updateAppListAdapter.notifyDataSetChanged(); dismissLoading(); break; case GENERAL_APPS_INSTALL_REQUEST: File file = (File) msg.obj; // Env.install(getActivity(), file, GENERAL_APPS_INSTALL_REQUEST); if (file.exists()) { /*Intent intent = new Intent(Intent.ACTION_VIEW); try { Runtime.getRuntime().exec("chmod 655 " + file.toString()); } catch (IOException e) { e.printStackTrace(); } intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive"); if (isAdded() && getActivity() != null) { getActivity().startActivityForResult(intent, GENERAL_APPS_INSTALL_REQUEST); }*/ if (isAdded() && getActivity() != null) { Env.install(getActivity(), file, GENERAL_APPS_INSTALL_REQUEST); } } else { ToastUtil.showToast(application, R.string.str_apk_download_failure); } break; default: break; } }