Android Studio - Phone Calls

  • Antworten:1
  • OffenNicht stickyNicht beantwortet
  • Forum-Beiträge: 1

07.04.2016, 10:07:53 via Website

I want to make one phone call after the other by pushing a Button. The telephone numbers are fixed in an Array.
I call the first number. If the phonecall is over (Hang up), it automatically calls the next number

Thats my current Code:

public class MainActivity extends Activity {

String[]numbers={
"number1",
"number2",
"number3"};

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
findViewById(R.id.button).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
for (int i = 0; i < numbers.length;i++) {
dialContactPhone(numbers[i]);
}
}
});
}

private void dialContactPhone(final String phoneNumber) {
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED) {

    return;
}
startActivity(new Intent(Intent.ACTION_CALL, Uri.fromParts("tel", phoneNumber, null)));

}

Antworten
Pascal P.
  • Mod
  • Blogger
  • Forum-Beiträge: 10.165

07.04.2016, 10:32:17 via App

Hello Tobias!
Since this is a german forum we appreciate to speak german.
If you cant german i would refer to our english forum at androidpit.com

— geändert am 07.04.2016, 10:32:30

LG Pascal //It's not a bug, it's a feature. :) ;)

Antworten

Empfohlene Artikel