This presentation is Imam Raza's tech talk on "Android" in Google Developer Group DevFest 2012 Event. In the event Mr. Imam Raza condemned recent blasphemy act of Google of not removing blasphemy video by saying "Shame on You". He also appreciated the efforts of minorities who stand with Muslim community on this issue.
He also read following Stanza from Allama Iqbal poem "Jawaab-e-Shikwa", in which Allah is answering to complains of Muslims to Him. In below stanza Allah is praising His prophet Mohammad (peace be upon him) and telling that this universe is made due His beloved prophet Mohammad (peace be upon him). In last part of stanza Allah tells Muslims that if they want to success in this world and there after then they have to make themselves loyal to Mohammad (peace be upon him).
ہو نہ یہ پھول تو بلبل کا ترنم بھی نہ ہو
چمن دہر میں کلیوں کا تبسم بھی نہ ہو
یہ نہ ساقی ہو تو پھر مے بھی نہ ہو،خم بھی نہ ہو
بزم توحید بھی دنیا میں نہ ہو، تم بھی نہ ہو
خیمہ افلاک کا استادة اسی نام سے ہے
نبض ہستی تپش امادة اسی نام سے ہے
دشت میں، دامن کہسارمیں،میدان میں ہے
بحر میں، موج کی ا غوش میں،طوفان میں ہے
چین کے شہر، مراقش کے بیابان میں ہے
اور پوشیدة مسلمان کے ایمان میں ہے
چشم اقوام یہ نظارة ابد تک دیکھے
رفعت شان رفعنالک ذکرک دیکھے
کی محمد سے وفا تو نے تو ہم تیرے ہیں
یہ جہاں چیز ہے کیا، لوح و قلم تیرے ہیں
2. Speaker.bio.toString()
• Senior Software Architect @ Folio3.
• Specialties: Enterprise Software Architecture,
Mobile Software Architecture, Software Best
Practices(TDD,CI ,AOP, IOC).
• Master in computer science from KU
• B.E (Mechanical) from NED University
Monday, September 19, 2011
20. Linux Kernel
• Android runs on Linux. Linux
provides:
– Hardware abstraction
layer
– Memory
management
– Process management
– Networking
• Users never see Linux sub
system
• The adb shell command opens
Linux shell
21. Native Libraries
• Pieces borrowed from other
open source projects:
– Bionic, a super fast and
small license-friendly
libc library optimized
for Android
• WebKit library for fast HTML
rendering
• OpenGL for graphics
• Media codecs offer support for
major audio/video codecs
• SQLite database ..Much more…
23. Dalvik VM
• Dalvik VM is Android implementation of Java VM
• Dalvik is optimized for mobile devices:
– Battery consumption
– CPU capabilities
• Key Dalvik differences:
– Register-based versus stack-based VM
– Dalvik runs .dex files
– More efficient and compact implementation
– Different set of Java libraries than JDK
24. Application Framework
• The rich set of system services wrapped in an
intuitive Java API.
• This ecosystem that developers can easily tap
into is what makes writing apps for Android easy.
• Location, web, telephony, WiFi, Bluetooth,
notifications, media, camera, just to name a few.
39. HelloWorld-JAVA File
package com.folio3;
import android.app.Activity;
import android.os.Bundle;
public class HelloAndroid extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}
43. Activity LifeCycle
Activity have well-defined
lifecycle. The android OS
manages your activity by
changing its state.
You fill in the blanks
44. Intents
• Intents represent
events or actions.
• They are to Android
apps what hyperlinks
are to websites. Sort
of.
• Intents can be
implicit or explicit.
45. Services
Services are code that runs in the background.
They can be started and stopped. Services
doesn’t have UI.
46. Service LifeCycle
• Service also has a lifecycle,
but it’s much simpler than
activity’s.
• An activity typically starts
and stops a service to do
some work for it in the
background, such as play
music, check for new
tweets, etc.
47. Content Provider
• Content Providers share
content with applications
across application
boundaries.
• Examples of built-in
Content Providers are:
– Contacts,
– MediaStore,
– Settings and
more.
50. Fragments
• Fragments were introduced in Android 3.0 (API
level 11), primarily to support more dynamic and
flexible UI designs on large screens, such as
tablets.
• Fragments are lot like an activity but it must
exists within the activity.
• DialogFragment makes it easy to show a Dialog
that is managed as part of the Activity lifecycle.
• ListFragment makes it easy to show a list of data.
Monday, September 19, 2011
53. Best Practices
• Use RoboGuice(DI based framework)
• Learn Activity Life Cycle
• Avoid getting activities thick
• Design views for multiple size/orientation.
• Use Fragments to better manage sub-portion of
Activity.
• Practice Good MVC.
• Use Source Code Analyzer Tools (findbugs,
checkstyle,PMD and CPD). Integrate these tools
with CI Tools like Teamcity.
Monday, September 19, 2011
54. RoboGuice
• It’s based on dependency injection pattern just
like Spring Framework in enterprise apps
• It takes the guesswork out of development. e.g
checking null for getIntent().getExtras(). Casting
findViewById().
• Make your writing unit test case easy
• It reduces your lines of code and hence the
number of bugs see next slide for code.
Monday, September 19, 2011
57. Compatibility
• Ability to install and run app on device.
• Huge variety of devices so developer need to
make sure about the Hardware/Software feature
his application needed to run.
Monday, September 19, 2011
58. Compatibility
• Specify uses-feature node for every API you use
• Mark essential features as required.
• Mark optional features as not required.
<uses-feature
Android:name=“android.hardware.gps”
Android:required=“true”/>
Monday, September 19, 2011
59. Compatibility
• Check for API existence in code.
PackageManager pm = getPackageManager();
Boolean hasCompass=
pm.hasSystemFeature(
PackageManager.FEATURE_SENSOR_COMPASS);
If(hasCompass){
//enable things are needed
}
Monday, September 19, 2011
60. Compatibility
Use dp and sp instead of px:
<Button android:layout_width=“wrap_content”
Android:layout_height=“wrap_content”
Android:layout_marginTop=“20dp”/>
<TextView android:layout_width=“match_parent”
Android:layout_height=“wrap_content”
Android:textsize=“20sp”/>
Monday, September 19, 2011
64. Advance Task Killer App is
among 50 millions or more
install apps
Why?
Monday, September 19, 2011
65. Performance
• Avoid creating objects. (e.g use StringBuffer) .
• Prefer static over virtual.
• Use static final for constants.
• Avoid internal getter/Setter (with Proguard you
don’t need it.)
• Use Enhanced For Loop Syntax e.g:
for (Foo a : mArray) { sum += a.mSplat; }
• Use native methods.
• Avoid using Float and enums
67. Responsiveness
• “Application Not Responding”
• Respond to user within 5 seconds
• Broadcast Receiver must complete within 10 seconds
• Use Threads and AsyncTasks within Services
Monday, September 19, 2011
68. Source Code Analyzer Tools
• FindBugs
• PMD
• CheckStyle
• CPD : Shows code duplication
• You can integrate them with CI Server like
Teamcity to get consolidated reports of code
quality of your team. We have been using it on
our company and its really helped us in
monitoring quality of code.
Monday, September 19, 2011
-First I would like to thank the organizers of the event that they allow me to put this slide as right of freedom of speech of every individual.-I condemn blasphemy act made recently by individuals and organizations in the name of freedom of speech that hurt millions of humans. So I would like to record my statement of condemnation to all those individual and organization who involved in this. And I would say to one sentence to them “Shame on you. Shame on you Google. Shame on you Facebook. Shame on you all on this wicked act”.-After recording my condemnation I would like to address you as your Muslim brother that lets we all start attaching ourselves with the only great personality ever sent to human kind. I would like share some Iqbal thoughts on the importance for Muslims to attached themselves with our Prophet Rasool Allah Sallahwasallam.SurahAle-Imran chapter#3,verse 64Allah did confer a great favour on the believers when He sent among them an apostle from among themselves, rehearsing unto them the Signs of Allah, sanctifying them, and instructing them in Scripture and Wisdom, while, before that, they had been in manifest error.