美文网首页
Android分享/卸载应用/查看应用权限

Android分享/卸载应用/查看应用权限

作者: M_天河 | 来源:发表于2020-09-21 15:20 被阅读0次
    1. 分享应用
    public void sendApp(String srdir){
                  Uri v2 = Uri.fromFile(new File(srdir));
                  Intent v1 = new Intent("android.intent.action.VIEW");
                  v1.setDataAndType(v2,"text/plain");
                  v1.setFlags(67108864);
                  try {
                         this.startActivity(v1);
                  } catch (Exception e) {
                         Toast.makeText(getAppListActivity.this, "error x 1", 0).show();
                  }
           }
    
    1. 卸载应用
    public void uninstallApp(String pkn){
             Uri v1 = Uri.parse("package:" + pkn);
             Intent v0 = new Intent("android.intent.action.DELETE");
             v0.setData(v1);
             this.startActivity(v0);
    }
    
    1. 查看权限
    private void getAppPermission(String pkn){
                  PackageManager pm = getPackageManager();
                  try {
                         PackageInfo pack = pm.getPackageInfo(pkn, PackageManager.GET_PERMISSIONS);
                         String[] permissionStrings = pack.requestedPermissions;
                         String permissionReq = "";
                         for(String permissionString : permissionStrings){
                               permissionReq = permissionReq + permissionString + "\n";
                         }
                         Toast.makeText(getAppListActivity.this, permissionReq, 0).show();
                  } catch (Exception e) {
                         e.printStackTrace();
                  }                    
    }

    相关文章

      网友评论

          本文标题:Android分享/卸载应用/查看应用权限

          本文链接:https://www.haomeiwen.com/subject/sqonlktx.html