Académique Documents
Professionnel Documents
Culture Documents
Search
QUICK
Table of Contents LINKS
http://www.vogella.com/tutorials/Android/article.html 4/11/2016
Android development with Android Studio - Tutorial Page 2 of 57
Search
QUICK
LINKS
http://www.vogella.com/tutorials/Android/article.html 4/11/2016
Android development with Android Studio - Tutorial Page 3 of 57
Search
QUICK
LINKS
http://www.vogella.com/tutorials/Android/article.html 4/11/2016
Android development with Android Studio - Tutorial Page 4 of 57
Search
QUICK
LINKS
Table 1. Android versions
http://www.vogella.com/tutorials/Android/article.html 4/11/2016
Android development with Android Studio - Tutorial Page 5 of 57
Search
QUICK
LINKS
http://www.vogella.com/tutorials/Android/article.html 4/11/2016
Android development with Android Studio - Tutorial Page 6 of 57
Search
QUICK
LINKS
http://www.vogella.com/tutorials/Android/article.html 4/11/2016
Android development with Android Studio - Tutorial Page 7 of 57
Search
QUICK
LINKS
CONSOLE
http://www.vogella.com/tutorials/Android/article.html 4/11/2016
Android development with Android Studio - Tutorial Page 8 of 57
Search
QUICK
LINKS
http://www.vogella.com/tutorials/Android/article.html 4/11/2016
Android development with Android Studio - Tutorial Page 9 of 57
Search
QUICK
LINKS
http://www.vogella.com/tutorials/Android/article.html 4/11/2016
Android development with Android Studio - Tutorial Page 10 of 57
Search
QUICK
LINKS
http://www.vogella.com/tutorials/Android/article.html 4/11/2016
Android development with Android Studio - Tutorial Page 11 of 57
Search
QUICK
LINKS
http://www.vogella.com/tutorials/Android/article.html 4/11/2016
Android development with Android Studio - Tutorial Page 12 of 57
Search
QUICK
LINKS
http://www.vogella.com/tutorials/Android/article.html 4/11/2016
Android development with Android Studio - Tutorial Page 13 of 57
Search
QUICK
LINKS
3.3. Create a virtual device (AVD)
http://www.vogella.com/tutorials/Android/article.html 4/11/2016
Android development with Android Studio - Tutorial Page 14 of 57
Search
QUICK
LINKS
http://www.vogella.com/tutorials/Android/article.html 4/11/2016
Android development with Android Studio - Tutorial Page 15 of 57
Search
QUICK
LINKS
http://www.vogella.com/tutorials/Android/article.html 4/11/2016
Android development with Android Studio - Tutorial Page 16 of 57
Search
QUICK
LINKS
http://www.vogella.com/tutorials/Android/article.html 4/11/2016
Android development with Android Studio - Tutorial Page 17 of 57
Search
http://www.vogella.com/tutorials/Android/article.html 4/11/2016
Android development with Android Studio - Tutorial Page 18 of 57
Search
QUICK
LINKS
http://www.vogella.com/tutorials/Android/article.html 4/11/2016
Android development with Android Studio - Tutorial Page 19 of 57
Search
QUICK
5.4. Speed optimization with GPU rendering LINKS
http://www.vogella.com/tutorials/Android/article.html 4/11/2016
Android development with Android Studio - Tutorial Page 20 of 57
Search
QUICK
LINKS
5.6. Installation of the Intel emulator on Windows
http://www.vogella.com/tutorials/Android/article.html 4/11/2016
Android development with Android Studio - Tutorial Page 21 of 57
Search
QUICK
LINKS
5.7. Installation of the Intel emulator on Linux
http://www.vogella.com/tutorials/Android/article.html 4/11/2016
Android development with Android Studio - Tutorial Page 22 of 57
Search
QUICK
LINKS
http://www.vogella.com/tutorials/Android/article.html 4/11/2016
Android development with Android Studio - Tutorial Page 23 of 57
Search
QUICK
LINKS
http://www.vogella.com/tutorials/Android/article.html 4/11/2016
Android development with Android Studio - Tutorial Page 24 of 57
Search
QUICK
LINKS
XML
http://www.vogella.com/tutorials/Android/article.html 4/11/2016
Android development with Android Studio - Tutorial Page 25 of 57
Search
xmlns:android "http://schemas.android.com/apk/res/android"
package "com.example.android.rssreader"
-
android:minSdkVersion "16"
android:targetSdkVersion "19" /> QUICK
<uses-permission
android:name "android.permission.INTERNET" />
LINKS
<application
android:name "RssApplication"
android:allowBackup "false"
android:icon "@drawable/ic_launcher"
android:label "@string/app_name"
android:theme "@style/AppTheme" >
<activity
android:name "RssfeedActivity"
android:label "@string/title_activity_main" >
<intent-filter>
<action
android:name "android.intent.action.MAIN" />
<category
android:name "android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name ".DetailActivity"
android:label "Details" >
</activity>
<activity android:name "MyPreferenceActivity" >
</activity>
</manifest>
http://www.vogella.com/tutorials/Android/article.html 4/11/2016
Android development with Android Studio - Tutorial Page 26 of 57
Search
QUICK
LINKS
7.6. Permissions
http://www.vogella.com/tutorials/Android/article.html 4/11/2016
Android development with Android Studio - Tutorial Page 27 of 57
Search
QUICK
7.7. Required device configuration LINKS
XML
<uses-configuration android:reqHardKeyboard "true"/>
XML
<uses-feature android:name "android.hardware.camera" />
8. Resources
8.1. Resource files
http://www.vogella.com/tutorials/Android/article.html 4/11/2016
Android development with Android Studio - Tutorial Page 28 of 57
Search
XML
http://www.vogella.com/tutorials/Android/article.html 4/11/2016
Android development with Android Studio - Tutorial Page 29 of 57
Search
<resources>
</resources>
XML
http://www.vogella.com/tutorials/Android/article.html 4/11/2016
Android development with Android Studio - Tutorial Page 30 of 57
Search
xmlns:android "http://schemas.android.com/apk/res/android"
xmlns:tools "http://schemas.android.com/tools"
android:layout_height "match_parent"
" "
"
android:paddingRight "@dimen/activity_horizontal_margin"
android:paddingTop "@dimen/activity_vertical_margin"
tools:context ".MainActivity" >
QUICK
<TextView
LINKS
android:id "@+id/mytext"
android:layout_width "wrap_content"
android:layout_height "wrap_content"
android:text "@string/hello_world" />
</RelativeLayout>
JAVA
package
import android.os.Bundle
import android.app.Activity
import android.view.Menu
MainActivity
@Override
super
XML
http://www.vogella.com/tutorials/Android/article.html 4/11/2016
Android development with Android Studio - Tutorial Page 31 of 57
Search
android:id "@+id/button1"
android:layout_width "wrap_content"
QUICK
LINKS
XML
<?xml version="1.0" encoding="utf-8"?>
<resources>
<item name "button1" type "id"/>
</resources>
XML
<RelativeLayout
xmlns:android "http://schemas.android.com/apk/res/android"
xmlns:tools "http://schemas.android.com/tools"
android:layout_width "match_parent"
android:layout_height "match_parent"
tools:context ".MainActivity" >
<Button
android:id "@id/button1"
android:layout_width "wrap_content"
android:layout_height "wrap_content"
android:layout_centerHorizontal "true"
android:layout_centerVertical "true"
android:layout_marginRight "27dp"
android:text "Button" />
</RelativeLayout>
8.7. System resources
http://www.vogella.com/tutorials/Android/article.html 4/11/2016
Android development with Android Studio - Tutorial Page 32 of 57
Search
QUICK
9.2. Using a layout manager LINKS
http://www.vogella.com/tutorials/Android/article.html 4/11/2016
Android development with Android Studio - Tutorial Page 33 of 57
Search
QUICK
LINKS
9.5. FrameLayout
9.6. LinearLayout
http://www.vogella.com/tutorials/Android/article.html 4/11/2016
Android development with Android Studio - Tutorial Page 34 of 57
Search
QUICK
LINKS
9.7. RelativeLayout
XML
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android "http://schemas.android.com/apk/res/android"
android:layout_width "match_parent"
android:layout_height "match_parent"
android:orientation "vertical" >
<ProgressBar
android:id "@+id/progressBar1"
style "?android:attr/progressBarStyleLarge"
android:layout_width "wrap_content"
android:layout_height "wrap_content"
android:layout_centerInParent "true"
/>
</RelativeLayout>
9.8. GridLayout
http://www.vogella.com/tutorials/Android/article.html 4/11/2016
Android development with Android Studio - Tutorial Page 35 of 57
Search
QUICK
<?xml version="1.0" encoding="utf-8"?>
<GridLayout
XML
LINKS
xmlns:android "http://schemas.android.com/apk/res/android"
android:id "@+id/GridLayout1"
android:layout_width "match_parent"
android:layout_height "match_parent"
android:columnCount "4"
android:useDefaultMargins "true" >
<TextView
android:layout_column "0"
android:layout_columnSpan "3"
android:layout_gravity "center_horizontal"
android:layout_marginTop "40dp"
android:layout_row "0"
android:text "User Credentials"
android:textSize "32dip" />
<TextView
android:layout_column "0"
android:layout_gravity "right"
android:layout_row "1"
android:text "User Name: " >
</TextView>
<EditText
android:id "@+id/input1"
android:layout_column "1"
android:layout_columnSpan "2"
android:layout_row "1"
android:ems "10" />
<TextView
android:layout_column "0"
android:layout_gravity "right"
android:layout_row "2"
android:text "Password: " >
</TextView>
<EditText
android:id "@+id/input2"
android:layout_column "1"
android:layout_columnSpan "2"
android:layout_row "2"
android:inputType "textPassword"
android:ems "8" />
<Button
android:id "@+id/button1"
android:layout_column "2"
android:layout_row "3"
android:text "Login" />
</GridLayout>
http://www.vogella.com/tutorials/Android/article.html 4/11/2016
Android development with Android Studio - Tutorial Page 36 of 57
Search
QUICK
LINKS
9.9. ScrollView
XML
http://www.vogella.com/tutorials/Android/article.html 4/11/2016
Android development with Android Studio - Tutorial Page 37 of 57
Search
<ScrollView
xmlns:android "http://schemas.android.com/apk/res/android"
android:layout_height "match_parent"
" "
<TextView
android:id "@+id/TextView01"
QUICK
android:layout_width "wrap_content"
android:layout_height "wrap_content"
LINKS
android:paddingLeft "8dip"
android:paddingRight "8dip"
android:paddingTop "8dip"
android:text "This is a header"
android:textAppearance "?
android:attr/textAppearanceLarge" >
</TextView>
</ScrollView>
Table 6. ID Assignment
XML
http://www.vogella.com/tutorials/Android/article.html 4/11/2016
Android development with Android Studio - Tutorial Page 38 of 57
Search
xmlns:android "http://schemas.android.com/apk/res/android"
xmlns:tools "http://schemas.android.com/tools"
android:layout_height "match_parent"
" "
"
android:paddingRight "@dimen/activity_horizontal_margin"
android:paddingTop "@dimen/activity_vertical_margin"
tools:context ".MainActivity" >
QUICK
LINKS
<EditText
android:layout_width "wrap_content"
android:layout_height "wrap_content"
android:id "@+id/main_input"
android:layout_alignParentTop "true"
android:layout_alignParentStart "true"
android:layout_alignParentEnd "true" />
<Button
android:layout_width "wrap_content"
android:layout_height "wrap_content"
android:text "Start"
android:id "@+id/button"
android:layout_below "@id/main_input"
android:layout_alignParentStart "true"
android:onClick "onClick"/>
<RadioGroup
android:id "@+id/orientation"
android:layout_below "@id/button"
android:layout_width "match_parent"
android:layout_height "wrap_content"
android:layout_marginTop "16dp">
<RadioButton
android:id "@+id/horizontal"
android:layout_width "wrap_content"
android:layout_height "wrap_content"
android:text "Horizontal" >
</RadioButton>
<RadioButton
android:id "@+id/vertical"
android:layout_width "wrap_content"
android:layout_height "wrap_content"
android:checked "true"
android:text "Vertical" >
</RadioButton>
</RadioGroup>
</RelativeLayout>
http://www.vogella.com/tutorials/Android/article.html 4/11/2016
Android development with Android Studio - Tutorial Page 39 of 57
Search
QUICK
LINKS
http://www.vogella.com/tutorials/Android/article.html 4/11/2016
Android development with Android Studio - Tutorial Page 40 of 57
Search
QUICK
LINKS
JAVA
new
@Override
switch
case
break
case
break
9.12. Validating
JAVA
// BitmapFactory requires an instance of the Resource class
http://www.vogella.com/tutorials/Android/article.html 4/11/2016
Android development with Android Studio - Tutorial Page 41 of 57
Search
@Override
JAVA QUICK
super
LINKS
JAVA
// search in the layout of the activity
JAVA
package
import android.app.Activity
import android.view.View
UiUtils
return
return
JAVA
this
http://www.vogella.com/tutorials/Android/article.html 4/11/2016
Android development with Android Studio - Tutorial Page 42 of 57
Search
QUICK
LINKS
10.4. Using assets?
JAVA
// get the AssetManager
catch
finally
if null
try
catch
http://www.vogella.com/tutorials/Android/article.html 4/11/2016
Android development with Android Studio - Tutorial Page 43 of 57
Search
JAVA
for
QUICK
for LINKS
"@+id/myicon"
"@drawable/ic_offline"
11.4. Validating
XML
http://www.vogella.com/tutorials/Android/article.html 4/11/2016
Android development with Android Studio - Tutorial Page 44 of 57
Search
<ScrollView
xmlns:android "http://schemas.android.com/apk/res/android"
android:layout_height "match_parent"
" "
<LinearLayout
android:id "@+id/LinearLayout01"
QUICK
android:layout_width "match_parent"
android:layout_height "wrap_content"
LINKS
android:orientation "vertical" >
<TextView
android:id "@+id/TextView01"
android:layout_width "wrap_content"
android:layout_height "wrap_content"
android:paddingLeft "8dip"
android:paddingRight "8dip"
android:paddingTop "8dip"
android:text "This is a header"
android:textAppearance "?
android:attr/textAppearanceLarge" >
</TextView>
<TextView
android:id "@+id/TextView02"
android:layout_width "wrap_content"
android:layout_height "match_parent"
android:layout_weight "1.0"
android:text "@+id/TextView02" >
</TextView>
<LinearLayout
android:id "@+id/LinearLayout02"
android:layout_width "wrap_content"
android:layout_height "wrap_content" >
<Button
android:id "@+id/Button01"
android:layout_width "wrap_content"
android:layout_height "wrap_content"
android:layout_weight "1.0"
android:text "Submit" >
</Button>
<Button
android:id "@+id/Button02"
android:layout_width "wrap_content"
android:layout_height "wrap_content"
android:layout_weight "1.0"
android:text "Cancel" >
</Button>
</LinearLayout>
</LinearLayout>
</ScrollView>
JAVA
http://www.vogella.com/tutorials/Android/article.html 4/11/2016
Android development with Android Studio - Tutorial Page 45 of 57
Search
import android.app.Activity
import android.view.View
ScrollViewActivity
@Override QUICK
super
LINKS
""
for 0 500
"vogella.com "
http://www.vogella.com/tutorials/Android/article.html 4/11/2016
Android development with Android Studio - Tutorial Page 46 of 57
Search
QUICK
LINKS
13.1. Create Project
XML
http://www.vogella.com/tutorials/Android/article.html 4/11/2016
Android development with Android Studio - Tutorial Page 47 of 57
Search
<resources>
http://www.vogella.com/tutorials/Android/article.html 4/11/2016
Android development with Android Studio - Tutorial Page 48 of 57
Search
QUICK
LINKS
XML
http://www.vogella.com/tutorials/Android/article.html 4/11/2016
Android development with Android Studio - Tutorial Page 49 of 57
Search
xmlns:android "http://schemas.android.com/apk/res/android"
xmlns:tools "http://schemas.android.com/tools"
android:layout_height "match_parent"
" "
"
android:paddingLeft "@dimen/activity_horizontal_margin"
android:paddingRight "@dimen/activity_horizontal_margin"
android:paddingTop "@dimen/activity_vertical_margin"
QUICK
tools:context ".MainActivity"
android:background "@color/myColor">
LINKS
<EditText
android:layout_width "match_parent"
android:layout_height "wrap_content"
android:id "@+id/editText1" />
<RadioGroup
android:id "@+id/radioGroup1"
android:layout_width "wrap_content"
android:layout_height "wrap_content"
android:layout_alignStart "@+id/editText1"
android:layout_below "@+id/editText1">
<RadioButton
android:id "@+id/radio0"
android:layout_width "wrap_content"
android:layout_height "wrap_content"
android:checked "true"
android:text "RadioButton" />
<RadioButton
android:id "@+id/radio1"
android:layout_width "wrap_content"
android:layout_height "wrap_content"
android:text "RadioButton" />
</RadioGroup>
<Button
android:id "@+id/button1"
android:layout_width "wrap_content"
android:layout_height "wrap_content"
android:layout_alignStart "@+id/radioGroup1"
android:layout_below "@+id/radioGroup1"
android:layout_marginTop "22dp"
android:text "Button" />
</LinearLayout>
13.4. Edit view properties
http://www.vogella.com/tutorials/Android/article.html 4/11/2016
Android development with Android Studio - Tutorial Page 50 of 57
Search
QUICK
LINKS
JAVA
"@+id/inputValue"
"match_parent"
"wrap_content"
"true"
"@+id/textView"
"10"
"numberSigned|numberDecimal"
JAVA
"http://schemas.android.com/apk/res/android"
"http://schemas.android.com/tools"
"match_parent"
"match_parent"
"vertical"
"@dimen/activity_vertical_margin"
"@dimen/activity_horizontal_margin"
"@dimen/activity_horizontal_margin"
"@dimen/activity_vertical_margin"
".MainActivity"
"@color/myColor"
JAVA
http://www.vogella.com/tutorials/Android/article.html 4/11/2016
Android development with Android Studio - Tutorial Page 51 of 57
Search
"http://schemas.android.com/apk/res/android"
"http://schemas.android.com/tools"
"match_parent"
" "
"
"@dimen/activity_horizontal_margin"
"@dimen/activity_horizontal_margin"
"@dimen/activity_vertical_margin"
QUICK
".MainActivity"
"@color/myColor"
LINKS
"match_parent"
"wrap_content"
"@+id/inputValue"
"numberSigned|numberDecimal"
"@+id/radioGroup1"
"wrap_content"
"wrap_content"
"@+id/editText1"
"@+id/editText1"
"@+id/radio0"
"wrap_content"
"wrap_content"
"true"
"@string/celsius"
"@+id/radio1"
"wrap_content"
"wrap_content"
"@string/fahrenheit"
"@+id/button1"
"wrap_content"
"wrap_content"
"@+id/radioGroup1"
"@+id/radioGroup1"
"22dp"
"@string/calc"
"onClick"
JAVA
http://www.vogella.com/tutorials/Android/article.html 4/11/2016
Android development with Android Studio - Tutorial Page 52 of 57
Search
ConverterUtil
// converts to fahrenheit
QUICK
LINKS
return 9 5 32
JAVA
http://www.vogella.com/tutorials/Android/article.html 4/11/2016
Android development with Android Studio - Tutorial Page 53 of 57
Search
import android.app.Activity
import android.view.View
import android.widget.Toast
MainActivity
QUICK
LINKS
@Override
super
switch
case
if 0
this "Please enter a valid number"
return
if
false
true
else
false
true
break
http://www.vogella.com/tutorials/Android/article.html 4/11/2016
Android development with Android Studio - Tutorial Page 54 of 57
Search
QUICK
LINKS
14. Deployment
14.1. How to deploy
http://www.vogella.com/tutorials/Android/article.html 4/11/2016
Android development with Android Studio - Tutorial Page 55 of 57
Search
http://www.vogella.com/tutorials/Android/article.html 4/11/2016
Android development with Android Studio - Tutorial Page 56 of 57
Search
QUICK
LINKS
http://www.vogella.com/tutorials/Android/article.html 4/11/2016
Android development with Android Studio - Tutorial Page 57 of 57
Search
QUICK
LINKS
http://www.vogella.com/tutorials/Android/article.html 4/11/2016