Presentation is loading. Please wait.

Presentation is loading. Please wait.

6: Getting Started with Android. Android Android Inc. was initially started in 2003 It was acquired by Google in 2005 The hardware side of Android is.

Similar presentations


Presentation on theme: "6: Getting Started with Android. Android Android Inc. was initially started in 2003 It was acquired by Google in 2005 The hardware side of Android is."— Presentation transcript:

1 6: Getting Started with Android

2 Android Android Inc. was initially started in 2003 It was acquired by Google in 2005 The hardware side of Android is supported by the Open Handset Alliance (OHA). Android had its fi rst major release in late 2008. The Android OS was built on a modified Linux kernel and applications are written in Java.

3 WHO SUPPORTS ANDROID? HTC, LG, Motorola, and Samsung are the major players in the Android smartphone market. Archos, Dell, Samsung, and Toshiba hold the largest pieces of the Android tablet market. You should note that Amazon’s Kindle Fire and Nook Color are up-and-comers and use a customized version of the Android tablet (Version 3) OS on their devices

4 ANDROID AS COMPETITION TO ITSELF Because Android was designed to be run on many different types of devices. Because of the open nature of the Android OS, it is commonplace for manufacturers to create vendor- specific builds of Android, and when this happens you are beholden to them for OS updates. Additionally in these custom builds, vendor-specific limitations have arisen such as the vendor-specific market. Another issue that has cropped up is the lack of over- the-air (OTA) distribution of OS updates by cellular carriers.

5 Multiple Markets and Market Locks Depending on your version of Android, and depending on the manufacturer of a given device. You often find on cheap and imported Android devices a version of Google Play that is maintained by the manufacturer. They pick and choose what applications are available from the whole set in the marketplace. The version of the Android SDK that you need to support depends on what devices you want to support. If you want to target most phones available right now, you should support Android 2.2 or 2.3. “Gingerbread” (2.3) is the last widely available version for those devices. Once you have decided on a version to deploy your application against, you need to set up your development environment.

6 GETTING THE TOOLS YOU NEED Downloading and Installing JDK Downloading and Installing Eclipse Downloading and Installing the Android SDK Downloading and Configuring the Eclipse ADT Plug-in Installing Additional SDK Components Development BUILDING THE DERBY APP IN ANDROID

7 Downloading and Installing JDK

8 Downloading and Installing Eclipse

9 Downloading and Installing the Android SDK

10 Downloading and Configuring the Eclipse ADT Plug-in

11 Use the Update Manager feature of your Eclipse installation to install the latest revision of ADT on your development computer. Follow these steps: 1. Start Eclipse and select Help ➪ Install New Software. 2. Click Add in the top-right corner. 3. In the Add Repository dialog box that appears, enter ADT plug-in for the name and the following URL for the location: https://dl- ssl.google.com/android/eclipse/.https://dl- ssl.google.com/android/eclipse/ 4. Click OK. If you have trouble acquiring the plug-in, try using “http” in the Location URL instead of “https” (“https” is preferred for security reasons). 5. In the Available Software dialog box, select the checkbox next to Developer Tools and click Next. 6. The next window shows a list of the tools to be downloaded. Click Next. 7. Read and accept the license agreements and then click Finish. If you get a security warning saying that the authenticity or validity of the software can’t be established, click OK. 8. When the installation completes, restart Eclipse.

12 Downloading and Configuring the Eclipse ADT Plug-in After you’ve successfully downloaded the ADT, the next step is to modify your ADT preferences in Eclipse to point to the Android SDK directory (see Figure 6-5): 1. Select Window ➪ Preferences to open the Preferences panel. In Mac OS X, click Eclipse ➪ Preferences. 2. Select Android from the left panel. 3. You may see a dialog box asking whether you want to send usage statistics to Google. If so, make your choice and click Proceed. You cannot continue with this procedure until you click Proceed. 4. For the SDK Location in the main panel, click Browse and locate your downloaded SDK directory. 5. Click Apply and then click OK.

13 Downloading and Configuring the Eclipse ADT Plug-in

14 Installing Additional SDK Components

15 Loading the Android SDK Manager in Eclipse takes only a few steps: 1. Open Eclipse. 2. Select Window ➪ Android SDK and AVD Manager. 3. Select Available Packages in the left panel. This reveals all of the components that are currently available for download from the SDK repository. 4. Select the component(s) you’d like to install and click Install Selected. 5. Verify and accept the components you want (ensure each one is selected with a green checkmark) and click Install. The components will now be installed into your existing Android SDK directories.

16 Development - Creating a New Project

17 Development – Naming your project

18 Development – configuring application information

19 Development – choosing sdk version for your app

20 Project Structure All of your code lives within your src folder. The res folder holds layouts and resources for different hardware specs. The layout subfolder holds all of your XML layouts. All of your XML layouts are stored in the layout subfolder of res, and your code will be linked under the namespace in your src folder of the project view.

21 Project Structure All of your code lives within your src folder. The res folder holds layouts and resources for different hardware specs. The layout subfolder holds all of your XML layouts. All of your XML layouts are stored in the layout subfolder of res, and your code will be linked under the namespace in your src folder of the project view.

22 Project Structure – Manifest File

23 Project Structure – Manifest File – Application Editor

24

25 Project Structure – Manifest File – Permissions Editor

26 Project Structure – Manifest File xml

27 Android Basics - Creating User Interfaces - Basic Android UI Elements

28

29

30

