覆盖来电屏幕? [英] Override incoming call screen?

查看:135
本文介绍了覆盖来电屏幕?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我想知道如果有一种方法可以重写来电屏幕添加更多的功能呢?如果是这样,你可以既指明了正确的方向,或提供一些样品code?

Hello I was wondering if there is a way to override the incoming call screen to add more functionality to it? If so could you either point me in the right direction or provide some sample code?

----------------------------------------------- ---编辑:--------------------------

-------------------------------------------------- --------------------------

我得到的接收器工作良好,当电话打进来,但我将如何让当前窗口覆盖呼叫屏幕?这是我得到了那么远,但我得到一个ClassCastException试图转换为活动的情况下,我想不出来访问该窗口中的任何其他方式。

I got the receiver working well when the call comes in but how would I get the current window to override the call screen? This is what I got so far... but i get a classCastException trying to cast to activity from context, I cant think of any other way to gain access to the window.

@Override
    public void onReceive(Context context, Intent intent) {
        Bundle extras = intent.getExtras();
        if (extras != null) {
            String state = extras.getString(TelephonyManager.EXTRA_STATE);
            Log.w("DEBUG", state);
            Log.w("DEBUG", "-------------------------------------------------- Broadcast Received");
            if (state.equals(TelephonyManager.EXTRA_STATE_RINGING)) {
                String phoneNumber = extras
                        .getString(TelephonyManager.EXTRA_INCOMING_NUMBER);
                Log.w("DEBUG", phoneNumber);
                Activity activity = (Activity)context.getApplicationContext();
                Window window = activity.getParent().getWindow();
                window.addContentView(window.findViewById(R.layout.textalertbuttonview),null);
                Log.w("DEBUG", "------------------------Button Added");

            }
        }
        else {
            Log.w("DEBUG", "---------------------------------------------------no Extras");
        }
    }

----------------------------------------------- ---编辑2:--------------------------

--------------------------------------------------EDIT 2: --------------------------

这似乎并没有一些研究,我其实可以添加元素的实际来电屏幕后。因此,我将不得不做出我自己的看法,并覆盖来电屏幕。但我仍然开放的想法......我看到来电再加上却找不到源头code为该项目。

It doesn't seem after some research that I can actually add elements to the actual incoming call screen. So I will have to make my own view and override the incoming call screen. But I am still open for ideas... I saw incoming call plus but can not find the source code for that project.

推荐答案

一般来说: 您可以设置一个BroadcastReceiver听PHONE_STATE:

Generally speaking: You can set a BroadcastReceiver listening to PHONE_STATE:

<receiver android:name=".CallsBroadcastReceiver" android:enabled="true">
    <intent-filter>
        <action android:name="android.intent.action.PHONE_STATE" />
    </intent-filter>
</receiver>

那么这个接收器内(检查要处理(振铃电话的状态,通话,挂断,等),你应该得到的当前窗口(这应该是呼叫屏幕)和视图添加到后它。 当然,除去视图一旦国家是不是要处理一个。

Then inside this receiver (after checking the state of the phone you want to handle (ringing, in call, hanged up, etc.) you should get the current window (which should be the call screen) and add a view to it. And of course remove the view once the state is not the one you want to handle.

很一般,但是这是这个想法。

Very general, but that's the idea.

这篇关于覆盖来电屏幕?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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