Skip to content

Instantly share code, notes, and snippets.

@BodhiHu
Last active August 29, 2015 14:21
Show Gist options
  • Save BodhiHu/890999403c86e2bc77ee to your computer and use it in GitHub Desktop.
Save BodhiHu/890999403c86e2bc77ee to your computer and use it in GitHub Desktop.
Android IQs

Android IQs

Intent

  • <intent-filter>: action, category, data
  • Pending intent, NotificationManager

Activity

  • Activity lifecycle
  • Intent flags/launchMode:standard, singleTop, singleTask, singleInstance
  • best practices for Acti.. and Frag..: use Acti.. to manage Frag...

Fragment

  • lifecycle
  • Fragment transaction

Service

  • IntentService
  • startService, bindService

Background

  • Knowledge of AsyncTask: its dark sides: lifecycle/view reference
  • Looper(message loop)
  • Handler(Looper) -> handleMessage(Message…), obtainMessage(…)
  • handle message on main thread: new Handler(Looper.getMainLooper()) {handleMessage}
  • HandlerThread.getLooper
  • Runnable

UI

  • View: onDraw
  • Layout: onMeasure: setMeasuredDimension, onLayout
  • <declare-stylable>, Context. obtainStyledAttributes
  • onTouchEvent, onInterceptTouchEvent
  • MotionEvent, GestureDetector , OverScroller
  • ValueAnimator, ObjectAnimator
  • RelativeLayout: evenly spacing, what if children is ImageButton
  • Auto complete: AutoCompleteTextView + Loader

Drawable

  • selector: states, fade duration
  • shape: round corder, stroke, solid ...
  • Animation: <set>, <objectAnimator>, <animator>, AnimationUtils.loadAnimation, View.startAnimation

res/layout

  • dp, dip, px, sp(scale independant, for fonts)
  • mdpi : hdpi : xhdpi : xxhdpi : xxxhdpi :: 1 : 1.5 : 2 : 3 : 4
  • launcher icon : 48dp on mobile, 512px on Play store

Style and Themes

  • define style: res/values : <resources> <style name="" parent=“”><item …>…
  • apply theme to application : <application android:theme=“”>…
  • Select theme based on platform: use resource filters: e.g. values-v21

Performance

  • Reuse layout with <include>
  • use <merge> tag
  • in favor of RelativeLayout vs LinearLayout
  • Avoid deep hierarchy
  • Smooth Scrolling: use ViewHolder, use background thread
  • StrictMode
  • ANR: how to avoid

Test

  • Unit tests: Robolectric
  • UI tests: Robotium

Misc

  • Http client: OKhttp
  • EventBus
  • Realm
  • Retrofit for JSON
  • Gson: TypeAdapter
  • 65K limitation
  • Crash report: fabric...
  • Projects, github, stackoverflow

Real World

  • How to implement a Activity/Fragment open-splitting/swipe-back transition animation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment