-
大小: 194KB文件类型: .zip金币: 1下载: 0 次发布日期: 2021-06-03
- 语言: Java
- 标签: Android 源文件 InstallAppPr
资源简介
近日想实现静默安装(不提示用户),网上搜文章大多提到一个方法 PackageManager.install,这是个非公开方法,它的用法是借鉴了内置应用 packageInstaller,跳过Activity提示用户,直接调用核心方法。用Git下载Android源码较麻烦,也很大,特把这一部分的源码打包给大家。
代码片段和文件信息
/*
**
** Copyright 2007 The Android Open Source Project
**
** Licensed under the Apache License Version 2.0 (the “License“);
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing software
** distributed under the License is distributed on an “AS IS“ BASIS
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
package com.android.packageinstaller;
import com.android.packageinstaller.R;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.DialogInterface.OnCancelListener;
import android.content.pm.ApplicationInfo;
import android.content.pm.IPackageInstallObserver;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.content.pm.PackageManager.NameNotFoundException;
import android.graphics.drawable.LevelListDrawable;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.ProgressBar;
import android.widget.TextView;
import java.util.List;
/**
* This activity corresponds to a download progress screen that is displayed
* when the user tries
* to install an application bundled as an apk file. The result of the application install
* is indicated in the result code that gets set to the corresponding installation status
* codes defined in PackageManager. If the package being installed already exists
* the existing package is replaced with the new one.
*/
public class InstallAppProgress extends Activity implements View.onclickListener OnCancelListener {
private final String TAG=“InstallAppProgress“;
private boolean localLOGV = false;
private ApplicationInfo mAppInfo;
private Uri mPackageURI;
private ProgressBar mProgressBar;
private View mOkPanel;
private TextView mStatusTextView;
private TextView mExplanationTextView;
private Button mDoneButton;
private Button mLaunchButton;
private final int INSTALL_COMPLETE = 1;
private Intent mLaunchIntent;
private static final int DLG_OUT_OF_SPACE = 1;
private CharSequence mLabel;
private Handler mHandler = new Handler() {
public void handleMessage(Message msg) {
switch (msg.what) {
case INSTALL_COMPLETE:
if (getIntent().getBooleanExtra(Intent.EXTRA_RETURN_RESULT false)) {
Intent result = new Intent();
result.putExtra(Intent.EXTRA_INSTALL_RESULT msg.arg1);
setRe
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2011-12-06 10:29 android-platform_packages_apps_packageinstaller-668cc01\
文件 227 2011-12-06 10:29 android-platform_packages_apps_packageinstaller-668cc01\Android.mk
文件 2949 2011-12-06 10:29 android-platform_packages_apps_packageinstaller-668cc01\AndroidManifest.xm
文件 2227 2011-12-06 10:29 android-platform_packages_apps_packageinstaller-668cc01\CleanSpec.mk
文件 0 2011-12-06 10:29 android-platform_packages_apps_packageinstaller-668cc01\MODULE_LICENSE_APACHE2
文件 10695 2011-12-06 10:29 android-platform_packages_apps_packageinstaller-668cc01\NOTICE
目录 0 2011-12-06 10:29 android-platform_packages_apps_packageinstaller-668cc01\res\
目录 0 2011-12-06 10:29 android-platform_packages_apps_packageinstaller-668cc01\res\drawable-hdpi\
文件 707 2011-12-06 10:29 android-platform_packages_apps_packageinstaller-668cc01\res\drawable-hdpi\ic_fail.png
文件 651 2011-12-06 10:29 android-platform_packages_apps_packageinstaller-668cc01\res\drawable-hdpi\ic_success.png
目录 0 2011-12-06 10:29 android-platform_packages_apps_packageinstaller-668cc01\res\drawable-mdpi\
文件 594 2011-12-06 10:29 android-platform_packages_apps_packageinstaller-668cc01\res\drawable-mdpi\ic_fail.png
文件 505 2011-12-06 10:29 android-platform_packages_apps_packageinstaller-668cc01\res\drawable-mdpi\ic_success.png
目录 0 2011-12-06 10:29 android-platform_packages_apps_packageinstaller-668cc01\res\drawable-xhdpi\
文件 947 2011-12-06 10:29 android-platform_packages_apps_packageinstaller-668cc01\res\drawable-xhdpi\ic_fail.png
文件 820 2011-12-06 10:29 android-platform_packages_apps_packageinstaller-668cc01\res\drawable-xhdpi\ic_success.png
目录 0 2011-12-06 10:29 android-platform_packages_apps_packageinstaller-668cc01\res\drawable\
文件 952 2011-12-06 10:29 android-platform_packages_apps_packageinstaller-668cc01\res\drawable\ic_result_status.xm
目录 0 2011-12-06 10:29 android-platform_packages_apps_packageinstaller-668cc01\res\layout\
文件 2595 2011-12-06 10:29 android-platform_packages_apps_packageinstaller-668cc01\res\layout\app_details.xm
文件 5053 2011-12-06 10:29 android-platform_packages_apps_packageinstaller-668cc01\res\layout\install_confirm.xm
文件 1325 2011-12-06 10:29 android-platform_packages_apps_packageinstaller-668cc01\res\layout\install_start.xm
文件 4632 2011-12-06 10:29 android-platform_packages_apps_packageinstaller-668cc01\res\layout\op_progress.xm
文件 4532 2011-12-06 10:29 android-platform_packages_apps_packageinstaller-668cc01\res\layout\uninstall_confirm.xm
文件 4532 2011-12-06 10:29 android-platform_packages_apps_packageinstaller-668cc01\res\layout\uninstall_progress.xm
目录 0 2011-12-06 10:29 android-platform_packages_apps_packageinstaller-668cc01\res\values-af\
文件 7234 2011-12-06 10:29 android-platform_packages_apps_packageinstaller-668cc01\res\values-af\strings.xm
目录 0 2011-12-06 10:29 android-platform_packages_apps_packageinstaller-668cc01\res\values-am\
文件 7884 2011-12-06 10:29 android-platform_packages_apps_packageinstaller-668cc01\res\values-am\strings.xm
目录 0 2011-12-06 10:29 android-platform_packages_apps_packageinstaller-668cc01\res\values-ar\
文件 8022 2011-12-06 10:29 android-platform_packages_apps_packageinstaller-668cc01\res\values-ar\strings.xm
............此处省略106个文件信息
相关资源
- android 自定义相机拍照
- 免费 android 应用 源代码——记事本
- android 美食天下源码 googlemap
- 极客学院安卓Android全套最新视频教程
- android 版贪吃蛇源码_课程设计
- Android 躲避球
- Android 堆房子简单小游戏
- Qt(5.9) for Android(6.0) 调用JNI接口
- AndroidStudio通过蓝牙连接绘制实时温度
- 《Android Studio应用程序设计》第2版例
- 安卓获取手机加速度传感器并存储
- Android外卖APP
- 基于android平台的校园社交app的设计与
- android火车购票系统登录页面
- Android_Build_Environment_on_Ubuntu_14.04_64-b
- Android项目实战
- Android简单日记本源码
- Android 使用OkHttp3报错处理
- Android家庭理财通源码
- Android安卓开发全套112GB教程很全.txt
- Android studio写的页面滑动
- 基于Android开发的扫雷小游戏
- Android仿照微信App功能代码
- Android大作业
- android-x86_64-7.1-r2.isoandandroid-x86_64-8.1
- usb-serial-for-android
- News_AndroidStudio源代码
- 微信APP支付服务端和Android 端详解及其
- websocket 依赖包,android和java都可以
- android简单音乐播放器源码
评论
共有 条评论