8
Développer sur Android Android Lab Test www.AndroidLabTest.com Facebook Par Bruno Delb www.youtube.com/androidlabtest www.twitter.com/brunodelb | www.facebook.com/brunodelb | blog.brunodelb.com www.facebook.com/Androidlabtest Youtube Site officiel Leçon : Les Intents, Dial

Android Lab Test : La numérotation avec Intent (français)

Embed Size (px)

Citation preview

Page 1: Android Lab Test : La numérotation avec Intent (français)

Développer sur AndroidAndroid Lab Test

www.AndroidLabTest.com

Face

bo

ok

Par Bruno Delb

www.youtube.com/androidlabtest

www.twitter.com/brunodelb | www.facebook.com/brunodelb | blog.brunodelb.com

www.facebook.com/Androidlabtest

You

tub

e

Site

off

icie

l

Leçon : Les Intents, Dial

Page 2: Android Lab Test : La numérotation avec Intent (français)

Les Intents, Dial

• Dans cette leçon, vous allez apprendre à lancer le

composeur de numéro de téléphone.

• Pour cela, vous allez utiliser les Intents.

Page 3: Android Lab Test : La numérotation avec Intent (français)

Les Intents, Dial

• La méthode startActivity lance une activité.

• L’activité en question est un Intent.

• L’Intent lancé est ACTION_DIAL, qui consiste à lancer le composeur

de numéro de téléphone.

startActivity (

new Intent (Intent.ACTION_DIAL, Uri.parse ("tel:0606060606"))

);

Page 4: Android Lab Test : La numérotation avec Intent (français)

Layout main.xml

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout

xmlns:android="http://schemas.android.com/apk/res/android"

android:orientation="vertical"

android:layout_width="fill_parent"

android:layout_height="fill_parent">

<TextView

android:text="Phone number to dial:"

android:layout_width="wrap_content"

android:layout_height="wrap_content" />

<EditText

android:id="@+id/et_number"

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:cursorVisible="true"

android:editable="true"

android:singleLine="true" />

Page 5: Android Lab Test : La numérotation avec Intent (français)

Layout main.xml

<Button

android:id="@+id/btn_dial"

android:text="Dial"

android:layout_width="fill_parent"

android:layout_height="wrap_content" />

</LinearLayout>

Page 6: Android Lab Test : La numérotation avec Intent (français)

Fichier Main.java

public class Main extends Activity {

EditText etNumber;

public void onCreate (Bundle icicle) {

super.onCreate (icicle);

setContentView (R.layout.main);

etNumber = (EditText)findViewById (R.id.et_number);

Button btnDial = (Button)findViewById (R.id.btn_dial);

btnDial.setOnClickListener (new Button.OnClickListener() {

public void onClick (View view) {

startActivity (new Intent (Intent.ACTION_DIAL, Uri.parse ("tel:" +

etNumber.getText().toString())));

}

});

}

}

Page 7: Android Lab Test : La numérotation avec Intent (français)

Testez sur votre mobile

Intent_Dial

Page 8: Android Lab Test : La numérotation avec Intent (français)

Retrouvez-moi sur ma chaîne AndroidLabTest …

Sur ma chaîne Youtubehttps://www.youtube.com/user/mobiledevlabtest

Qui suis-je ?

Bruno Delb,

auteur du 1er livre francophone de développement d’application Java sur mobile (2002),

développeur d’applications mobiles & sociales,

parlez-moi de vos projets.

Et bien sûr sur mon site Web :http://blog.brunodelb.com