随笔分类 -  android

涉及开放方面的心得。
摘要:阅读 http://developer.android.com/training/best-ux.html关于怎么使用swipe views。首先要有个布局:这里有两种类可以继承实现pagerview。FragmentPagerAdapterThis is best when navigating between sibling screens representing a fixed, small number of pages.FragmentStatePagerAdapterThis is best for paging across a collection of objects fo 阅读全文
posted @ 2013-11-09 22:22 yutoulck 阅读(322) 评论(0) 推荐(0)
摘要:阅读:http://developer.android.com/training/scheduling/index.html让屏幕常亮:public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); getWindow().addFlags(WindowManager.La... 阅读全文
posted @ 2013-11-09 11:16 yutoulck 阅读(353) 评论(0) 推荐(0)
摘要:阅读:http://developer.android.com/training/load-data-background/index.html我真的发现官方提供了好多异步操作的东西,例如这个教程里面的CursorLoader。它的特点就是,数据改变的时候,能够自动更新吧,不过你也要自己继承接口并且重写初始化、读取结束、读取刷新等方法,没什么好讲的,官方的例子很清晰可以自己去看。 阅读全文
posted @ 2013-11-09 11:00 yutoulck 阅读(163) 评论(0) 推荐(0)
摘要:阅读:http://developer.android.com/training/run-background-service/index.htmlThe IntentService class provides a straightforward structure for running an operation on a single background thread. This allows it to handle long-running operations without affecting your user interface's responsiveness. 阅读全文
posted @ 2013-11-09 10:45 yutoulck 阅读(282) 评论(0) 推荐(0)
摘要:阅读:http://developer.android.com/training/basics/network-ops/index.html首先,声明权限检测网络情况:public void myClickHandler(View view) { ... ConnectivityManager connMgr = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo networkInfo = connMgr.getActiveNetworkInfo(... 阅读全文
posted @ 2013-11-07 22:27 yutoulck 阅读(203) 评论(0) 推荐(0)
摘要:官方文档 http://developer.android.com/reference/android/os/Handler.html 有进行解释其实我本身很好奇asynctask是怎么实现的。A Handler allows you to send and process Message and Runnable objects associated with a thread's MessageQueue. Each Handler instance is associated with a single thread and that thread's message q 阅读全文
posted @ 2013-11-07 21:55 yutoulck 阅读(162) 评论(0) 推荐(0)
摘要:阅读:https://developer.android.com/training/animation/index.html接下来学学怎么自定义动画。首先学的是渐变,效果打开https://developer.android.com/training/animation/crossfade.html 就能看到了。在这里假设有两个页面交错渐变替换。首先,先获得两个view的引用,然后将要通过渐变显示的view隐藏,然后通过res文件的value来获得动画显示时间:public class CrossfadeActivity extends Activity { private View m... 阅读全文
posted @ 2013-11-05 21:26 yutoulck 阅读(214) 评论(0) 推荐(0)
摘要:阅读:https://developer.android.com/training/graphics/opengl/environment.html接下来学学怎么使用OpenGL。首先,在manifest里声明:还要声明支持,不支持的手机不会运行你的程序:代码:public class OpenGLES20 extends Activity { private GLSurfaceView mGLView; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(save... 阅读全文
posted @ 2013-11-05 20:11 yutoulck 阅读(198) 评论(0) 推荐(0)
摘要:阅读:https://developer.android.com/training/displaying-bitmaps/index.htmlBitmap非常消耗内存,因此学会怎么处理它非常重要。有几点需要注意:1、安卓为每个系统分配16MB的内存使用,但这并不是一定的,有些限制会高点。2、Bitm... 阅读全文
posted @ 2013-11-05 16:53 yutoulck 阅读(270) 评论(0) 推荐(0)
摘要:阅读:https://developer.android.com/training/camera/index.html先学学怎么从相机获取相片。首先要有权限: ...private void dispatchTakePictureIntent(int actionCode) { Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); startActivityForResult(takePictureIntent, actionCode);}//查询是否有程序能够照相public ... 阅读全文
posted @ 2013-11-04 21:00 yutoulck 阅读(229) 评论(0) 推荐(0)
摘要:阅读:https://developer.android.com/training/managing-audio/index.html系统将音频流分为了很多种:stream for playing music, alarms, notifications, the incoming call ringer, system sounds, in-call volume, and DTMF tones.默认情况下,音量调整按钮控制当前正在活动的音频流。setVolumeControlStream(AudioManager.STREAM_MUSIC);使用上面的方法,就能让物理按键对当前声明的音频流 阅读全文
posted @ 2013-11-04 20:32 yutoulck 阅读(302) 评论(0) 推荐(0)
摘要:阅读:https://developer.android.com/training/basics/intents/index.htmlImplicit intents指的是你没有明确指明哪个程序来启动,只是告诉了系统你的Action或者其他数据就行了,一般还带有Data。Uri number = Uri.parse("tel:5551234");Intent callIntent = new Intent(Intent.ACTION_DIAL, number);URI Data 的代码写法.// Map point based on addressUri location 阅读全文
posted @ 2013-11-02 11:43 yutoulck 阅读(261) 评论(0) 推荐(0)
摘要:阅读:https://developer.android.com/training/basics/data-storage/index.htmlSharedPreferences适用于存储少量的键值对数据,由框架管理,可以只供本程序使用也可共享。Note: The SharedPreferences APIs are only for reading and writing key-value pairs and you should not confuse them with the Preference APIs, which help you build a user interface 阅读全文
posted @ 2013-11-02 00:22 yutoulck 阅读(335) 评论(0) 推荐(0)
摘要:阅读:https://developer.android.com/training/basics/fragments/index.html关于低版本兼容Fragment的,V4支持包的Activity使用FragmentActivity,V7的使用ActionBarActivity。文字使用到了自适应,系统会根据屏幕的不同来选择不同的布局文件,所以当你要从代码进行不同的布局的时候,要根据布局文件的某些特征。import android.os.Bundle;import android.support.v4.app.FragmentActivity;public class MainActivi 阅读全文
posted @ 2013-11-01 22:22 yutoulck 阅读(229) 评论(0) 推荐(0)
摘要:阅读:https://developer.android.com/guide/topics/resources/runtime-changes.html前言不再累述,就表达一种情况:有可能在Activity restart的时候,有些数据通过系统自带的onRestoreInstanceState()会有很糟糕的效果并且代价很高,因此你有两种选择:Retain an object during a configuration changeAllow your activity to restart when a configuration changes, but carry a statefu 阅读全文
posted @ 2013-11-01 18:45 yutoulck 阅读(191) 评论(0) 推荐(0)
摘要:阅读:https://developer.android.com/training/basics/activity-lifecycle/index.html这是ACtivity的状态以及各个方法的执行步骤,我们没有必要继承所有的方法,但是,有几个原则必须遵守,那就是:Does not crash if the user receives a phone call or switches to another app while using your app.Does not consume valuable system resources when the user is not activ 阅读全文
posted @ 2013-11-01 17:09 yutoulck 阅读(187) 评论(0) 推荐(0)
摘要:阅读:http://developer.android.com/training/basics/actionbar/index.html对于API11以下的兼容:Update your activity so that it extends ActionBarActivity. For example:public class Main Activit yextends ActionBarActivity{...}In your manifest file, update either the element or individual elements to use one of the.. 阅读全文
posted @ 2013-10-29 21:15 yutoulck 阅读(294) 评论(0) 推荐(0)
摘要:阅读:http://developer.android.com/training/articles/perf-anr.htm总的来说,要避免程序停止响应,就是不要再UI线程里进行工作,如果有需要长时间操作的,例如IO请求,数据库操作,下载等等,应该放在work threak.避免APP无响应的方法,最简便的就是使用AsyncTask。The most effecive way to create a worker thread for longer operations is with the AsyncTask class. Simply extend AsyncTask and imple 阅读全文
posted @ 2013-10-26 14:01 yutoulck 阅读(195) 评论(0) 推荐(0)
摘要:阅读:http://android-developers.blogspot.com/2010/07/multithreading-for-performance.html文章通过一个图像下载器来说明:下载代码:static Bitmap downloadBitmap(String url) { final AndroidHttpClient client = AndroidHttpClient.newInstance("Android"); final HttpGet getRequest = new HttpGet(url); try { HttpRespon... 阅读全文
posted @ 2013-10-26 13:48 yutoulck 阅读(312) 评论(0) 推荐(0)
摘要:阅读(需FQ):http://android-developers.blogspot.com/2012/05/using-dialogfragments.html例子使用了V4支持包。fragment_edit_name.xml 对话框Fragment代码:import android.support.v4.app.DialogFragment;// ...public class EditNameDialog extends DialogFragment { private EditText mEditText; public EditNameDialo... 阅读全文
posted @ 2013-10-26 10:52 yutoulck 阅读(267) 评论(0) 推荐(0)