Your SlideShare is downloading. ×
0
Mobile Worshop Lab guide
Mobile Worshop Lab guide
Mobile Worshop Lab guide
Mobile Worshop Lab guide
Mobile Worshop Lab guide
Mobile Worshop Lab guide
Mobile Worshop Lab guide
Mobile Worshop Lab guide
Mobile Worshop Lab guide
Mobile Worshop Lab guide
Mobile Worshop Lab guide
Mobile Worshop Lab guide
Mobile Worshop Lab guide
Mobile Worshop Lab guide
Mobile Worshop Lab guide
Mobile Worshop Lab guide
Mobile Worshop Lab guide
Mobile Worshop Lab guide
Mobile Worshop Lab guide
Mobile Worshop Lab guide
Mobile Worshop Lab guide
Mobile Worshop Lab guide
Mobile Worshop Lab guide
Mobile Worshop Lab guide
Mobile Worshop Lab guide
Mobile Worshop Lab guide
Mobile Worshop Lab guide
Mobile Worshop Lab guide
Mobile Worshop Lab guide
Mobile Worshop Lab guide
Mobile Worshop Lab guide
Mobile Worshop Lab guide
Mobile Worshop Lab guide
Mobile Worshop Lab guide
Mobile Worshop Lab guide
Mobile Worshop Lab guide
Mobile Worshop Lab guide
Mobile Worshop Lab guide
Mobile Worshop Lab guide
Mobile Worshop Lab guide
Mobile Worshop Lab guide
Mobile Worshop Lab guide
Mobile Worshop Lab guide
Mobile Worshop Lab guide
Mobile Worshop Lab guide
Mobile Worshop Lab guide
Mobile Worshop Lab guide
Mobile Worshop Lab guide
Mobile Worshop Lab guide
Mobile Worshop Lab guide
Mobile Worshop Lab guide
Mobile Worshop Lab guide
Mobile Worshop Lab guide
Mobile Worshop Lab guide
Mobile Worshop Lab guide
Mobile Worshop Lab guide
Mobile Worshop Lab guide
Mobile Worshop Lab guide
Mobile Worshop Lab guide
Mobile Worshop Lab guide
Mobile Worshop Lab guide
Mobile Worshop Lab guide
Mobile Worshop Lab guide
Mobile Worshop Lab guide
Mobile Worshop Lab guide
Mobile Worshop Lab guide
Mobile Worshop Lab guide
Mobile Worshop Lab guide
Mobile Worshop Lab guide
Mobile Worshop Lab guide
Mobile Worshop Lab guide
Mobile Worshop Lab guide
Mobile Worshop Lab guide
Mobile Worshop Lab guide
Mobile Worshop Lab guide
Mobile Worshop Lab guide
Mobile Worshop Lab guide
Mobile Worshop Lab guide
Mobile Worshop Lab guide
Mobile Worshop Lab guide
Mobile Worshop Lab guide
Mobile Worshop Lab guide
Mobile Worshop Lab guide
Mobile Worshop Lab guide
Mobile Worshop Lab guide
Mobile Worshop Lab guide
Mobile Worshop Lab guide
Mobile Worshop Lab guide
Mobile Worshop Lab guide
Mobile Worshop Lab guide
Mobile Worshop Lab guide
Mobile Worshop Lab guide
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Mobile Worshop Lab guide

298

Published on

Crossover International Company Limited

