Your SlideShare is downloading. ×
Android mypractices
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Saving this for later?

Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime - even offline.

Text the download link to your phone

Standard text messaging rates apply

Android mypractices

632
views

Published on

Talk from Android Developer Days and Istanbul GTUG (GDG) meetings.

Talk from Android Developer Days and Istanbul GTUG (GDG) meetings.

Published in: Technology, Art & Photos

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
632
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
16
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Android Best Practices Murat Yener, eterationWednesday, May 23, 12
  • 2. Android Best Practices Murat Yener, eterationWednesday, May 23, 12
  • 3. Android Best Practices Murat Yener, eterationWednesday, May 23, 12
  • 4. Android Best Practices Murat Yener, eterationWednesday, May 23, 12
  • 5. Why am I doing this talk? Get well soon Alain!!Wednesday, May 23, 12
  • 6. Alternatives • Make me look like Alain? • or just let me do another talk...Wednesday, May 23, 12
  • 7. Alternatives • Make me look like Alain? • or just let me do another talk...Wednesday, May 23, 12
  • 8. pointed ears rounded ears science officer developer half human - half vulcan half flex - half java trying to understand human trying to understand objective-c nature behaviourWednesday, May 23, 12
  • 9. how to develop? • Android SDK: Java, capable, resources, easy • Android NDK: Most capable but?? • Adobe AIR: easy XML+AS but??!! • runtime, memory, new apis • Web+JSWednesday, May 23, 12
  • 10. SDK • Activities • Services • Widgets • Intents&Broadcasts • PreferencesWednesday, May 23, 12
  • 11. Going to Market • Silence my Phone vs Shake to Answer • idea • target devices • code right • let users communicate with you • respond back... (even when you don’t care)Wednesday, May 23, 12
  • 12. Targeting all devices • Matching everyone is winner! • bug!! v5 thinks its v6 • canary patternWednesday, May 23, 12
  • 13. Targeting all devices • Matching everyone is winner! • bug!! v5 thinks its v6 • canary patternWednesday, May 23, 12
  • 14. Targeting all Devices • Never, ever manipulate images!!! • Ok, only if you must... • nine-patchesWednesday, May 23, 12
  • 15. Targeting all Devices • Never, ever manipulate images!!! • Ok, only if you must... • nine-patchesWednesday, May 23, 12
  • 16. Targeting all Devices • Never, ever manipulate images!!! • Ok, only if you must... • nine-patchesWednesday, May 23, 12
  • 17. Targeting all Devices • Never, ever manipulate images!!! • Ok, only if you must... • nine-patchesWednesday, May 23, 12
  • 18. app fitness • Collect you own trash! • Services, unregister whatever registered • Images: image=null != image.recycle(); • favor primitives over objects • BUT!! avoid autoboxing • keep in mind Generics only work for objects • size checks on loopsWednesday, May 23, 12
  • 19. things that take time • Specially when network is involved • Never, ever lock up UI thread!!! • Painless threading: Use AsyncTasks • Let user know: ToasterWednesday, May 23, 12
  • 20. Responsive UI • use as little as possibles views in views: slower layout, drawing, startup time... • cut down view hierarchy: memory, slow, StackOverFlowExceptionWednesday, May 23, 12
  • 21. Less Views?? • use Merge as root tag for components • use RelativeLayout instead of LinearLayoutWednesday, May 23, 12
  • 22. DI in Android!! class AndroidWay extends Activity {     TextView name;     ImageView thumbnail;     LocationManager loc;     Drawable icon;     String myName;     public void onCreate(Bundle savedInstanceState) { • findViewById is         super.onCreate(savedInstanceState);         setContentView(R.layout.main);         name      = (TextView) findViewById(R.id.name);         thumbnail = (ImageView) findViewById(R.id.thumbnail);         loc       = (LocationManager) expensive! getSystemService(Activity.LOCATION_SERVICE);         icon      = getResources().getDrawable(R.drawable.icon);         myName    = getString(R.string.app_name); • either use it once         name.setText( "Hello, " + myName );     } } class RoboWay extends RoboActivity { or... RoboGuice!!     @InjectView(R.id.name)             TextView name;     @InjectView(R.id.thumbnail)        ImageView thumbnail;     @InjectResource(R.drawable.icon)   Drawable icon;     @InjectResource(R.string.app_name) String myName;     @Inject                            LocationManager loc;     public void onCreate(Bundle savedInstanceState) {         super.onCreate(savedInstanceState);         setContentView(R.layout.main);         name.setText( "Hello, " + myName );     } }Wednesday, May 23, 12
  • 23. ...Wednesday, May 23, 12
  • 24. AndroidAnnotations @EActivity(R.layout.translate) // Sets content view to R.layout.translate public class TranslateActivity extends Activity { @ViewById // Injects R.id.textInput EditText textInput; @ViewById(R.id.myTextView) // Injects R.id.myTextView TextView result; @AnimationRes // Injects android.R.anim.fade_in Animation fadeIn; @Click // When R.id.doTranslate button is clicked void doTranslate() { translateInBackground(textInput.getText().toString()); } @Background // Executed in a background thread void translateInBackground(String textToTranslate) { String translatedText = callGoogleTranslate(textToTranslate); showResult(translatedText); } @UiThread // Executed in the ui thread void showResult(String translatedText) { result.setText(translatedText); result.startAnimation(fadeIn); }Wednesday, May 23, 12
  • 25. Wednesday, May 23, 12
  • 26. </presentation> murat@muratyener.com twitter.com/yenerm devchronicles.com blogs.eteration.com/blogsWednesday, May 23, 12