//安装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. git无法定位程序输入点libiconv

    使用git clone时,报以下错误: 解决方案: 将git\bin\下的libiconv-2.dll复制到\git\libexec\git-core\下即可

  2. python之路1(初识python)

    python简史: python我认为特性就是简洁,灵活,高效. python重要版本: python1991年问世, python2.4:2004,同年django框架诞生. python2.6:2 ...

  3. Python中MySQLdb模块的安装

    安装 MySQLdb是Python语言访问mysql数据库的一个模块,如果你不确定自己的Python环境中是否已经安装了这个模块,可以打开Python shell,输入import MySQLdb,如 ...

  4. in_array,array_search的使用

    写一个数组里面有小写a-z 大写A-Z 以及数字,把相似的数字和字母都剔除     无论大小写:将括号内的数字剔除(0,o,2,Z,1,i) $arr1 = range("a", ...

  5. Adroid 展开收起效果实现

    Layout <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns ...

  6. 内存屏障 & Memory barrier

    Memory Barrier http://www.wowotech.net/kernel_synchronization/memory-barrier.html 这里面讲了Memory Barrie ...

  7. 关于java序列化中的一个细节

    java序列化机制的可以参考很多资料了,最近在看的时候发现了一些问题. 1. 默认的序列化机制,很多书里讲到序列化类只序列化类名,实例变量,不会实例化类变量(static)和瞬态变量(transien ...

  8. CSS3的基础用法

    CSS3的现状:1.浏览器支持程度差,需要添加私有前缀 2.移动端支持优于PC端 3.不断改进中 4.应用相对广泛 在CSS3中增加新增了许多灵活查找元素的方法,极大的提高了查找元素的效率和精准度.C ...

  9. Vim插件管理器Vundle使用

    参考地址:http://www.linuxidc.com/Linux/2012-12/75684.htm Vundle(Vim bundle) 是一个vim的插件管理器. 其Github地址为: ht ...

  10. es5 and es6

    es5学习地址:http://www.zhangxinxu.com/wordpress/2013/04/es5%E6%96%B0%E5%A2%9E%E6%95%B0%E7%BB%84%E6%96%B9 ...