android intent.action_call,java-启动后如何停止intent.ACTION_CALL?
发布日期:2021-06-24 11:27:38 浏览次数:2 分类:技术文章

本文共 1611 字,大约阅读时间需要 5 分钟。

我正在使用Intent intent = new Intent(Intent.ACTION_CALL);从我的应用程序拨打电话.

一段时间后有什么办法可以终止通话?还是在ACTION_CALL开始之前设置一个计时器?

我正在使用Prasanta博客中的以下代码,但是由于某种原因,上下文在下面出现了错误.有什么建议么?

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);

}

}

}

}

转载地址:https://blog.csdn.net/weixin_32497403/article/details/117592634 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:linux sed 正则转义,转义字符Escape character在正则中的用法
下一篇:android2.1操作系统,电脑安卓操作系统

发表评论

最新留言

逛到本站,mark一下
[***.202.152.39]2024年03月30日 22时07分15秒