31

32

33 Android Basics - Creating User Interfaces - Basic Android Layouts and Views ➤ FrameLayout: This is very simplistic and can really contain only a single UI element. You can, in fact, have multiple elements but they overlap each other by default. The example code shown here is rendered in Figure 6-17:

34 Android Basics - Creating User Interfaces - Basic Android Layouts and Views

35

36

37

38 Creating an Android Virtual Device You need to create an Android Virtual Device (AVD) in order to debug your application in the emulator, because this “device” is what the emulator runs. Creating an AVD is quite easy. Eclipse includes a tool called AVD Manager (click Window Manager ➪ AVD Manager). You need to name your AVD instance, choose its OS version (Target), pick a skin (with which you can customize the look and feel of the emulator) and resolution, and specify the hardware details for the device (amount of RAM, size of SD card, and sensors like Accelerometer and GPS). Once you have configured it to your specifications, click Create AVD and you are all set.

39 Debugging

40

41 CONNECTING TO THE GOOGLE PLAY Getting Signing Your Application Signing your application with Eclipse is a relatively simple process: 1. Right-click your project in the Package Explorer and select File ➪ Export. 2. Select Export Android Application. 3. Complete the steps of the wizard and you will have a keystore, and a signed release build of your app ready for the market.ng an Android Developer Account

42 CONNECTING TO THE GOOGLE PLAY ANDROID DEVELOPMENT PRACTICES Android Fundamentals – Activities Activities are the individual screens in your application. – Services Services are components that run in a background thread. – Content Providers Content providers are interfaces to the offl ine storage that you have within your app. – Broadcast Receivers Broadcast receivers are components that respond to system messages.

43 CONNECTING TO THE GOOGLE PLAY Fragments as UI Elements – Starting in Android 3.x, there has been a shift in design elements to account for the significant differences between the screen sizes of tablets versus handsets.Whereas normally UI design for mobile devices is very rigid, Fragments add a level of fl exibility. Fragments themselves live as a subactivity that you can reference in multiple places in your application. Fragments live within the scope of their parent activity, but can be used in multiple activities. Ask for Permission – The users of your application must approve of what functionality you want to leverage on their device. To prompt the user for what you need, and so that your device will behave as designed, you need to add permission requests in your application’s manifest. Visit http://developer.android.com/reference/android/Manifest.permission.html for a list the various permissions you can request when developing.http://developer.android – Depending on what version of the OS you are targeting you are afforded additional permissions. – One of the newest permissions available is READ_SOCIAL_STREAM, which enables you to access the user’s social stream. One of the oldest permissions is your ability to set the given time zone, using, you guessed, it SET_TIME_ZONE. Mind the Back Stack – Unlike iOS-based devices, all Android devices have a hardware back button.

44 BUILDING THE DERBY APP IN ANDROID - Common Interactions UI Navigation and Using Back Stack – Use the GetExtra command to retrieve simple and complex objects from one activity to another using an Intent. You can select the extras you want to refer to individually from the Intent. For example: String id = getIntent().getStringExtra(“id”); String name = getIntent().getStringExtra(“name”) Or you can get all of the objects you passed along as a Bundle: Bundle extras = getIntent().getExtras(); String userName; String id; if (extras != null) { userName = extras.getString(“name”); id = extras.getString(“id”); }

45 BUILDING THE DERBY APP IN ANDROID - Common Interactions Use the PutExtra command to put the object you want to pass between activities. You can pass simple or complex objects. You need to use Extras only when you want to pass data between activities. It is not necessary to set a complex state transfer process if you don’t need that data.

46 BUILDING THE DERBY APP IN ANDROID - Notifications Toast Alerts

47 BUILDING THE DERBY APP IN ANDROID - Notifications Alerts

48 BUILDING THE DERBY APP IN ANDROID - Ofline Storage SQLite

49 BUILDING THE DERBY APP IN ANDROID - Offline Storage SQLite

50 BUILDING THE DERBY APP IN ANDROID - Offline Storage SQLite

51 BUILDING THE DERBY APP IN ANDROID - SharedPreferences SharedPreferences is a set of key-value pairs saved on your device that is helpful for storing instance-specific data as it pertains to the app. The main concern is the level of privacy that you impose upon it. If you make it world-readable its value can be accessed by any application should another application query against your key.

52 BUILDING THE DERBY APP IN ANDROID - Web Service

53

54 Long Running Task on Web

55 BUILDING THE DERBY APP IN ANDROID - GPS public class SensorsGPS extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); LocationManager locManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); LocationListener locListener = new MyLocationListener(); locManager.requestLocationUpdates(LocationManager. GPS_PROVIDER, 0, 0, locListener); }

56 BUILDING THE DERBY APP IN ANDROID - Accelerometer public class SensorsAccel extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); /* do this in onCreate */ mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE mSensorManager.registerListener(mSensorListener, mSensorManager. getDefaultSensor(Sensor.TYPE_ACCELEROMETER), SensorManager.SENSOR_DELAY_NORMAL); mAccel = 0.00f; mAccelCurrent = SensorManager.GRAVITY_EARTH; mAccelLast = SensorManager.GRAVITY_EARTH; }

57 BUILDING THE DERBY APP IN ANDROID - Accelerometer

58

59 Thank You


Download ppt "6: Getting Started with Android. Android Android Inc. was initially started in 2003 It was acquired by Google in 2005 The hardware side of Android is."

Similar presentations


Ads by Google