slide1 l.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Android Integration Perry Hoekstra Technical Consultant perry.hoekstra@perficient.com PowerPoint Presentation
Download Presentation
Android Integration Perry Hoekstra Technical Consultant perry.hoekstra@perficient.com

Loading in 2 Seconds...

play fullscreen
1 / 60

Android Integration Perry Hoekstra Technical Consultant perry.hoekstra@perficient.com - PowerPoint PPT Presentation


  • 185 Views
  • Uploaded on

Android Integration Perry Hoekstra Technical Consultant perry.hoekstra@perficient.com. There is an App for That. Gartner says …. Smartphones in the US. Two Horse Race?. Consumers.

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

Android Integration Perry Hoekstra Technical Consultant perry.hoekstra@perficient.com


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. Android Integration Perry Hoekstra Technical Consultant perry.hoekstra@perficient.com

    2. There is an App for That

    3. Gartner says …

    4. Smartphones in the US

    5. Two Horse Race?

    6. Consumers Smartphones (and possibly tablets) are fast overtaking conventional computers as the life-management workstation of choice for consumers

    7. Consumers The vision is that literally a billion people getting inexpensive, browser-based touchscreen phones over the next few years in developing countries.

    8. Inquiring minds want to know … Corporate clients (and internal IT departments) are not asking for slingshotted birds at evil green pigs …

    9. What are corporations looking for? Not witty responses to office trash talk …

    10. Or beer tracking applications …

    11. So what is on the minds of CTOs? • How can we tie mobile computing to our current client-facing Internet offerings into a comprehensive mobile/Internet strategy? • How do we support our own mobile workforce?

    12. Consumer Mobile Strategy • Financial institutions have been in the vanguard • Previously, had invested heavily in SOA architectures • Made their secure web sites available in mobile-friendly formats • Rolled out selective native applications

    13. Bring your own Device (BYOD) • John CEO gets a new iPad from his wife for Xmas • Likes it and would like to: • read corporate email from it • view corporate reports from reports server • What do you say?

    14. Expanding the Corporate Network • Smartphones and tablets are the new corporate perimeter • Phones are always with the business user • Tablets fit in an 8x11 leather portfolio and will eliminate the netbook market • Surveys indicate that by 2015, mobile development will eclipse traditional enterprise development as an IT professional focus

    15. Workplace 2.0 • Need to consider an enterprise mobility strategy • SOA is an ideal enabler for sophisticated mobile web applications • Mobile devices are typically on the move outside their office and homes

    16. Reason for “Android Integration” Enterprise mobile development generally means developing a distributed application (the device accessing one or more servers)

    17. Professional Development If you as a developer are looking to get into the mobile space: • Consumer app that supports current corporate end users • Support internal users with tasks such as filling out expense reports • Each is a distributed application

    18. Mobile as an SOA Platform • Android currently supports SOA-enabled apps such as Gmail, Google Calendar & Contacts. • Each have separate UIs but share common data • Other SOA-enabled apps running on mobile devices include Twitter and Facebook

    19. Business Apps • Other than the popular Google apps, most of the major mobile business apps are not SOA-enabled • Rather, they boost the productivity and ease-of-use such as Swype • Google launched Google Apps Marketplace to the business-oriented consumer

    20. SOA-enabled Mobile Apps • However, apps like the ones from Walgreens are. • Using the unique capabilities of a mobile device: • Capture the prescription’s bar code through camera phone and send in • Check on current RXs • Locate pharmacy • Tied to current backend Walgreen web services

    21. Internal SOA-enabled Mobile Apps • Field force automation • Especially those using dedicated devices • Work order, status tracking • Product manuals • Sales personnel • Sales and product data • Product availability • Order status • Enterprise data • ERP and CRM

    22. Not your Father’s SOA • Mobile platforms have their own set of challenges in running within an SOA given: • Bandwidth • Memory and CPU Availability • Connectivity Issues • Storage Capacity • Security

    23. Bandwidth • As a developer, when you implemented a web service, you assumed: • Had a reliable connection • Had a fat pipe • The other end had significant processing power • Therefore, the requests and replies could be very large and complex and require a lot of processing and parsing. • But none of these assumptions hold true with a cell phone over a cell phone network

    24. Processing Service Messages • Decreasing returns for XML with large data sets and repetitive XML sections • Processing power and memory limited to parse large XML datasets • Minimize large data sets: • Ask for only those elements that you require • Store what you can locally instead of requesting the same data • Possibly move to JSON to decrease size of data message

    25. Spring Mobile & Spring Android • Spring Android is focused on their RestTemplate library for interaction with back-end services • Will be their platform going forward for a Java-based framework • Spring Mobile also has their RestTemplate library but also code for server-side interaction with mobile devices • Embeds with Spring MVC to detect mobile devices and redirect them to a m.*.* mobile-optimized web site

    26. Go to code …

    27. Significant Code Points Some points about the code, depends on: • Spring Android framework • Spring Http Client (Apache Http Client) • Jackson REST framework Have a full, working example called Greenhouse • Not much in way of integration examples (other than RestClient)

    28. Significant Code Points Two major methods to make a REST call: • getObject • exchange The big difference in which method to use is that exchange allows the developer to manipulate the HTTP headers

    29. Significant Code Points Either case, the JSON response is manifested to an object ResponseEntityresponseEntity = restTemplate.exchange(serverURL, HttpMethod.GET, new HttpEntity<String>(headers), RetrievalResponse.class); RetrievalResponseretrievalResponse = (RetrievalResponse) responseEntity.getBody();

    30. SOAP • No SOAP embedded in base Android distribution • There is a SOAP distribution called kSOAP2 used by a number of developers • Not much enthusiasm with Google or development community • Support existing services (lots of corporate SOAP/WSDL)

    31. Memory & CPU • The current generation of phones are constrained in terms of processing by the power of their CPU and memory • In 2011, smartphones will be debuting with next-generate dual-core processors and NvidiaGeForce graphics core: • Play 1080p HD video • Videoconferencing

    32. Future Horsepower • By 2012, quad-core chips should be readily available • Along with the CPU, graphics processing (NVIDIA) will also see a boost • Both ARM (Cortex) and Intel (Medfield) are quickly following

    33. Semi-Connected • Developer assumed that PCs/laptops have wired Ethernet or reliable Wi-Fi built into the them • Smartphones access the Internet via mobile connections (3G or Wi-Fi) • These connections must be considered unreliable • Want the app light and speedy on a standard 3G network • May need to cache and maintain user session state on the phone so that can restore application state once Internet connection restored

    34. Local Storage & Caching • Cache locally in order to: • minimize service API round trips • preserve application session state between connections • Caching options • Cache in memory • Cache in onboard light weight database or file • Off device persistence (SD card) • Take into account when caching: • Length of time stored • Length of time before refresh

    35. Go to code …

    36. SQLite public class OfflineDatabaseHelper extends SQLiteOpenHelper { private static intVERSION = 1; public static String DATABASE_NAME = "BeerDB"; public OfflineDatabaseHelper(Context context) { super(context, DATABASE_NAME, null, VERSION); } @Override public void onCreate(SQLiteDatabase db) { db.execSQL("CREATE TABLE beers " + "(_id INTEGER PRIMARY KEY AUTOINCREMENT, " + "classification TEXT, name TEXT, description TEXT, " + "ratings TEXT)"); } @Override public void onUpgrade(SQLiteDatabase db, intoldVersion, intnewVersion) { db.execSQL("DROP TABLE IF EXISTS beers"); onCreate(db); } public void truncate(SQLiteDatabase db) { db.execSQL("DROP TABLE IF EXISTS beers"); onCreate(db); } }

    37. JDBC taste … public class ResourceSQL { private OfflineDatabaseHelper db; public ResourceSQL(Context context) { db = new OfflineDatabaseHelper(context); } public ArrayList<Beer> selectByClassification(String classification) { ArrayList<Beer> list = new ArrayList<Beer>(); SQLiteDatabasereadableDB = db.getReadableDatabase(); String [] columns=new String[] {"_id", "classification", "name", "description", "rating"}; Cursor cursor = readableDB.query("resource", columns, "classification=?", new String[]{classification}, null, null, null); if (cursor.moveToFirst()) { do { list.add(new Beer(cursor.getString(1), cursor.getString(2), cursor.getString(3), cursor.getString(4))); } while (cursor.moveToNext()); } if (cursor != null && !cursor.isClosed()) { cursor.close(); } return list; } }

    38. What ORMLite provides • OrmLiteSqliteOpenHelper • Extends SQLiteOpenHelper • Ormlite-specific onCreate and onUpgrademethods • Define some simple interactions for getting DAOs • Base Activity and Service classes that manage DB opens/closes, etc. • This is not your father’s Hibernate

    39. ORMLite @DatabaseTable public class Beer { @DatabaseField(generatedId = true)     private Integer beerId;     @DatabaseField private String classification;     @DatabaseField private String name;     @DatabaseField private String desc;     @DatabaseField private String rating; public Integer getBeerId() { return beerId; } public String getClassification() { return classification; } public void setClassification(String classification) { this.classification= classification; } …. }

    40. Basic DAO public class OfflineDatabaseHelper extends OrmLiteSqliteOpenHelper { … public Dao<Beer, Integer> getBeerao() throws SQLException { if (beerDao== null) { beerDao= BaseDaoImpl.createDao(databaseType, getConnectionSource(), Beer.class); } return beerDao; } }

    41. Data Synchronization • If app is informational, needs to work whether connected or not • If only works when connection, won’t get used • Keep data current against backend changes • Resynchronization upon reconnection

    42. SQL • Simplest approach is: • Server-to-mobile (full table update), depends on size • Mobile-to-server (incremental update) • Any table that need to sync up will contain a timestamp column containing the date/time when the record was last touched (where updated_ts >= @last_sync_pt) • Alternative is some type of version number (eliminate clock skew between mobile and DB server)

    43. SQL • A number of the SQL and NoSQL databases advertise seamless data synchronization for mobile including: • Couchbase • Oracle Database Lite 10g

    44. Push • Synchronization solutions can either rely on the device polling or on some form of a push solution • Polling • Balance between low interval (drains battery) and higher interval (miss alerts) • Does not hold connection open

    45. ApproachesApproaches • SMS • Good integration with Android • Limited payload • Sockets • Persist connection including keep-alives • Android could kill connection in certain situations • Servers have this tendency too

    46. ApproachesMessage Queues • Android Cloud to Device Messaging (C2DM) • Size limit 1024 bytes • Google throttles messages sent/received • MQTT • IBM • Very attractive • Open protocol • No support on iOS

    47. Go to code …

    48. MQTT • Did not want to install MQ, using IBM’s Real Small Message Broker (alphaWorks) • Drop wmqtt.jar in the assets library

    49. Security • Along with caching, a smartphone can now act as a data repository for sensitive corporate data • Some issues: • What are the risks to loss and compromise? • What security controls are available? • What new infrastructure support is necessary? • Impact on web service calls?

    50. Mobile development generally means • A distributed system (the device accessing one or more servers) • The device can easily be lost or stolen • In both of these cases, one needs to pay particular attention to security, both on the wire and internally stored data