How to get call state of outgoing android call
<p>I am originating a call from Android Studio. The code is as follows:
I want to get the state of the call at any point. The link: <a href="https://developer.android.com/reference/android/telecom/Call.html" rel="nofollow noreferrer">https://developer.android.com/reference/android/telecom/Call.html</a>
shows the state of the call can be obtained by using the Class call.. SO if I use Call.getState() I should be able to get the current state. But I get the compilation error:
<strong>Error:(28, 20) error: Call() is not public in Call; cannot be accessed from outside package</strong>.  There are several call states defined in the enum: Dialing, Ringing, Connected, DIsconnected, Holding, etc.
When I run the code, it does make the call as I can see the screen of emulator making the call. </p>

<p>The developer guide does not provide any examples of using these classes.
Thank you for your help.</p>

<pre><code>package com.example.ramesh.makeacall;

import android.app.Activity;
import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.net.Uri;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.telecom.Call;
import android.telephony.*;

import android.util.Log;

public class MainActivity extends AppCompatActivity {

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

    }
    private void call() {

        try {

            Intent callIntent = new Intent(Intent.ACTION_CALL);
            callIntent.setData(Uri.parse("tel:5555551212"));
            System.out.println("====before startActivity====");
            startActivity(callIntent);


        } catch (ActivityNotFoundException e) {
            Log.e("helloAndroid","Call failed",e);
        }
    }

    }
</code></pre>