我在用Intent intent = new Intent(Intent.ACTION_CALL);
从我的应用程序拨打电话。
有什么办法可以在一段时间后终止通话吗?或者在ACTION_CALL开始之前设置一个计时器?
我正在使用 Prasanta 博客中的以下代码,但出于某种原因context
出现以下错误。有什么建议么?
无法解决
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);
}
}
}
}
你的问题已经被问过很多次了。简而言之,没有官方的方法可以做到这一点。
长答案:
- 在 Android 中结束通话
- android 2.2.6 版本无法结束通话
- 结束去电
仔细阅读它们。寻找有人说“曾经工作过……”的案例。
在其中一个问题中,有人建议打开飞行模式(当然,应用程序需要权限才能执行此操作)。这很粗糙,但很有效。不过,作为用户,我对这样做的应用程序持保留态度。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)