zoukankan      html  css  js  c++  java
  • android常用的方法

    //安装apk文件 

     private void installAPK(File file) {
      Intent intent = newIntent(Intent.ACTION_VIEW);
      Uri data =Uri.fromFile(file);
      String type ="application/vnd.android.package-archive";
      intent.setDataAndType(data,type);
      startActivity(intent);
     }

     //卸载apk文件

     private void uninstallAPK(String packageName){
      Intent intent = newIntent(Intent.ACTION_VIEW);
      Uri data = Uri.parse("package:"+ packageName);
      intent.setData(data);
      startActivity(intent);
     }


     //编辑图片大小,保持图片不变形。
     public static Bitmap resetImage(Bitmap sourceBitmap,int resetWidth,int resetHeight){
      int width =sourceBitmap.getWidth();
      int height =sourceBitmap.getHeight();
      int tmpWidth;
      int tmpHeight;
      float scaleWidth =(float)resetWidth / (float)width;
      float scaleHeight =(float)resetHeight / (float)height;
      float maxTmpScale = scaleWidth>= scaleHeight ? scaleWidth : scaleHeight;
      //保持不变形
      tmpWidth = (int)(maxTmpScale *width);
      tmpHeight = (int)(maxTmpScale *height);
      Matrix m = new Matrix();
      m.setScale(maxTmpScale,maxTmpScale, tmpWidth, tmpHeight);
      sourceBitmap =Bitmap.createBitmap(sourceBitmap, 0, 0, sourceBitmap.getWidth(),sourceBitmap.getHeight(), m, false);
      //切图
      int x = (tmpWidth -resetWidth)/2;
      int y = (tmpHeight -resetHeight)/2;
      returnBitmap.createBitmap(sourceBitmap, x, y, resetWidth,resetHeight);
     }

    //从SIM卡中获取联系人

    private Cursor getContacts() {
            Uri uri = Uri.parse("content://sim/adn");
            String[] projection = new String[] { "name", "phone" };
            String selection = null;
            String[] selectionArgs = null;
            String sortOrder = null;
            return managedQuery(uri, projection, selection, selectionArgs,sortOrder);
    }

  • 相关阅读:
    C#类中的字段、属性和方法
    Linux下制作Windows启动U盘的工具
    将samba共享目录映射为本地文件夹(百度网盘直接下载到samba共享目录下)
    《怎样编写研究报告》读书笔记0-0
    mcnp的重复探测器单元计数-fmesh卡的介绍
    单能X射线产生方法
    matlab学习之降噪平滑算法
    matlab学习之求解函数的根和极小值
    matlab学习之绘制参数曲线,添加辅助线以及颜色设置
    MC资源整理
  • 原文地址:https://www.cnblogs.com/xilin/p/2620752.html
Copyright © 2011-2022 走看看