如何停止intent.ACTION_CALL一旦启动? [英] How to stop a intent.ACTION_CALL once started?

查看:117
本文介绍了如何停止intent.ACTION_CALL一旦启动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用意向意图=新的意图(Intent.ACTION_CALL); 来使从我的应用程序调用

有没有什么办法来终止一段时间后的电话吗?或者,它开始前设置ACTION_CALL定时器吗?

我使用的Prasanta的博客下面code,但由于某些原因上下文越来越下面的错误。有什么建议?

  

解决不了

 进口java.lang.reflect.Method中;
进口android.app.Activity;
进口android.content.Context;
进口android.os.Bundle;
进口android.os.RemoteException;
进口android.telephony.PhoneStateListener;
进口android.telephony.TelephonyManager;
进口android.util.Log;
进口android.widget.CheckBox;
进口android.widget.CompoundButton;
进口android.widget.CompoundButton.OnCheckedChangeListener;
进口android.widget.TextView;
进口android.widget.Toast;
进口com.android.internal.telephony.ITelephony;


公共类AnswerActivity延伸活动{
    私有静态最后字符串变量= NULL;
    / **第一次创建活动时调用。 * /
    私人ITelephony telephonyService;
    TelephonyManager telephonyManager;

    @覆盖
    公共无效的onCreate(包savedInstanceState){
        super.onCreate(savedInstanceState);
        的setContentView(R.layout.main);

    TelephonyManager TM =(TelephonyManager)上下文
            .getSystemService(Context.TELEPHONY_SERVICE); {

    尝试 {
        // Java反射来访问TelephonyManager的
        // ITelephony吸气
        Log.v(TAG,获取getTeleService ......);
        C类=的Class.forName(tm.getClass()的getName());
        方法米= c.getDeclaredMethod(getITelephony);
        m.setAccessible(真正的);
        com.android.internal.telephony.ITelephony telephonyService =
                (ITelephony)m.invoke(商标);
    }赶上(例外五){
        e.printStackTrace();
        Log.e(TAG,
                致命错误:无法连接到电话子系统);
        Log.e(TAG,异常物体+ E);
    }

}
    }
}
 

解决方案

您的问题已经被问了很多次。简短的回答是,没有正式的方式来做到这一点。

长回答:

认真阅读。寻找那里有人说,案件用来工作......。

在有人提出要打开飞行模式的问题之一(应用程序需要的权限做的当然是,)。这是粗糙,但它的工作原理。作为一个用户,我将有大约一个应用程序有所保留这样做,虽然。

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.

这篇关于如何停止intent.ACTION_CALL一旦启动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