app forum 2014 helping the developer community build next generation multi platform apps n.
Skip this Video
Loading SlideShow in 5 Seconds..
APP FORUM 2014 Helping the developer community build next-generation, multi-platform apps. PowerPoint Presentation
Download Presentation
APP FORUM 2014 Helping the developer community build next-generation, multi-platform apps.

Loading in 2 Seconds...

play fullscreen
1 / 44

APP FORUM 2014 Helping the developer community build next-generation, multi-platform apps. - PowerPoint PPT Presentation

  • Uploaded on

APP FORUM 2014 Helping the developer community build next-generation, multi-platform apps. SCHAUMBURG, ILLINOIS | SEPTEMBER 8-10. ANDROID APPLICATION FUNDAMENTALS. JOHN SEIMER GLOBAL SOLUTION CENTERS. Agenda. Android application structure – crash course on application components Activity

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
Download Presentation

APP FORUM 2014 Helping the developer community build next-generation, multi-platform apps.

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
    Presentation Transcript
    1. APPFORUM2014Helping the developer community build next-generation, multi-platform apps. SCHAUMBURG, ILLINOIS | SEPTEMBER 8-10


    3. Agenda • Android application structure – crash course on application components • Activity • Services • Intents • BroadcastReceiver • ContentProvider • Processes and Threading • Data Storage

    4. Android Architecture • Dalvik Virtual Machine • Dalvik Executable (.dex) format • Optimized for minimal memory footprint • Compilation

    5. What is an APK File • A package containing • .DEX files • Resources • Assets • Certificates • Manifest file • A .ZIP formatted package based on .JAR file format • Manifest File • Declares the components and settings of an application • Identifies permissions (ie. network access) • Defines the package of the app • Defines the version • Declares hardware and software features

    6. Android Application Components • Activity • Service • BroadcastReceiver • ContentProvider • Activating Components • Intents

    7. Activity Overview • A screen with a UI • A typical application may have many activities • Typically expensive and so are managed by the system • May be shutdown by the system

    8. Activity Lifecycle • Activities are managed by the system’s Activity Manager. • Applications show new screens by pushing a new activity onto the screen. Navigating back (via back button) causes the top screen to be popped off the stack. • You define what happens in each callback.

    9. Activity Lifecycle Explored Rotating the screen • onSaveInstanceState • onPause • onStop • onDestroy • onCreate • onStart • onRestoreInstanceState • onResume Starting for the first time • onCreate • onStart • onResume Restarting next time • onRestart • onStart • onResume

    10. Activity Implementation

    11. Registering the Activity Register the activity in the manifest file: <application> ...<activity android:name=".ActivityDemo“ android:label="@string/app_name"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> ... </application> The intent filter specifies that this activity is to be the main entry point into the application as well as that it should be shown in the app launcher on home screen.

    12. Building an Android UI • There are 2 approaches to building Android User Interfaces: • Declaratively • Declare UI in XML • Eclipse provides nice drag-n-drop tools • Inflate the XML view in Java • Programmatically • Write Java code for the UI • Instantiate all widgets programmatically • Set properties for each • Best approach is to combine both: • Declare the look and feel using XML • Inflate XML into Java. • Program the actions using Java.

    13. Building an Android UI • UI is built using a hierarchy of View and ViewGroup objects • Android provides XML vocabulary for all View and ViewGroup objects so that UI can be defined in XML

    14. Building an Android UI

    15. Building an Android UI

    16. Preference Activity Specialized activity that knows how to display, read and write application’s user preferences. import android.os.Bundle;import android.preference.PreferenceActivity; public class PrefsActivityextends PreferenceActivity { @Override protected void onCreate(Bundle savedInstanceState { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.prefs); } } R.xml.prefs refers to Preference screen resource.

    17. Preference Activity res/xml/prefs.xml <?xml version="1.0" encoding="utf-8"?><PreferenceScreenxmlns:android=""> <CheckBoxPreference android:title="Background data" android:key="background_data" android:summary="Use background data?”> </CheckBoxPreference> <ListPreference android:key="text_size" android:entries="@array/text_size_entries“ android:entryValues="@array/text_size_values" android:title="Text Size”> </ListPreference> </PreferenceScreen>

    18. Preference Activity

    19. Preference Activity

    20. Intent Overview • Intents are like events or messages. • Can be used to start activities, start/stop services, or send broadcasts. • Composed of an action that needs to be performed and the data that it needs to perform the action on. • Can be implicit or explicit.

    21. Using Intents Sample An activity can send an intent to start another activity: Intent I = new Intent (this, SecondActivity.class); startActivity(i); An intent can contain data to be used by the receiving component: String url =; Intent i = new Intent (Intent.ACTION_VIEW); i.setData(Uri.parse(url)); startActivity(i);

    22. Intent Filters • Intent filter is a way for to assign certain action to an activity, service, receiver or similar. • Action is one of system defined actions, or something developer can come up with. • Intent filter typically goes into Android Manifest file, within <activity>, <service>, or <receiver> elements. • Android Manifest file • ... • <intent-filter> • <actionandroid:name=""/> • </intent-filter> • ...

    23. Explicit Intent Sample ... startActivity(newIntent(this,AnotherActivity.class)); ... startService(newIntent(this,ServiceDemo.class)); ... this is the context from which this intent is being sent, in this case an Activity or Service

    24. Implicit Intent Sample ... startService(newIntent(“MSI.intent.action.IntentServiceDemo")); ... sendBroadcast(newIntent(“MSI.intent.action.ReceiverDemo")); ... Requires an intent filter filtering for this particular intent.

    25. Service • Service Overview • Service Lifecycle • Service Lifecycle Explored • Service Sample • Service Callbacks • Registering Service

    26. Service Overview • Runs in the background • Can be started and stopped • No UI

    27. Service Lifecycle • Starting a service first time • onCreate • onStartCommand • Restarting the same service • onStartCommand • Stopping the service • onDestroy • Starting the intent service • onCreate • onHandleIntent • onDestroy

    28. Registering a Service Registering a service that will be called explicitly by its class name <application> ... <serviceandroid:name=".ServiceDemo"></service> ... </application> Registering a service that will be called via action ... <serviceandroid:name=".IntentServiceDemo"> <intent-filter> <actionandroid:name=“MSI.intent.action.IntentServiceDemo"/> </intent-filter> </service> …

    29. Example Service

    30. Broadcast Receiver Overview • An Intent-based publish-subscribe mechanism • Respond to broadcast messages from other applications or from the system. • Great for listening for system events such as SMS messages

    31. Registering a Broadcast Receiver Registering in Android Manifest file <application> <receiverandroid:name=".ReceiverDemo"> <intent-filter> <actionandroid:name=“android.intent.action.BOOT_COMPLETED"/> </intent-filter> </receiver> </application>

    32. Notification Overview • Alerts the user in the status bar • Contains the following elements: • Content title • Large icon • Content text • Content info • Small icon • Time the notification was issued

    33. Data Storage • Android provides a number of options for storing data • SharedPreferences • Store persistent key-value pairs that can be private or public • Ideal for store preferences and other small data • Files • Local Storage – created in app sandbox and private • External Storage – Open to be read by all applications • SQLite • Android provides full SQLite support • Android provides SQLiteOpenHelper to manage opening and closing of actual database • Ideal for storing structured data

    34. Content Provider • Content Provider Overview • Content Provider Lifecycle • Content Provider Lifecycle Explored • Content Provider Sample • Content Provider Callbacks • Registering Content Provider

    35. Content Provider Overview • Content Providers share content with applications across application boundaries. • Examples of built-in Content Providers are: • Contacts • MediaStore • Settings and more

    36. Content Provider Lifecycle • Content provider is initiated first time it is used via a call to onCreate(). • There is no callback for cleaning up after the provider. • When modifying the data (insert/update/delete), open/close database atomically. • When reading the data, leave database open or else the data will get garbage collected.

    37. Registering a Content Provider Registering in the manifest file: <application> ... <provider android:name=".ProviderDemo“ android:authorities="" /> ... </application> The authority of this provider must match the URI authority that this provider is responding to.

    38. Typical Use of Content Providers

    39. Processes and Threading • All components of the same application package run in the same process (all activities, services, etc). • Android system automatically creates a thread called “main”, which is usually referred to as the “UI thread”. • Any interaction with views (ui components) must be done from the UI thread. • Android provides convenience classes for using background threads for long running tasks.

    40. Threading - AsyncTask

    41. Summary/Recap • Android applications are developed in Java. Decide on the API level that your app will be supporting. • Each Android application runs in its own Application Security Sandbox • Android system can kill your activity anytime if it decides its not required. Hence save your screen data constantly. • Your application settings can be stored/retrieved using Preference Activity. • You could register intent filters to start your activity or service from any other app. • Services are the code that does not have UI. • Use IntentService to perform any background activity. • Broadcast Receiver listens to the system event to occur. • Use a Content Provider if shared data access is required.

    42. DEVELOPMENT OPTIONS NEW Recommended when programmatically accessing MSI value adds is required for app development Recommended for standard Android development Targeted for multiple device and OS development Web development skills recommended Recommended when no application programming desired and basic text data processing required

    43. EMDK OFFERING Sample Apps / Code Settings Scanning MSR Android SDK + ADT Eclipse IDE EMDK Profile API Scanning API MSR API PROFILES Scanning MSR Fusion Clock Power Battery //Get scanManager instance ScanManager scnDeviceMngr = (ScanManager)EMDKManager.getInstance (getApplicationContext(), SCANNER); //Enumerate scan devices ArrayList<Device> scnDevices = scnDeviceMngr.getDevices(); //Get specified scan device Device scnDevice = scnDevices.get(index); //Enable scan device scnDevice.enable(); //Set config ConfigurationSettings config = scnDevice.getConfiguration(); config.triggerMode = TriggerMode.SOFT_ONCE; config.Decoders.Code39 = ENABLE; …

    44. THANK YOU