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/)
Original Title
MobilMobile application development: part 1: Andriod Vs IOSe Application Development
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/)
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/)
Basic Topics covered Session 1 Fragments : slide 3 Activity Lifecycle : slide 4 Configuration Changes : slide 5 Starting activity and getting results: slide 6,7 Saving persistent State: Slide 7 Permissions: Slide 8 Process Lifecycle: Slide 9. 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); } }
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. Visible Lifetime Foreground Lifetime Entire Lifetime 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
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.
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 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 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.
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