在接听电话时将应用程序置于最前面 [英] to bring app to front on receive of a call

查看:70
本文介绍了在接听电话时将应用程序置于最前面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在接听电话时将我的应用程序带到电话接听屏幕的前面.接到电话后,我做了所有编码工作.但是,该应用程序并没有出现在前面.它只是打开并停留在电话应答屏幕下方.
我想将我的应用程序显示在此屏幕的前面.

我做了如下操作:

I want to bring my app to front of phone call answer screen when i receive a call. I did every coding part to happen after receiving a call. But the app is not coming to front. Its just open and stays below the phone call answer screen.
I want to bring my app to front of this screen.

I did something like below:

Intent i = new Intent(); i.setAction(Intent.ACTION_MAIN);
i.addCategory(Intent.CATEGORY_LAUNCHER);
                    i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_ACTIVITY_CLEAR_TOP|Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
ComponentName cn = new ComponentName(this, MainActivity.class);
i.setComponent(cn); 
startActivity(i);

但是没有变化.

推荐答案

向接收方添加优先级.这将有助于在Android OS本地电话之前被调用

Add the priority to the receiver..this will help to be called prior than the native incoming call by the android os

<receiver android:name="com.companyname.receivers.InComingCallReceiver" >
        <intent-filter android:priority="2147483647" >
            <action android:name="android.intent.action.PHONE_STATE" />
        </intent-filter>
 </receiver>

希望这会有所帮助

这篇关于在接听电话时将应用程序置于最前面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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