Je crée une application d'appel. J'essaie d'utiliser un numéro par défaut dans ActionView et je souhaite transmettre un numéro de mobile au bouton d'appel mobile.
c'est mon code: -
public void onClick(View arg0) {
// this is real calling number
long mobile = "tel:9999999999";
// this is default number.and show in textfield of calling.
Uri uri = Uri.parse("tel:+919910699440");
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
// here i want to pass real calling num in Button. so when i press the
//calling button . button will get mobile num but not show.
intent.setData(Uri.parse("tel:"+mobile));
startActivity(intent);
}
Merci pour votre temps.
Réponses:
1 pour la réponse № 1A l'aide du code suivant, vous pouvez appeler ACTION_CALL Intent
int Number = 0377778888;
Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse("tel:" + number));
startActivity(callIntent);
et vous devez également ajouter cette autorisation au fichier AndroidManifest
<uses-permission android:name="android.permission.CALL_PHONE" />
1 pour la réponse № 2
Vous avez deux options:
utilisation
Intent.ACTION_CALL
:Intent intent = new Intent(Intent.ACTION_CALL); intent.setData(Uri.parse("tel:" + number.trim())); startActivity(intent);
Ce sera effectivement appeler le fourni
number
numéro de téléphone. Rappelez-vous simplement que cette action nécessite laandroid.permission.CALL_PHONE
permission dans le manifeste:<uses-permission android:name="android.permission.CALL_PHONE" />
utilisation
Intent.ACTION_DIAL
:Intent intent = new Intent(Intent.ACTION_DIAL); intent.setData(Uri.parse("tel:" + number.trim())); startActivity(intent);
Ceci montre la vue du numéroteur avec le
number
déjà composé, mais permet à l’utilisateur de décider d’appeler ou non. Cela fait ne pas requièrent des autorisations supplémentaires.
1 pour la réponse № 3
Essayez ce code j'ai changé ce code:
no=txt_no.getText().toString().trim();
String URI_TEL = "tel";
Uri uri = Uri.fromParts(URI_TEL, no, null);
Intent intent = new Intent(Intent.ACTION_CALL,uri);
//intent.setData(Uri.parse(no));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);