//安装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. Navicat for mysql 远程连接 mySql数据库10061、1045错误

    原文地址:http://www.111cn.net/database/mysql/46377.htm 有朋友可能会碰到使用Navicat for mysql 远程连接 mySql数据库会提示10061 ...

  2. VBS整人代码

    记得刚开始学VB脚本语言的时候,写了一段调用系统进程的代码,挺好的: dim wshif msgbox("笑笑很帅",vbyesno,"请回答是或否")=vby ...

  3. synergy 两台Windows电脑配置过程

    Synergy 介绍 软件作用 Synergy 两台独立电脑,共享一套鼠标和键盘的工具, 软件原理(我自己想的) 保证两台电脑在一个局域网内,可以相互Ping通的电脑(这样才能直接通过TCP连接) 将 ...

  4. 写在OpenFire

    首先,确保你已经关掉了openfire打开终端 (在应用程序-->实用工具-->)输入以下命令sudo rm -rf /Library/PreferencePanes/Openfire.p ...

  5. php保留键随机打乱数组顺序

    最近遇到一个需求,把一个数组随机打乱顺序,我们可以用php的shuffle函数,但是这个函数会把数组的键清空建立新的键,那么我们若想保留键只需要利用shuffle函数再做一下处理就可以了.可以自定义一 ...

  6. Install Nvidia driver 367.18 or later

    Install Nvidia driver 367.18 or later from ppa:graphics-drivers/ppa as follows: sudo add-apt-reposit ...

  7. Asp.NET利用ClientScript.RegisterStartupScript("")的同学,请注意!

    如果你想要在aspx.cs 文件用利用 ClientScript.RegisterStartupScript(""); 方法动态在DOM中执行脚本(比如想要将后置代码中的验证结果信 ...

  8. CSS伪类和伪元素

    一.伪类 CSS伪类用于向某些选择器添加特殊的效果,在W3规范中,CSS伪类有如下几个: CSS2.1 :active:向被激活的元素添加样式(激活是指点击鼠标那一下) :focus:向拥有键盘输入焦 ...

  9. OSChina码云试用

    首先在码云申请账户. 从 http://git-scm.com/download  下载window版的客户端.下载好,一步一步安装即可. $git config --global user.name ...

  10. SQL Server Reporting Service(SSRS) 第四篇 SSRS 用法总结

    1. 如何让表头在每页显示(译) A. 打开高级模式:  在分组栏中点击Column Goups右侧的箭头选择高级模式; B. 找到第一个Static组 在Row Groups区域中(注意不是Colu ...