深入理解ANDROID消息处理系统——LOOPER、HANDLER、THREAD

Posted by & filed under Android, Java.

(自) Activity,Service属于主线程,在主线程中才能更新UI,如toast等。其他线程中不能直接使用,这时可以使用Handler来处理,Handler可以在Activity和Service中。

关于在非UI线程中进行UI操作会出现问题: Can’t create handler inside thread that has not called Looper.prepare()

这时有两种方式来解决:

(一)在该非UI线程中创建消息队列(因为创建的工作线程默认是没有消息循环和消息队列的),Looper.prepare();…..;Looper.loop(); 

 newThread() { 

public void run() {

 Looper.prepare(); //创建消息队列

 todo(); 

 Looper.loop();//进入消息循环

}}.start();

(二)运用Handler机制:

package com.simon;

import android.app.Activity; 
import android.os.Bundle; 
import android.os.Message; 
import android.util.Log; …

Supporting Multiple Screens

Posted by & filed under Android.

Android runs on a variety of devices that offer different screen sizes and densities. For applications, the Android system provides a consistent development environment across devices and handles most of the work to adjust each application’s user interface to the …

Set the absolute position of a view in Android

Posted by & filed under Android.

Is it possible to set the absolute position of a view in android? (I know that there is an AbsoluteLayout, but it’s deprecated…) Lets say I have a screen 240x320px, and I want to put an ImageView which is 20x20px …

搭建 Android 开发环境

Posted by & filed under Android.

http://www.cnblogs.com/cheney23reg/archive/2010/08/19/1803474.html

这几天看到了几个不错的Android 上的应用,心痒痒,也想探索一下Android 的世界,于是决心学习一下Android 的开发技术。 :)

 

接下来当然是搭建Android 的开发环境啦,步骤如下:

 

1. 安装JDK。注意这里只是安装JRE是不行的,需要安装JDK
笔者是去 http://www.oracle.com/technetwork/java/javase/downloads/index.html 下载了 JDK 6 Update 20。
注: 根据www.eclipse.org的官方信息,在windows 平台上安装了JDK 6 Update 21,然后运行Eclipse Helios (3.6) 会出现 crashing,需要进行一些设置 ( http://wiki.eclipse.org/FAQ_How_do_I_run_Eclipse%3F#Oracle.2FSun_VM_1.6.0_21_on_Windows )

Windows 7:
1) 双击 jdk-6u20-windows-i586.exe …

APK文件反编译 查看源代码 相关工具下载

Posted by & filed under Android.

反编译APK文件需要dex2jar和jd-gui这两个工具,我已经打包了,可以本文底部下载。
第一步、下载我提供的工具后解压。
第二步、把目标APK文件扩展名改为zip,用WINRAR或者其他压缩软件打开,解压其中的classes.dex,并放到上面第一步解压出来的工具目录里
如图:

第三步、双击执行目录中的First.bat,会在当前目录生成一个classes.dex.dex2jar.jar文件
第四步、打开jd-gui.exe,File-Open File找到刚才生成的classes.dex.dex2jar.jar文件
OK,现在你可以看到Java源代码了.
如果需要查看APK中的XML文件以及图片,可以用apktool,这里也一并附上,已经放进压缩包里了,上面的截图没有,使用方法:

apktool.bat d apk名 解压目录

工具下载:
apkdecode (35)

or ApkDecode

From:http://www.pocketdigi.com/20110905/459.html

Android Learn Note

Posted by & filed under Android.

1.Android 四大天王:Activity(程序的界面),Intent(数据传输),Service(服务),Content Provider(数据存放)

2.产生APK安装包:Android Manifest里的Export

3.Activity的生命周期:onCreate->onStart->onResume->onPause->Other Activity’s onCreate,onStart,onResume-> onStop()(完全不可见后,才会调用,如第二个ACtivity是Dialog,则不发生),再按Back后,Other Activity’s onPause ->First Activity’s onStart->onResume, Other Activity’s onStop() , onDestroy()(再起来时一定要再有onCreate)

4. A task is a stack of Activities.…