Wednesday, June 26, 2013

Android App Development

1)TVS motors-mp3 player in android for indonesian client
2)Samsung has printer with android os
3) GE healthcare scanning - with android Os
4) ATM also has android OS

Windows Phone or iOS is tightly coupled with OEMs/manufacturers.

1) Google map applications
2) Background services and applications { ex: image download in background}
3) Shared data and Interprocess commn
4) All applications[in-built application/third party app. no difference] have all apis.

if we want to make our DB public, we have to implement content provider , so that others can make use of it.

Application framework - List of classes & APIs available for developers

   -Allows multiple instances of virtual machine
   -less Binary size

    java -> .class -> .dex
    .apk -> dex + resources

    accelerometer-> rotation,tilt motion sensors

  Set training mode in mobile,when the user is calling
the caller should receive message/voice message about the user's scenario.

 while pressing BACK button, by default it will goes to previous activity.This is done by Activity manager.
Activitymanger has backstack to perform this.

View manager does the drawing job/control or draw the views[button/combo box any control] on screeen.

Any code apart from java is called as resource.Ex. XML,photo,image,audio/video
Via Resource manager, we will access the resources

Android Application:

Package manger name should be unique.
while creating the process by android kernel, it will makes use of package name as identifier.
So no two applications should not have the same package name.

gen folder- autogenerated files are available in this folder.

Entry point for the Android application is who has action.MAIN in androidmanifest.xml
<action android:name="android.intent.action.MAIN" />
 & LAUNCHER flag.

During installation, AndroidManifest.xml is checked. if the minSDK criteria is not satisfied application wont be installed.

Android Application blocks:
   1)Activity-Single Screen
   2)BroadCastReceiver- to receive external events

Except broadcast reciever, we must register it in AndroidManifest.xml.

 Difference between actions and broadcast receivers?
 Diff service and midl service?


Activating components:
  Intent can
    i) start an activity [startActivity(new Intent(this,NewActivity.class));]
        ii) start a service  [Context.startService() ]
        iii)can send broadcast[context.sendBroadcast() ..]

           Activity class is derived from context. So whenever context is needed, we can use Activity object or Activity's this pointer.

Shutting down components:
 1) ContentProviders and broadcastReceivers - No need to shut down explicitly shutdown
 2) Shutdown activity
    finish() or finitshActivity() [Parent activity will call finishActivity() of child activity]

 3)Shutdown service
    - Context.stopService() or stopSelf()

Lifecycle of an android application:
    process's lifetime is not controlled by the application itself.
Android will decide when to kill or stop process.

The order of killing processes will be decided by
        1) How mportant [importance hierarchy]
        2) memory need

Importance hierarchy:
     1)Foreground process- visible to user and having focus
     2)Visible process - visible to the user but not having focus. [onPause state] Activitylaunches the dialog. Activity is visible but not focus.
     3)Service process - not visible to user. it is in running
     4)background process- not visible to the is in  stopped state.
     5)Empty process - doesnt hold any acctive application components[as a cache to improve startup time]    

First android will try to kill empty proces, background process...foreground process until required memory is available.

aapt is used to construct apk file.

State of activity:
1)Running -focused screen
2)Paused - visible to user but not focused
3)Stopped- not visible to user and it is in stopped state.
4)Inactive - when we finish() activity, it will goes to Inactive

Callbacks of activity:

onPause() & onStop() will be called if activity is going to stopped state.

finish() activity will invoke

Save your user data to persistent storage in onPause() .
Load your user data to persistent storage in onResume().

Lifecycle methods:(onPause/onResume...)

For all lifecycle methods, we should call super version of it.


Activity manager is responsible for handling acitivity's lifecycle.

while launching activity-> onCreate(), onStart() ,onResume()
pressed HOME button     -> OnPause(),OnStop()

UI is based on View and ViewGroup classes.


It is loading activity_main.xml file for displaying UI content.

ViewGroup->View or ViewGroup...

Through DDMS's Emulator control, we can make a call or SMS to emulator. Try it...

  FrameLayout: pins each child view to top left corner
          --->add controls dynamically this will be used
  LinerarLayout-aligns each other in either vertical or horizontal
  Relativelayout-defines position of each view relative to others and to the screen boundaries
                 rightof, leftof,below,above
  TablelLayout - lays out view using grid of rows and columns
  Gallery -  displays single row of items in horizontal scrolling list

We have to implement onTouch or OnClick ? what is the best practice??

Android best practice is always assume that there is a keyboard.
If touch listener is not available, android will convert the touch listener to click listener.

So as a practice, we have to implement onClick().

Adding new activity:

 1) Create XML UI layout [/Res/layout/auth.xml]
 2) Create activity class & setContentView(xmlUILayout);
 3) Register the activity in Androidmanifest.xml

1 comment:

Sumit Mishra said...

Twigz Technologies is a leading Android application development company. Android application development Being the core of today's mobile strategy, we are helping global companies by developing and deploying the best in Android class applications to maintain them before the curve. Not only do we develop great Android apps, but we also support in terms of marketing application and monetization. With ready-to-use framework and a strong team of Android application developers in place, we are rapidly developing the application and deploying the project according to the planned schedule.
Android App Development in Gurgaon