Upload
bruno-delb
View
33
Download
2
Embed Size (px)
Citation preview
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
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.
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"))
);
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" />
Layout main.xml
<Button
android:id="@+id/btn_dial"
android:text="Dial"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</LinearLayout>
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())));
}
});
}
}
Testez sur votre mobile
Intent_Dial
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