Crossover International Company Limited

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
298
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
6
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Workshop Lab Guide Alex Hung Crossover International Co. Ltd. www.crossover-int.com
  • 2. Lab Guide Page 2 Course Agenda Lab 1: Setup of Development Environment Lab 2: Basic Development of Mobile App Lab 3: Example Coding Lab 4: Submission of Mobile App to Application Store Lab 5: Reporting and Statistics Collection
  • 3. Lab Guide Page 3 Lab 1: Setup Android SDK • Objective: – Download and Setup the Android Development Platform • Task: – Refer to Lab 1 instruction – Download and install Java Developer Toolkit (JDK) – Download and setup the Android SDK – Start the Eclipse IDE and setup up the Android Virtual Device (AVD) for testing – Create a simple app and test the Emulator
  • 4. Page 4 Lab Guide Lab 1: Setup Android SDK SYSTEM REQUIREMENTS • Operating Systems – Windows XP (32-bit), Vista (32- or 64-bit), or Windows 7 (32- or 64-bit) – Mac OS X 10.5.8 or later (x86 only) – Linux (tested on Ubuntu Linux, Lucid Lynx) • GNU C Library (glibc) 2.7 or later is required. • On Ubuntu Linux, version 8.04 or later is required. • 64-bit distributions must be capable of running 32-bit applications.
  • 5. Lab Guide Page 5 Lab 1: Setup Android SDK SYSTEM REQUIREMENTS • Eclipse IDE – Eclipse 3.6.2 (Helios) or greater – Eclipse JDT plugin (included in most Eclipse IDE packages) – JDK 6 (JRE alone is not sufficient) – Android Development Tools plugin
  • 6. Lab Guide Page 6 Lab 1: Setup Android SDK • Download the SDK (ADT bundle for Windows) from: – http://developer.android.com/sdk/index.html • With a single download, the ADT Bundle includes everything you need to begin developing apps: – – – – – Eclipse + ADT plugin Android SDK Tools Android Platform-tools The latest Android platform The latest Android system image for the emulator
  • 7. Lab Guide Lab 1: Setup Android SDK • Make sure your development environment has JDK installed • Download JDK – http://www.oracle.com/te chnetwork/java/javase/do wnloads/index.html • Install JDK Page 7
  • 8. Lab Guide Page 8 Lab 1: Setup Android SDK Install the SDK and Eclipse IDE • Unpack the ZIP file and save it to an appropriate location • Open the adt-bundle<os_platform>/eclipse/ directory and launch eclipse. • Done!
  • 9. Lab Guide Lab 1: Setup Android SDK Page 9
  • 10. Lab Guide Lab 1: Setup Android SDK Android SDK Manager • You can install the SDK packages and tool needed from the SDK Manager • The latest API is included in the ADT Bundle Page 10
  • 11. Lab Guide Lab 1: Setup Android SDK Android Virtual Device (AVD) Manager • Create a new Virtual Device for testing in the Emulator Page 11
  • 12. Lab Guide Lab 1: Setup Android SDK Android Virtual Device (AVD) Manager • Device: you can choose one of the default device in the list OR add a new type in the Device Definition tap from the AVD Manager • Target: you can only find the version install from the SDK Manager Page 12
  • 13. Lab Guide Lab 1: Setup Android SDK Emulator • Select the Device from the list and click Start Page 13
  • 14. Lab Guide Lab 1: Setup Android SDK Create a New App and Test the Emulator Page 14
  • 15. Lab Guide Lab 1: Setup Android SDK Run the App in Emulator • Select the App in Package Explorer, click Run Page 15
  • 16. Lab Guide Lab 1: Setup Android SDK Testing with real Android device • You need to first enable USB debugging on your device – On most devices running Android 3.2 or older, Settings > Applications > Development – On Android 4.0 and newer, Settings > Developer options – On Android 4.2 and newer, Developer options is hidden by default. Go to Settings > About phone and tap Build number seven times. Return to the previous screen to find Developer options. Page 16
  • 17. Lab Guide Page 17 Lab 1: Setup Android SDK Testing with real Android device • If you're developing on Windows, you need to install the USB driver • Then run your application as usual. A Device Chooser dialog will be shown
  • 18. Lab Guide Page 18 Lab 2: Develop of Simple Android Mobile App • Objective: – Develop a simple BMI calculator program in Android Platform • Task: – Refer to Lab 2 instruction – Create a new Android Project – Use the built-in object to develop the user interface – Write the simple Android program to communicate with the user interface – Test the Android program by emulator
  • 19. Lab Guide Page 19 Lab 2: Develop of Simple Android Mobile App • Create a new Android Project – Package Name have to be unique (e.g. com.crossover.XXXX)
  • 20. Lab Guide Lab 2: Develop of Simple Android Mobile App Use the built-in object to develop the user interface • You can do that by simply drag and drop of widgets like text box, buttons into the form in the WYSIWYG editor in Eclipse. • Open the res/activity_main.xml file under your project from Package Explorer window. Page 20
  • 21. Lab Guide Page 21 Lab 2: Develop of Simple Android Mobile App Use the built-in object to develop the user interface • Open the xml file, you will get to the Graphical Layout editor. • There is a hello world greeting has been added by default. • Just select the "Hello World" label and delete.
  • 22. Lab Guide Page 22 Lab 2: Develop of Simple Android Mobile App Use the built-in object to develop the user interface • Drag a medium text widgets from the Palette to the form • Right click on the text and select “Edit Text...” • Select “New String…”
  • 23. Lab Guide Lab 2: Develop of Simple Android Mobile App Use the built-in object to develop the user interface • Enter – “Your Weight (kg)” in String – “weightLabel” in New R.string • Click OK Page 23
  • 24. Lab Guide Page 24 Lab 2: Develop of Simple Android Mobile App • Next Drag a text field to allow user to input the weight. • That should be a text field that allow user type decimal numbers
  • 25. Lab Guide Page 25 Lab 2: Develop of Simple Android Mobile App • Right click on the newly added text field and click "Edit ID". • Provide a meaningful name to the text field, i.e. "weightText" and click "OK".
  • 26. Page 26 Lab Guide Lab 2: Develop of Simple Android Mobile App • Now add the following widgets to the form: • A "Medium size label" • – string value "Your Height (m)" and R.String as “heightLabel" A text field with decimal numbers. • – id "heightText". A Button. – Right click and select "Other Properties" > "All By Name" > "Text" and add a new String Resource • String: Calculate and R.String: calculateButton • – Similarly set the "onClick" property to "calculateClickHandler". – Set the button's id as "calculateButton". A Large Label. – Give it the id "resultLabel". Set the text property of the label to a empty string. (with the R.String: emptyString)
  • 27. Lab Guide Lab 2: Develop of Simple Android Mobile App • Final UI Page 27
  • 28. Lab Guide Page 28 Lab 2: Develop of Simple Android Mobile App • If you click the activity_main.xml tab in the bottom of the window, you can review or edit the strings and IDs you have associated with widgets
  • 29. Lab Guide Lab 2: Develop of Simple Android Mobile App Write the simple Android program to communicate with the user interface • After designing the UI, we have to write a simple program that trigger BMI calculation when user click the "Calculate" button. • This is written in the src/com.crossover.bmi/MainActivit y.java file. Page 29
  • 30. Lab Guide Page 30 Lab 2: Develop of Simple Android Mobile App Write the simple Android program to communicate with the user interface Program Code: package com.crossover.bmi; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.widget.EditText; import android.widget.TextView;
  • 31. Page 31 Lab Guide Lab 2: Develop of Simple Android Mobile App public class MainActivity extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } public void calculateClickHandler(View view) { // make sure we handle the click of the calculator button if (view.getId() == R.id.calculateButton) { // get the references EditText weightText = EditText heightText = TextView resultText = to the widgets (EditText)findViewById(R.id.weightText); (EditText)findViewById(R.id.heightText); (TextView)findViewById(R.id.resultLabel); // get the users values from the widget references float weight = Float.parseFloat(weightText.getText().toString()); float height = Float.parseFloat(heightText.getText().toString());
  • 32. Lab Guide Lab 2: Develop of Simple Android Mobile App // interpret the meaning of the bmi value String bmiInterpretation = interpretBMI(bmiValue); // now set the value in the result text resultText.setText(bmiValue + "-" + bmiInterpretation); } } // the formula to calculate the BMI index // check for http://en.wikipedia.org/wiki/Body_mass_index private float calculateBMI (float weight, float height) { return (float) (weight / (height * height)); } // interpret what BMI means private String interpretBMI(float bmiValue) { if (bmiValue < 16) { return "Severely underweight"; } else if (bmiValue < 18.5) { return "Underweight"; } else if (bmiValue < 25) { return "Normal"; } else if (bmiValue < 30) { return "Overweight"; } else { return "Obese"; } } } Page 32
  • 33. Lab Guide Lab 2: Develop of Simple Android Mobile App • Test the Android program by emulator Page 33
  • 34. Lab Guide Page 34 Lab 3: Example Coding • Objective: – Try to run the sample coding on Camera & GPS integration, accessibility feature, embedded web content and soliciting feedback from users • Task: – – – – Integration with camera, GPS Coding with accessibility feature Coding including embedded web content Coding for soliciting feedback from users
  • 35. Page 35 Lab Guide Lab 3: Example Coding • To run an application with the feature of camera, GPS location, changing font size, embedded web content and soliciting feedback from users Home Functions Menu
  • 36. Lab Guide Lab 3: Example Coding • Step 1: Create a new project with Package name: com.crossover.labdemo • Step 2: To create the layout of Home Screen (activity_home.xml) – The Home screen should contain an ImageView or Button (with ID: imageView1) Page 36
  • 37. Lab Guide Lab 3: Example Coding • Step 3: Create an activity named HomeActivity.java – Use the code provided – This is the home page of the app – Click on the ImageView then go to the Camera page Page 37
  • 38. Lab Guide Lab 3.1: Integration with camera, GPS • Camera preview screen is on the top of the screen • Tap on the preview screen and a photo will be taken • Photo taken will be shown at the bottom left Page 38
  • 39. Lab Guide Lab 3.1: Integration with camera, GPS Integration with camera: • First, create a layout (named: activity_camera.xml) • As shown on the right, the layout should at least include: – a SurfaceView – an ImageView – an ImageView with an arrow image Page 39
  • 40. Page 40 Lab Guide Lab 3.1: Integration with camera, GPS • SurfaceView – named: “surfaceView1” for the camera preview) • ImageView – named: “imageView1” for the display of the photo taken) • ImageView with an arrow image – named: “camera_next” for going to the next function) surfaceView1 image View1 Camera _next
  • 41. Lab Guide Lab 3.1: Integration with camera, GPS Create a new activity “CameraActivity.java”: • Use the code provided Page 41
  • 42. Lab Guide Page 42 Lab 3.1: Integration with camera, GPS Updating AndroidManifest.xml • Update your AndroidManifest.xml file by adding the following permissions to access camera: <uses-permission android:name="android.permission.CAMERA" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-feature android:name="android.hardware.camera" /> <uses-feature android:name="android.hardware.camera.autofocus" />
  • 43. Lab Guide Lab 3.1: Integration with camera, GPS Page 43
  • 44. Lab Guide Lab 3.1: Integration with camera, GPS • Tap the icon and the device will start getting you GPS location – Latitude – Longitude • Keep updating the location Page 44
  • 45. Lab Guide Lab 3.1: Integration with camera, GPS Integration with GPS: • First, define the layout (named: activity_gps.xml) • As shown on the right, the layout should at least include: – an ImageView – Four TextView in a LinearLayout with ID: “gps_info_layout” and the visibility set as “gone” – Two arrow ImageView (IDs: gps_btn_left & gps_btn_right) Page 45
  • 46. Lab Guide Page 46 Lab 3.1: Integration with camera, GPS • ImageView – ID: “gps_location_btn” act as a button to start getting the location) • Four TextView – ID: “gps_location_lat” to display the latitude) – ID: “gps_location_lng” to display the longitude) – ID: “gps_location_accu” to display the accuracy) – ID: “gps_location_count” to display the number of updates)
  • 47. Lab Guide Lab 3.1: Integration with camera, GPS Create a new activity “GPSActivity.java”: • Use the code provided Page 47
  • 48. Lab Guide Page 48 Lab 3.1: Integration with camera, GPS Updating AndroidManifest.xml • Update your AndroidManifest.xml file by adding the following permissions to access location: <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
  • 49. Lab Guide Lab 3.1: Integration with camera, GPS Page 49
  • 50. Lab Guide Lab 3.2: Accessibility Feature • Able to change the font size of the words on the screen Page 50
  • 51. Lab Guide Lab 3.2: Accessibility Feature Change font size: • First, define the layout (named: activity_access.xml) • As shown on the right, the layout should at least include: – a TextView – a spinner – Two arrow ImageView (IDs: access_left & access_right) Page 51
  • 52. Lab Guide Page 52 Lab 3.2: Accessibility Feature • TextView – ID: “access_text” – The font size of these words to be changed • Spinner – ID: “spinner1” – For the user to choose the font size
  • 53. Lab Guide Lab 3.2: Accessibility Feature Create a new activity “AccessActivity.java”: • Use the code provided Page 53
  • 54. Lab Guide Lab 3.3: Embedded Web Content • Example: • Embed www.google.com.hk inside the application Page 54
  • 55. Lab Guide Lab 3.3: Embedded Web Content Embedded Web Content : • First, define the layout (named: activity_web.xml) • As shown on the right, the layout should at least include: – a WebView – Two arrow ImageView (IDs: web_left & web_right) Page 55
  • 56. Lab Guide Lab 3.3: Embedded Web Content • WebView – ID: “mybrowser” – To display the website in this view Page 56
  • 57. Lab Guide Lab 3.3: Embedded Web Content Create a new activity “AccessActivity.java”: • Use the code provided Page 57
  • 58. Lab Guide Page 58 Lab 3.3: Embedded Web Content Updating AndroidManifest.xml • Update your AndroidManifest.xml file by adding the following permissions to access internet: <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
  • 59. Lab Guide Lab 3.3: Embedded Web Content Page 59
  • 60. Lab Guide Lab 3.4: Soliciting Feedback from Users • A form is included in the application for the users to submit comment • The comment will be sent by email Page 60
  • 61. Lab Guide Lab 3.4: Soliciting Feedback from Users Embedded Web Content : • First, create a new layout (named: activity_form.xml) • As shown on the right, the layout should at least include: – – – – Two Test Fields a TextView Two ImageView a arrow ImageView with ID: form_left) Page 61
  • 62. Lab Guide Page 62 Lab 3.4: Soliciting Feedback from Users • Test Field • – ID: “form_name” – For user to fill in the name TestView • – ID: “form_date” – For user to select the date, and display the selected date Test Field • – ID: “form_comment” – For user to fill in the comment ImageView • – ID: “form_submit” – For user to submit the form ImageView – ID: “form_clear” – For user to clear the form
  • 63. Lab Guide Lab 3.4: Soliciting Feedback from Users Embedded Web Content : • Then create another new layout (named: date_time_dialog.xml) • This is used for the date time picker dialog • As shown on the right, the layout should at least include: – a DatePicker (ID: “date_picker”) – a TimePicker (ID: “time_picker”) Page 63
  • 64. Lab Guide Lab 3.4: Soliciting Feedback from Users Create a new activity “FormActivity.java”: • Use the code provided Page 64
  • 65. Lab Guide Page 65 Lab 4: Submission of Mobile App to Application Store • Objective: – Register the Android Developer account and publish the App • Task: Refer to Lab 4 instruction Digitally sign the application Register the Android Developer account Prepare the image and document for mobile app – Publish the app to Google Play – – – –
  • 66. Lab Guide Page 66 Lab 4: Submission of Mobile App to Application Store • Set up to start publishing on Google Play: 1. Register for a Google Play publisher account 2. If you will sell apps, set up a Google Wallet Merchant Account 3. Explore the Google Play Developer Console and learn about the tools for publishing
  • 67. Lab Guide Page 67 Lab 4: Submission of Mobile App to Application Store Register for a publisher account • Visit the Google Play Developer Console at https://play.google.com/apps/publish/. • Enter basic information about your developer identity • Read and accept the Developer Distribution Agreement. • Pay a $25 USD registration fee using Google Wallet. – If you don't have a Google Wallet account, you can quickly set one up during the process.
  • 68. Page 68 Lab Guide Lab 4: Submission of Mobile App to Application Store Register for a publisher account • Tips – You need a Google account to register. • You can create one during the process. – If you are an organization, consider registering a new Google account rather than using a personal account.
  • 69. Page 69 Lab Guide Lab 4: Submission of Mobile App to Application Store Set up a Google Wallet Merchant account • If you want to sell products on Google Play you will also need to set up a Google Wallet Merchant Account. – Include priced apps, in-app products, or subscriptions • To set up a Merchant account from the Developer Console: – Sign in to your Google Play Developer Console – Open Financial reports on the side navigation. – Click Setup a Merchant Account now. – This takes you to the Google Wallet site to sign up as a Merchant • you'll need information about your business available to complete this step.
  • 70. Lab Guide Page 70 Lab 4: Submission of Mobile App to Application Store • Developer Console All applications page: A quick overview of your apps, lets you jump to stats, reviews, and product details, or upload a new app.
  • 71. Lab Guide Page 71 Lab 4: Submission of Mobile App to Application Store Multiple user accounts • If you are working with a team, you can set up multiple user accounts to access different parts of your Developer Console. • The first account registered is the account owner, with full access to all parts of the Console. • The owner can add user accounts and manage what parts of the Console they have access to. – For example, grant users access to publishing and app configuration, but not access to financial reports.
  • 72. Page 72 Lab Guide Lab 4: Submission of Mobile App to Application Store • Preparation for submitting a new App: – Digitally signed package file (.apk file) – App icon (512 x 512 pixels, 32-bit PNG) – Promotional materials • • • • Screenshots (for Phone, 7-inch tablet, 10-inch tablet) Feature Graphic Promo Graphic Promo Video – App Description
  • 73. Lab Guide Lab 4: Submission of Mobile App to Application Store Export Signed Application Package • Before submitting to the Google Play, you need to sign the application by a unique Keystore • Right click the application package in eclipse > Android Tools > Export Signed Application Package… Page 73
  • 74. Lab Guide Page 74 Lab 4: Submission of Mobile App to Application Store • Confirm the project to be signed > Next • Create new keystore > choose save location > enter the password twice > Next
  • 75. Lab Guide Page 75 Lab 4: Submission of Mobile App to Application Store • Enter the information for the key and choose the destination to save the exported APK • Done! Keep the keystore file for future update and memorize the passwords
  • 76. Lab Guide Lab 4: Submission of Mobile App to Application Store Page 76
  • 77. Lab Guide Lab 4: Submission of Mobile App to Application Store Remarks: • If you publish your app as free, it must remain free. • If you publish it as priced, you can later change it to free. Page 77
  • 78. Lab Guide Page 78 Lab 4: Submission of Mobile App to Application Store • Upload the Signed APK file and publish your app • Wait for a few hours, and your app will be found in the Google play
  • 79. Lab Guide Lab 5: Reporting and Statistics Collection • Objective: – Reporting and Statistics Collection • Task: – – – – Refer to Lab 5 instruction Setup the Google Analytics account Register the app for usage collection Add the Google Analytics Code to the application done in Lab 2 Page 79
  • 80. Lab Guide Lab 5: Reporting and Statistics Collection User reviews and crash reports • Google Play makes it easy for users to submit reviews of your app. • Give you usability feedback, support requests, and important functionality issues direct from your customers. • In the Developer Console, you can also see the crash reports submitted automatically from Android devices, for debugging and improving your app. Page 80
  • 81. Lab Guide Lab 5: Reporting and Statistics Collection App statistics • The Developer Console gives you detailed statistics of your app. • You can view installations of your app measured by unique users and unique devices. • For user installations, you can view active installs, total installs, daily installs and uninstalls, and metrics about user ratings. • For devices, you can see active installs as well as daily installs, uninstalls, and upgrades. • You can zoom into the installation numbers along several dimensions, including Android platform version, device, country, language, app version, and carrier (mobile operator). Page 81
  • 82. Lab Guide Page 82 Lab 5: Reporting and Statistics Collection Google Analytics SDK for Android • Makes it easy for developers to collect user engagement data from their apps. • Before implementing the SDK, make sure you have the following: – Google Analytics SDK for Android v3 – An Android app that you can use to implement the Google Analytics – A new Google Analytics app property and view. • Download SDK: – https://developers.google.com/analytics/devguides/ collection/android/resources
  • 83. Lab Guide Lab 5: Reporting and Statistics Collection • After downloading the SDK, Add the library to your project by right click your project in the Package Explorer and select “Properties” Page 83
  • 84. Lab Guide Lab 5: Reporting and Statistics Collection • In the Properties window, go to the “Java Build Path” page and select the “Libraries” Tab • Click “Add External JARs…” and select the .jar file in the SDK you have just downloaded Page 84
  • 85. Lab Guide Page 85 Lab 5: Reporting and Statistics Collection Create a new Google Analytics app property • https://www.google.com/analytics/ • Create a new Google Analytics account and login • Create a new application to get a new tracking ID
  • 86. Lab Guide Page 86 Lab 5: Reporting and Statistics Collection • There are three steps to getting started with the SDK: – Update AndroidManifest.xml – Add EasyTracker methods – Create your analytics.xml file
  • 87. Lab Guide Page 87 Lab 5: Reporting and Statistics Collection Updating AndroidManifest.xml • Update your AndroidManifest.xml file by adding the following permissions: <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
  • 88. Lab Guide Page 88 Lab 5: Reporting and Statistics Collection Adding EasyTracker methods • Add the send methods to the onStart() and onStop() methods of each of your Activities
  • 89. Lab Guide Page 89 Lab 5: Reporting and Statistics Collection package com.example.app; import android.app.Activity; import com.google.analytics.tracking.android.EasyTracker; /** * An example Activity using Google Analytics and EasyTracker. */ public class myTrackedActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); } @Override public void onStart() { super.onStart(); ... // The rest of your onStart() code. EasyTracker.getInstance(this).activityStart(this); // Add this method. } @Override public void onStop() { super.onStop(); ... // The rest of your onStop() code. EasyTracker.getInstance(this).activityStop(this); // Add this method. } }
  • 90. Lab Guide Page 90 Lab 5: Reporting and Statistics Collection Creating your analytics.xml file • When you use EasyTracker, global configuration settings are managed using resources defined in XML. • Create a file called analytics.xml in your project's res/values directory and add the following resources:
  • 91. Lab Guide Page 91 Lab 5: Reporting and Statistics Collection <?xml version="1.0" encoding="utf-8" ?> <resources> <!--Replace placeholder ID with your tracking ID--> <string name="ga_trackingId">UA-XXXX-Y</string> <!--Enable automatic activity tracking--> <bool name="ga_autoActivityTracking">true</bool> <!--Enable automatic exception tracking--> <bool name="ga_reportUncaughtExceptions">true</bool> </resources>
  • 92. - End -

×