I am using Intent intent = new Intent(Intent.ACTION_CALL);
to make a call from my application.
is there any way to terminate the call after a period of time? Or set a timer for ACTION_CALL before it starts?
I am using the below code from Prasanta's Blog, but for some reason context
is getting the error below. Any suggestions?
cannot be resolved
import java.lang.reflect.Method;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.os.RemoteException;
import android.telephony.PhoneStateListener;
import android.telephony.TelephonyManager;
import android.util.Log;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.TextView;
import android.widget.Toast;
import com.android.internal.telephony.ITelephony;
public class AnswerActivity extends Activity {
private static final String TAG = null;
/** Called when the activity is first created. */
private ITelephony telephonyService;
TelephonyManager telephonyManager;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TelephonyManager tm = (TelephonyManager) context
.getSystemService(Context.TELEPHONY_SERVICE);{
try {
// Java reflection to gain access to TelephonyManager's
// ITelephony getter
Log.v(TAG, "Get getTeleService...");
Class c = Class.forName(tm.getClass().getName());
Method m = c.getDeclaredMethod("getITelephony");
m.setAccessible(true);
com.android.internal.telephony.ITelephony telephonyService =
(ITelephony) m.invoke(tm);
} catch (Exception e) {
e.printStackTrace();
Log.e(TAG,
"FATAL ERROR: could not connect to telephony subsystem");
Log.e(TAG, "Exception object: " + e);
}
}
}
}
Your question has been asked a number of times. The short answer is that there is no official way to do that.
The long answers:
Read them carefully. Look for the cases where someone says "used to work...".
In one of the questions someone proposed to turn on airplane mode (the app need permissions to do that, of course). It's crude, but it works. As a user, I would have some reservations about an app doing that, though.