16

Click here to load reader

FITC 2012 Jellybean Tips and Tricks

Embed Size (px)

DESCRIPTION

FITC 2012 Jellybean Tips and Tricks

Citation preview

Page 1: FITC 2012 Jellybean Tips and Tricks

Faisal Abid @faisalabidwww.faisalabid.com

ANDROID AND JELLYBEAN TIPS AND TRICKS

Page 2: FITC 2012 Jellybean Tips and Tricks

Faisal Abid @faisalabidwww.faisalabid.com

• Software developer working with Android since

the beta days

• Started working in Node.js and Coffeescript for

the past year.

• Software Engineer at Kobo

• Co-Author Flex 3 in Action

• Entrepreneur, Author, Teacher & Developer

WHO AM I?

Page 3: FITC 2012 Jellybean Tips and Tricks

Faisal Abid @faisalabidwww.faisalabid.com

ABOUT THIS TALK

• Learn some of the tips and tricks I’ve learnt over the years

• Working at Kobo and building an Android tablet, you pick

up on a few cool things.

• I want to share these things with you!

Page 4: FITC 2012 Jellybean Tips and Tricks

Faisal Abid @faisalabidwww.faisalabid.com

• Up and Back are two different things now. As if things

weren’t bad enough.

• Up means going up to the next page in the app.

• Back means going back irrespective of where you are.

• You can control this stuff in code but it gets messy.

• Android Jellybean introduces the new ParentActivity tag

in the manifest

1. AppStackNavigation

Page 5: FITC 2012 Jellybean Tips and Tricks

Faisal Abid @faisalabidwww.faisalabid.com

• Getting thumbnails from Android videos is very weird.

• ICS’s new MediaMetadataRetriever makes it easy

2. Getting Media Thumbnails

private Bitmap getThumbnailForVideoUri(Context cx, Uri contentURI) { MediaMetadataRetriever retriever = new MediaMetadataRetriever(); try { retriever.setDataSource(cx, contentURI); return retriever.getFrameAtTime(); } catch (Exception e) { // exception } }

Page 6: FITC 2012 Jellybean Tips and Tricks

Faisal Abid @faisalabidwww.faisalabid.com

• I honestly had no idea you could do this!

• Set an alarm programmatically. Not an AlarmManager

alarm, but an actual alarm.

3. Set Alarm Programmatically

Intent i = new Intent(AlarmClock.ACTION_SET_ALARM);

Page 7: FITC 2012 Jellybean Tips and Tricks

Faisal Abid @faisalabidwww.faisalabid.com

• Lots and lots of ways exist.

• Tried many solutions

• This one worked the best

4. Handle Bitmap OOM Errors

Page 8: FITC 2012 Jellybean Tips and Tricks

Faisal Abid @faisalabidwww.faisalabid.com

• I love progress loaders. Really set the app apart

• WhereIsMyBus has a cool progress loader

• AnimationDrawable will give you OOM.

• AnimationDrawable loves to load up all the items in

memory.

• Solution is by “Yar” from StackOverFlow

http://bit.ly/OsGSsb

5. Handling Awesome progress animations

Page 9: FITC 2012 Jellybean Tips and Tricks

Faisal Abid @faisalabidwww.faisalabid.com

• Simple but cool. In Jellybean Android added

new activity animation.

• Take advantage of them!

6. ActivityAnimations

Page 10: FITC 2012 Jellybean Tips and Tricks

Faisal Abid @faisalabidwww.faisalabid.com

• With Project Butter. Android Animation keeps getting

better.

• Use the built-in .animate() class to get full performance.

• No need to learn OpenGL or anything else for

trivial animations.

7. Animation keeps getting better

Page 11: FITC 2012 Jellybean Tips and Tricks

Faisal Abid @faisalabidwww.faisalabid.com

• Honeycomb introduced this.

• Not widely known.

• call() you can add all the cool stuff you want.

• Built system wide image cache on the Arc.

8. ContentProvider with custom methods!

Page 12: FITC 2012 Jellybean Tips and Tricks

Faisal Abid @faisalabidwww.faisalabid.com

• Still not used as much as you should

• Simple as running monkeyrunner.

9. Monkey

Page 13: FITC 2012 Jellybean Tips and Tricks

Faisal Abid @faisalabidwww.faisalabid.com

• ICS, AsyncTasks run in a single threaded threadpool now.

• To change it run it on an executor.

10. Async Tasks have changed!

Page 14: FITC 2012 Jellybean Tips and Tricks

Faisal Abid @faisalabidwww.faisalabid.com

• More of a PSA

• Soon android users will be required to allow the app to

Read SD card.

• Read_External_storage is a good permission to have,

Start thinking about it.

• You’ll get a filenotfound exception if you don’t have it.

• If you have Write_External_storage you are good

11. Security Changes to Android

Page 15: FITC 2012 Jellybean Tips and Tricks

Faisal Abid @faisalabidwww.faisalabid.com

• As of Android 3.1, no BroadcastReceiver will work until

the user has manually launched an activity

11.5. More security changes

Page 16: FITC 2012 Jellybean Tips and Tricks

Faisal Abid @faisalabidwww.faisalabid.com

THANK YOU!