//安装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(BitmapsourceBitmap,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);
}

禁用后退键

@Override    
public boolean onKeyDown(int keyCode, KeyEvent event) {  
if(keyCode == KeyEvent.KEYCODE_BACK){      
return  true;
}  
return  super.onKeyDown(keyCode, event);

}

Android 中的常用方法的更多相关文章

  1. android开发(32) android 中 actionbar 常用方法。设置标题,隐藏图标等

    设置标题: actionBar.setTitle("关于我们"); 使返回箭头出现 actionBar.setDisplayHomeAsUpEnabled(true); 监听返回按 ...

  2. Android 中常见控件的介绍和使用

    1 TextView文本框 1.1 TextView类的结构 TextView 是用于显示字符串的组件,对于用户来说就是屏幕中一块用于显示文本的区域.TextView类的层次关系如下: java.la ...

  3. Android中SQLite应用详解

    上次我向大家介绍了SQLite的基本信息和使用过程,相信朋友们对SQLite已经有所了解了,那今天呢,我就和大家分享一下在Android中如何使用SQLite. 现在的主流移动设备像Android.i ...

  4. Android中Intent组件详解

    Intent是不同组件之间相互通讯的纽带,封装了不同组件之间通讯的条件.Intent本身是定义为一个类别(Class),一个Intent对象表达一个目的(Goal)或期望(Expectation),叙 ...

  5. Android中SQLite应用详解(转)

    上次我向大家介绍了SQLite的基本信息和使用过程,相信朋友们对SQLite已经有所了解了,那今天呢,我就和大家分享一下在Android中如何使用SQLite. 现在的主流移动设备像Android.i ...

  6. Android中FTP服务器、客户端搭建以及SwiFTP、ftp4j介绍

    本文主要内容: 1.FTP服务端部署---- 基于Android中SwiFTP开源软件介绍: 2.FTP客户端部署 --- 基于ftp4j开源jar包的客户端开发 : 3.使用步骤 --- 如何测试我 ...

  7. Android中滑屏实现----手把手教你如何实现触摸滑屏以及Scroller类详解

    前言:  虽然本文标题的有点标题党的感觉,但无论如何,通过这篇文章的学习以及你自己的实践认知,写个简单的滑屏小 Demo还是just so so的. 友情提示: 在继续往下面读之前,希望您对以下知识点 ...

  8. Android中的几种多线程实现

    有以下几种方式: 1)Activity.runOnUiThread(Runnable) 2)View.post(Runnable) ;View.postDelay(Runnable , long) 3 ...

  9. Android中获取系统内存信息以及进程信息-----ActivityManager的使用(一)

    本节内容主要是讲解ActivityManager的使用,通过ActivityManager我们可以获得系统里正在运行的activities,包括 进程(Process)等.应用程序/包.服务(Serv ...

随机推荐

  1. C#序列化及反序列化Json对象通用类JsonHelper

    当今的程序界Json大行其道.因为Json对象具有简短高效等优势,广受广大C#码农喜爱.这里发一个序列化及反序列化Json对象通用类库,希望对大家有用. public class JsonHelper ...

  2. Boost学习笔记(六) progress_display注意事项

    progress_display可以用作基本的进度显示,但它有个固有的缺陷:无法把进度显示输出与程序的输出分离. 这是因为progress_display和所有C++程序一样,都向标准输出(cout) ...

  3. R12供应商地点层付款方法SQL

    --R12供应商地点层付款方法SQL:SELECT ipmv.payment_method_name     , ipmv.payment_method_code     , 'N' primary_ ...

  4. 微信小程序-登陆、支付、模板消息

    wx.login(OBJECT) 调用接口获取登录凭证(code)进而换取用户登录态信息,包括用户的唯一标识(openid) 及本次登录的 会话密钥(session_key).用户数据的加解密通讯需要 ...

  5. BirdError

    //#include<curses.h> #include<stdlib.h> #include<signal.h> #include<time.h> ...

  6. 如何自定义ReportDesigner的向导界面(WIN)

    https://www.devexpress.com/Support/Center/Example/Details/T140683

  7. Ubuntu 和 Redhat / Fedora 服务管理命令对比表(附Fedora16新的服务管理工具systemctl )

    以 apache/httpd 服务作为例子 任务 Red Hat / Fedora Ubuntu Ubuntu (with sysv-rc-conf or sysvconfig) 立即启动/停止某服务 ...

  8. left和offsetLeft

    left: 1.当该对象的定位position为absolute时left是相对于拥有定位属性(position的值为默认值"static"时除外)的父级对象的左边距. 例1:当父 ...

  9. spice命令使用

    spicec.exe -h 192.168.1.1 -p 5912 -w 主机 物理机IP 端口号 主机

  10. FirstUniqueCharacterInString

    Given a string, find the first non-repeating character in it and return it's index. If it doesn't ex ...