In this tutorial, I decided to cover all of the topics I would need, so that in every tutorial that follows I can just make apps. Don’t try to memorize everything! Here I’m just covering a bunch of things you need to be familiar with.
We’ll cover the lifecycle of an Android activity completely. We’ll then look at how to make an app support many languages. We’ll look at how to grab string resources and how to pull them into java and xml files. Finally, we’ll look at the AndroidManifest.xml file in detail.
If you like videos like this, it helps to tell Google+ with a click here
Cheat Sheet From the Video
<?xml version="1.0" encoding="utf-8"?> <!-- The manifest defines requirements, components and security for your app package: package name for the app versionCode: Used to track app versions versionName: App version displayed to users --> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.newthinktank.helloworld" android:versionCode="1" android:versionName="1.0" > <!-- uses-sdk defines the minimum and maximum sdk version required on a device to run your app. Always set min or it will default to 1 and probably crash. The targetSdkVersion should always be set to the latest version even if you aren't using anything special from its api. It is best not to set a maximum sdk --> <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="17" /> <!-- The uses-configuration defines hardware and software features your app requires. Normally Not Needed because you should aim to have your app work on any device. reqFiveWayNav: input device capable of navigating up, down, left, right reqHardKeyboard: hardware keyboard reqKeyboardType: required keyboard type reqNavigation: required navigation device type reqTouchScreen: required touchscreen type <uses-configuration android:reqFiveWayNav=["true" | "false"] android:reqHardKeyboard=["true" | "false"] android:reqKeyboardType=["undefined" | "nokeys" | "qwerty" | "twelvekey"] android:reqNavigation=["undefined" | "nonav" | "dpad" | "trackball" | "wheel"] android:reqTouchScreen=["undefined" | "notouch" | "stylus" | "finger"] /> --> <!-- You can define numerous hardware features your app requires using uses-feature tags like this. You are in essence requesting permission to use this hardware. Full list here: http://developer.android.com/guide/topics/manifest/uses-feature-element.html If you want to note that it isn't required mark required as false. <uses-feature android:name="android.hardware.bluetooth" android:required="false" /> You can also set a minimum OpenGL version like this (Version 2.1) <uses-feature android:glEsVersion="0x00020001" /> --> <!-- A permission is used to restrict access to application components. <permission android:description="string resource" android:icon="drawable resource" android:label="string resource" android:name="string" android:permissionGroup="string" android:protectionLevel=["normal" | "dangerous" | "signature" | "signatureOrSystem"] /> description: A description of the permission that can be provided if a user requests it icon: A icon that represents the permission label: The permissions name that is provided to a user name: When you want to refer to the permission in code use this name permissionGroup: The group of permissions that this one belongs with protectionLevel: The risk possibilities associated with giving permission - normal: Low risk permission that shouldn't hurt other applications, the system, or the user - dangerous: Higher risk permission that could provide access to private user info and could hurt the system - signature: A permission the system grants only if the requesting app has the same certificate as the app that created the permission. - signatureOrSystem: Avoid this --> <!-- A uses-permission requests access to restricted code or data on a device. Each permission has a unique label. At install time the user will decide if it is ok to grant this power. If permission isn't granted the app may fail. Here is an example <uses-permission android:name="android.permission.READ_OWNER_DATA" /> --> <!-- supports-screens allows you to specify the screen sizes your app supports. Normally resizing applied by the system works for most apps and it doesn't require you to do anything if your app needs resized. You use this to define screen sizes that your app won't work with <supports-screens android:resizeable=["true"| "false"] // Is app resizeable android:smallScreens=["true" | "false"] // Does app work on screens smaller then HVGA android:normalScreens=["true" | "false"] // Does app work on normal cell phone screens android:largeScreens=["true" | "false"] // Does app work on screens larger then cell phones android:xlargeScreens=["true" | "false"] // Does app work on tablet screens and larger android:anyDensity=["true" | "false"] // Don't touch this (True by Default) android:requiresSmallestWidthDp="integer" // Ignore this android:compatibleWidthLimitDp="integer" // Upper bound your app may not work with android:largestWidthLimitDp="integer"/> // Upper bound your app definitely won't work with The last 2 either forces the user, or provide the user with the option to enable screen compatibility mode --> <!-- There is only one application node. There are many attributes available here: http://developer.android.com/guide/topics/manifest/application-element.html allowBackup: If false no backup or restore of the app will be performed icon: Reference to a drawable resource that represents the apps default icon label: The label that represents the app to the user theme: Reference to a style resource that represents the default theme --> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme"> <!-- activity declares any part of an apps interface and the main launch activity that you want to run. name: The class name that implements the activity label: Displayed on the screen if the activity is displayed --> <activity android:name="com.newthinktank.helloworld.MainActivity" android:label="@string/app_name" > <!-- Each activity has intent-filter tags. An intent is an operation that can be performed. Here we define the intents an activity can respond to. The intent-filter must contain one or more actions. Below MAIN and LAUNCHER tells Android that this activity is the starting activity. --> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> <!-- service tags are used to implement background operations, or a communications API that is called by other applications. A service is any component that performs a long running operation or supplies functionality to other apps. <service android:name="MyService" android:icon="@drawable/icon" android:label="@string/service_name"> </service> --> <!-- provider tags specify content providers used by the app. A content provider manages access to data repositories such as databases. --> </manifest>