读书人

Android app项目跟开发总结

发布时间: 2012-09-08 10:48:07 作者: rapoo

Android app项目和开发总结

?

关键字: android app,?android develop, android summary

???? 从2010.04启动该项目到现在完成主要功能模块,分享一下开发历程和注意事项。?
???? 开发环境: ubuntu7.10 + eclipse 3.5 + sdk
???? 下面是开发总结:?

    基于源码级的SDK以及SDK升级注意事项熟悉其如何做资源国际化熟悉其如何支持不同屏幕大小,不同density介质 熟悉其主要的API以及支持的最低版本和不被再支持的API了解其分层架构升级SDK确保该平台支持相关的cglib版本(否则要升级ubuntu) 简单容行的方式是remove ~/.android下的相关东西,remove先前的相关版本,再升级部分Resources(如strings中有%s的)可能需要修改才能适应新的版本新的sdk里可能不包括老的如2.01版本Emulator & Mobile用adb shell 操作emulatorhttp://www.iteye.com/topic/260042push / pull file in emulatorEclipse->window->Show View->File Explorer-> pull a file?from the device(or push a file onto the device)用 real mobile连接usb来直接测试(mobile 必须设置为develop/debug mode)http://dimitar.me/how-to-connect-your-android-phone-to-ubuntu-to-do-developmenttestinginstallations-or-tethering/emulator更能用于性能测试,功能测试。而mobile更适合触摸操作测试和一些View的真实展现测试屏幕大小适应测试(枚举大,中,小),屏幕方向(枚举横,竖屏),任务切换测试内存适应只能在mobile上做测试系统配置项SharedPreferences存储位置及如何在emulator上手动修改找到存储位置: \data\data\your package dir\shared_prefs\your xml files按照上面的pull/push the fileSQLite(sqlite3)默认存储位置:\data\data\your package dir\databases\your database name按照上面的用adb shell 操作emulator做部分database的设计和数据更新设计版本更新和升级Other File I/Oassert下文件读取文件权限以及读写解读AndroidManifest.xmlapplication/process标识最开始启动的activityactivity栈的形式(指定taskAffinity&launchMode="singleTask"),而且转向一个新的activity是用intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT)的形式需要的权限部分支持的最低版本基于View,Context,Manager的开发系统View & Layout(Layout也是View)用View本身来做其他Layout间的一个分隔常用的View&Layout: ListView,ScrollView,RelativeLayout,TableLayout设计常用的style/theme用到的Drawable: http://idunnolol.com/android/drawables.html 常用的图片操作指定颜色的渲染(setColorFilter) 剪裁自定义View & Layout
    public class TouchListView extends ListView {  public TouchListView(Context context, AttributeSet attrs, int defStyle) {} }?
    public class Toolbar extends LinearLayout {    public Toolbar(final Context context) {super(context);}public Toolbar(final Context con, AttributeSet attrs) {  }}
    ?Application,Activity,Service,View,IntentApplication,Activity,Service与Context的关系View与Context的关系用Application来做Activity,Service,View间的全局变量(这比自己用Singleton实现好)用工厂模式使用Intent做activity跳转sendBroadcast(实时数据交换可借助Thread+WindowManager 、PackageManager 等的使用网络IOjava.netandroid.netorg.apache.http如果没有让他在AsyncTask中操作,则他的TimeOut设置必须少于5秒(为ANR等待时间)java.net.UnknownHostException如果发生在emulator,可参考: http://blog.csdn.net/abby_dcy/archive/2010/08/09/5798945.aspx如果发生在mobile,则一般是DNS解析问题,要么允许用户再重试操作,要么把Host的域名改为public ip address绘图部分在View上绘图只在原来View上加边框等
    @Override    protected void dispatchDraw(Canvas canvas) {}
    ?自定义View
    @Overrideprotected void onDraw(Canvas canvas) {
    ?在Bitmap上绘图
    Bitmap result = Bitmap.createBitmap(48,48, Config.ARGB_8888);           Canvas canvas =  new   Canvas(result);  ...canvas.drawBitmap(result, rect, rect, paint);
    ?动画帧动画控制侦速率在25FPS以让其更流畅?渐变动画平移缩放旋转透明ANR构建消息以及消息循环处理Handler使用AsyncTaskException &?UncaughtException使用UncaughtExceptionHandler引入第三方jar以及与其他app共享数据通过add user library方式添加第三方jarContent Provider的使用?性能优化/调优?基于View的优化http://dl.iteye.com/topics/download/774b3e9e-1c48-33bd-bc9d-5c27da998181 代码级的规范Method级的调优Method Profiling(如果直接usb连接mobile,需要root权限作此项)GC分析 使用Allocation Tracker
10 楼 fkpwolf 2011-01-22 这总结偏向于细节了,流水账

读书人网 >Android

热点推荐