• 制定一个apk路径 然后跳出安装界面


    制定一个apk的路径 然后跳出界面让用户选择是否安装

    • 我们系统有一个写好的Activity来协助我们完成这一功能
    • 我们来看看它的清单文件
      <?xml version="1.0" encoding="utf-8" ?> 
    - <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.android.packageinstaller">
      <original-package android:name="com.android.packageinstaller" /> 
      <uses-permission android:name="android.permission.INSTALL_PACKAGES" /> 
      <uses-permission android:name="android.permission.DELETE_PACKAGES" /> 
      <uses-permission android:name="android.permission.CLEAR_APP_CACHE" /> 
      <uses-permission android:name="android.permission.READ_PHONE_STATE" /> 
      <uses-permission android:name="android.permission.CLEAR_APP_USER_DATA" /> 
      <uses-permission android:name="android.permission.INTERNET" /> 
      <uses-permission android:name="android.permission.WAKE_LOCK" /> 
      <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" /> 
      <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" /> 
      <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> 
      <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> 
    - <application android:label="@string/app_name" android:icon="@drawable/apk_new">
    - <activity android:name=".PackageInstallerActivity" android:configChanges="orientation|keyboardHidden" android:theme="@style/Theme.Transparent">
    - <intent-filter>
      <action android:name="android.intent.action.VIEW" /> 
      <category android:name="android.intent.category.DEFAULT" /> 
      <data android:scheme="content" /> 
      <data android:scheme="file" /> 
      <data android:mimeType="application/vnd.android.package-archive" /> 
      </intent-filter>
      </activity>
      <activity android:name=".InstallAppProgress" android:configChanges="orientation|keyboardHidden" android:theme="@android:style/Theme.Dialog" /> 
    - <activity android:name=".UninstallerActivity" android:configChanges="orientation|keyboardHidden" android:theme="@style/Theme.Transparent">
    - <intent-filter>
      <action android:name="android.intent.action.VIEW" /> 
      <action android:name="android.intent.action.DELETE" /> 
      <category android:name="android.intent.category.DEFAULT" /> 
      <data android:scheme="package" /> 
      </intent-filter>
      </activity>
      <activity android:name=".UninstallAppProgress" android:configChanges="orientation|keyboardHidden" android:theme="@android:style/Theme.Dialog" /> 
      </application>
      </manifest>

    我们这里使用.PackageInstallerActivity 其他卸载案例可以对照以上清单文件

    Intent intent = new Intent(Intent.ACTION_VIEW);
    //arg0.result 一个File类型          
    
    intent.setDataAndType(Uri.fromFile(arg0.result),"application/vnd.android.package-archive");
                                startActivityForResult(intent, 20);
  • 相关阅读:
    7-30-组队赛
    POJ 3125 Printer Queue
    7-28-比赛
    POJ 3922 A simple stone game
    POJ 1845
    第一次组队训练
    I-number
    Radar Installation
    Robots on a grid(DP+bfs())
    Dividing a Chocolate(zoj 2705)
  • 原文地址:https://www.cnblogs.com/muyuge/p/6152157.html
Copyright © 2020-2023  润新知