随笔分类 -  android

摘要:intent-filter主要通过三种(action category data)来过滤intent1、action一个intent 只包含一个action (可以没有),但是 一个filter可以有多个action(必须有一个,否则阻塞所有intent)并且只需要有一个action与intent中的action匹配就可以通过2、category一个intent 可以包含多个category(可以没有),一个filter也可以包含多个category,但是intent中的category必须是filter中的category的子集才可以通过。3、data(scheme path(pathPre 阅读全文
posted @ 2013-05-02 19:47 lipeil 阅读(318) 评论(0) 推荐(0) 编辑
摘要:1、WebViewClient就是帮助WebView处理各种通知、请求事件的,具体来说包括:onLoadResource 、onPageStart 、onPageFinish 、 onReceiveError 、onReceivedHttpAuthRequest2、WebChromeClient是辅助WebView处理Javascript的对话框,网站图标,网站title,加载进度等 onCloseWindow(关闭WebView) 、onCreateWindow() 、onJsAlert (WebView上alert是弹不出来东西的,需要定制你的WebChromeClient处理弹出) .. 阅读全文
posted @ 2013-05-02 15:30 lipeil 阅读(407) 评论(0) 推荐(0) 编辑
摘要:1. onMeasurea. 属于View的方法,用来测量自己和内容的来确定宽度和高度b. view的measure方法体中会调用onMeasure2. onLayouta. 属于ViewGroup的方法,用来为当前ViewGroup的子元素的位置和大小b. View的layout方法体中会调用onLayout3.onMeasure在onLayout之前调用4. 设置background后,会重新调用onMeasure和onLayout参考:http://gundumw100.iteye.com/blog/1025196 阅读全文
posted @ 2013-04-11 00:11 lipeil 阅读(572) 评论(0) 推荐(0) 编辑
摘要:1、调用draw() 绘制背景2、draw 中 如果有内容调用 onDraw()方法绘制内容3、draw 中 调用 dispatchDraw()方法分配给子控件进行绘制。4、dispatchDraw() 时,如果该空间为容器控件(ViewGroup子类),则会调用drawChild()绘制子类控件。5、drawChild 中会回到draw去绘制子类一般来说自定义控件需要重写ondraw 或者 ondispatchDraw.参考链接:http://blog.csdn.net/mryangbo001/article/details/8469800 阅读全文
posted @ 2013-04-10 23:56 lipeil 阅读(240) 评论(0) 推荐(0) 编辑
摘要:android系统中的每个View的子类都具有下面三个和TouchEvent处理密切相关的方法:1)public boolean dispatchTouchEvent(MotionEvent ev)这个方法用来分发TouchEvent2)public boolean onInterceptTouchEvent(MotionEvent ev) 这个方法用来拦截TouchEvent ,仅ViewGroup及其子类有3)public boolean onTouchEvent(MotionEvent ev) 这个方法用来处理TouchEvent当TouchEvent发生后,1、首先Activity将T 阅读全文
posted @ 2013-04-10 22:58 lipeil 阅读(250) 评论(0) 推荐(0) 编辑
摘要:进程间通信主要包括:1、管道2、系统IPC(消息队列、信号量、共享存储)3、套接字管道包括三种:1、普通管道PIPE:通常有两种限制,一是半双工,只能单向传输;二是只能在父子或者兄弟进程间使用。2、流管道s_pipe:去除了第一种限制,可以双向传输。3、命名管道name_pipe:去除了第二种限制,可以在不相关的进程间通讯。android采用进程间通信机制:BinderBinder优势: 管道 System V IPC 套接字 BinderC|S通信 N N ... 阅读全文
posted @ 2013-04-10 11:34 lipeil 阅读(398) 评论(0) 推荐(0) 编辑
摘要:1、添加Camera权限2、判断是否支持变焦public boolean isSupportZoom() { boolean isSuppport = true; if (mCamera.getParameters().isSmoothZoomSupported()) { isSuppport = false; } return isSuppport; }3、修改焦距public void setZoom() { if (mIsSupportZoom) { ... 阅读全文
posted @ 2013-03-04 11:17 lipeil 阅读(5214) 评论(0) 推荐(0) 编辑
摘要:1、解决方法:在相应的Activity配置中加上android:configChanges="orientation|keyboardHidden"设置实际问题:锁屏、解锁时Activity 重启,在之上添加的 Fragment 也会被多次创建,导致视图混乱。相关链接:http://my.oschina.net/u/614511/blog/76444 阅读全文
posted @ 2013-01-04 10:17 lipeil 阅读(506) 评论(0) 推荐(0) 编辑
摘要:protected void replaceFragment(Fragment fragment , boolean init) { FragmentManager fragmentManager = this.getSupportFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); if(init) { fragmentTransaction.add(R.id.main_... 阅读全文
posted @ 2012-12-27 14:44 lipeil 阅读(1695) 评论(1) 推荐(0) 编辑
摘要:1、Camera 可以实现3D平移、旋转等特效:2、它并不是以Galley视图所在坐标系,而是在其自身的坐标系3、例如,其绕Y轴旋转,实际是在matrix 对应视图的左边旋转;平移也是同样。package com.view;import android.content.Context;import android.graphics.Camera;import android.graphics.Matrix;import android.util.AttributeSet;import android.view.View;import android.view.animation.Transfo 阅读全文
posted @ 2012-12-21 11:10 lipeil 阅读(1755) 评论(0) 推荐(0) 编辑
摘要:1、 SlidingDrawer 抽屉控件 <SlidingDrawer android:id="@+id/sliding" android:layout_width="match_parent" android:layout_height="match_parent" android:content="@+id/home_water" // 指定内容控件id android:handle="@+id/handler" // 指定handler 控件id android:ori... 阅读全文
posted @ 2012-12-13 14:48 lipeil 阅读(580) 评论(0) 推荐(0) 编辑
摘要:private void showPopupView() { if (mPopupWindow == null) { View view = getLayoutInflater().inflate(R.layout.newest_layout, null); mPopupWindow = new PopupWindow(view, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); mPopupWindow.setFocusable(tr... 阅读全文
posted @ 2012-12-13 14:26 lipeil 阅读(2404) 评论(0) 推荐(0) 编辑
摘要:1、一种方法是将其中一个项目(含有res资源)打包成jar包,另一个项目来引用。但是多次尝试总是发现找不到资源2、第二种方法参考http://www.cnblogs.com/vaiyanzi/archive/2012/02/20/2358910.html将其中一个项目设置为引用的库,在另一个项目中添加这个库引用。简单点的做法是在被引用项目A中的project-properties 中添加一行 android.library=true在引用的项目B 中添加android.library.reference.1=../A其中 1表示引用的包的序号,“../A”表示 引用的项目的路径 阅读全文
posted @ 2012-12-11 17:44 lipeil 阅读(6460) 评论(0) 推荐(0) 编辑
摘要:1、添加权限(必须)<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />2、添加快捷键 public static void setupShortcut(Activity activity) { Intent shortcutIntent = new Intent(activity, MainActivity.class); //启动首页(launcher Activity) Intent intent = new Intent("com. 阅读全文
posted @ 2012-11-14 10:55 lipeil 阅读(645) 评论(0) 推荐(0) 编辑
摘要:1、定义属性名称、类型需要再res/values/attrs.xml 文件中配置<?xml version="1.0" encoding="utf-8"?><resources> <declare-styleable name="InputView"> <attr name="buttonNum" format="integer"/> </declare-styleable></resources>2、在自定义控件的xml配 阅读全文
posted @ 2012-10-16 10:33 lipeil 阅读(358) 评论(0) 推荐(0) 编辑
摘要:1、实现UncaughtExceptionHandler,在方法uncaughtException中处理没有捕获的异常。2、继承Application ,在其中调用Thread方法setDefaultUncaughtExceptionHandler,来捕获异常代码:public class MyApplication extends Application { public void onCreate() { super.onCreate(); GlobalException handler = GlobalException.getInstance(... 阅读全文
posted @ 2012-10-15 10:21 lipeil 阅读(1543) 评论(0) 推荐(0) 编辑
摘要:public static final int FLAG_SHOW_LIGHTS = 0x00000001;//控制闪光 public static final int FLAG_ONGOING_EVENT = 0x00000002;//将flag设置为这个属性那么通知就会像QQ一样一直在状态栏显示 public static final int FLAG_INSISTENT = 0x00000004; //重复发出声音,直到用户响应此通知 public static final int FLAG_ONLY_ALERT_ONCE ... 阅读全文
posted @ 2012-10-15 09:19 lipeil 阅读(4275) 评论(0) 推荐(0) 编辑
摘要:1、监听广播缺点,因为优先级的原因可能接收不到。代码:public static final String TAG = "ImiChatSMSReceiver"; public static final String SMS_RECEIVED_ACTION = "android.provider.Telephony.SMS_RECEIVED"; public void onReceive(Context context, Intent intent) { if (intent.getAction().equals(SMS_RECEIVED_ACTION) 阅读全文
posted @ 2012-09-24 18:11 lipeil 阅读(4187) 评论(0) 推荐(0) 编辑
摘要:join的用法:join是非静态的方法 有线程 threadA 与threadB,同时运行 1、如果在 threadA中调用自身的join方法,则threadA被堵塞,即使threadB结束,threadA也不会解除堵塞。//threadA堵塞threadA,直到threadA结束,发生死锁 2、如 阅读全文
posted @ 2012-09-07 22:53 lipeil 阅读(929) 评论(0) 推荐(1) 编辑
摘要:四种launchMode分别是 1、standard 2、singleTop 3、singleTask 4、singleInstancestandard :android 默认的启动模式,不管在task中有没有该activity的实例,都会new 一个新的实例。singleTop:只有该activity的实例在task(stack)顶部,才不同重复创建,否则还是需要创建一个新的activity。(只重用stack|task顶部的activity实例)singleTask:如果task中存在 activity的实例,则直接使用该实例 ,并将之上的其他activity实例清除,使该activity 阅读全文
posted @ 2012-09-07 22:15 lipeil 阅读(228) 评论(0) 推荐(0) 编辑