0

I'm new to android development and trying to make an app with 2 buttons, one calls a specific number and the other just answers the phone when being called. Except I don't really know what to define in the ACTION_ANSWER area.. Thanks in advance!

My MainActivity.java

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;


public class MainActivity extends ActionBarActivity {

    private Button button1;
    private Button button2;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        button1 = (Button) findViewById(R.id.buttonCall);

        button1.setOnClickListener(new OnClickListener() {
            public void onClick(View arg0) {
                Intent callIntent = new Intent(Intent.ACTION_CALL);
                callIntent.setData(Uri.parse("tel:0634834906"));
                startActivity(callIntent);
            }
        });

        button2 = (Button) findViewById(R.id.buttonAnswer);
        button2.setOnClickListener(new OnClickListener() {
            public void onClick(View arg0) {
                Intent answerIntent = new Intent(Intent.ACTION_ANSWER);

            }
        });
    }
}
  • 1
    Why you want to use button 2 to answer the call because when you get called there is already android will give option to pick up call, and it will not show your app when you got call – Harsh Parikh Oct 06 '14 at 07:48
  • 1
    this might be of interest: http://stackoverflow.com/questions/15481524/how-to-programatically-answer-end-a-call-in-android-4-1 – Chris Oct 06 '14 at 07:50
  • @HarshParikh did you found the solution? – Mateen Chaudhry Sep 02 '18 at 05:23

0 Answers0