Andriod Mobile Application development and comparison with IOS.
Part 1 basics: Activity, Intent , process lifecycle, activity Lifecycle.
More details: (blog: http://sandyclassic.wordpress.com ,
linkedin: ie.linkedin.com/in/sandepsharma/)
3. Fragments
• With Version Honeycomb Fragement class is optional for
Activity Class for modularization.
• Scale application between small and large screen.
• public class ArticleFragment extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater,
ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.article_view, container,
false);
}
}
4. Activity Class
• Activity- Any single focused thing User Does.
• Create window using setContentView(View).
• Full screen or Floating Window using theme
WindowIsFloating().
• Can be Grouped using class ActivityGroup
• Initialized using onCreate(Bundle) which call
setContentView() with layout resource defined to
create UI.
• findViewById(int) :retireve widget in that UI.
• onPause() deal with user leaving your activity &
changes commits ContentProvider holding data.
6. Configuration Changes
• Resource.configuration Class allow UI
undisturbed in case of changes in
Configuration.
• Even foreground activity visible to user killed
once onDestroy() called and new activity
created To allow Configuration driven resource
handling of files etc.
• Special case usin bypass using
andriod:configChanges
7. Starting Activity & getting result
• startActivity(Intent): used to start Activity.
Placed in activity stack and intent describe
activity to be executed.
• Activity Exits must return RESULT_CANCELED,
RESULT_OK or any custom value.
•
8. Saving Persistent State
• Actvity deals with two major States:
• Shared document like data( on SQLite
database using contentprovider)
• Internal State: like user preferences.
• While creating a new document a database
entry is created.
• When onPause() called the state content
provider files of user is saved
9. Process Lifecycle
• Application can have four states based on Activity
Lifecycle. (As shown in diagram in slide2)
If memory Not Available then All kinds of processes can be forced closed.
• Foreground Activity: User interacts with user and
process has least priority to be killed.
• Visible Activity: Visible not in foreground killed only
when conflict with foreground.
• Background Activity: not visible or paused not critical
can be safely killed restarted with onCreate() with
savedInstanceState.(start from where left)
• Empty process: hosting no activity killed highest
priority
10. Intent
• Abstract description of operation to be performed.
startActivity: launch Activity
BroadCastIntent(): send to Receiver
startService(Intent):
bindService(Intent, ServiceConnection,int): Bind to service
• Structure:
– Action: To be performed
– Data: data to be operate on.
– Category: addition info for execution like launch as top level or
as alternative application
– Type: Explicit typing of data intent (Normally MIME type).
– Component: Component class for intent
otherwise(Action,Data/Type, Category) is matched.
– Extras: Bundle Additional data Like subject, Body with email.
11. Example Operations spec as Intent
• Launch Home screen:
ACTION_MAIN & CATEGORY_HOME
• Display people phone Number, browse & pick:
ACTION_GET_CONTENT & MIME TYPE
(vnd.andriod.cursor.item/phone.
• ACTION_GET_CONTENT with mime type Any
(*/*) and Category CATEGORY_OPENABLE.
ContentResolver.opemInputStream() pick &
attach data return URI to caller.
Mime Type list :
http://www.freeformatter.com/mime-types-
list.html
12.
13. More Details: Cont. Next 4 more slides
• Visit http://sandyclassic.wordpress.com
• Java Architect :
http://javaarchitectview.wordpress.com/
Enterprise Architect:
http://enterprisearchitectview.wordpress.com
• Cloud perspective :
http://thecloudview.wordpress.com/
• Product Management:
http://productmanagementview.wordpress.co
m
Editor's Notes
All Mime types: http://www.webmaster-toolkit.com/mime-types.shtmlhttp://www.freeformatter.com/mime-types-list.html
All Mime types: http://www.webmaster-toolkit.com/mime-types.shtmlhttp://www.freeformatter.com/mime-types-list.html