android:覆盖来电屏幕 [英] android:override incoming call screen

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

问题描述

我想在来电屏幕上添加一些附加信息.为此,在我的应用程序中,我正在检查PHONE_STATE并在RINGING时正在调用一项活动.在此活动中,我将如下设置文本视图.

I want to add some addition information to the incoming call screen. For that in my app i am checking the PHONE_STATE and on RINGING, i am calling an activity. In this activity i am setting a text view as below.

它按预期工作.文本被添加到来电屏幕 问题是:

Its working as expected. The text gets added to incoming call screen tHE iSSUE IS :

如果我在我的应用程序中,即在我的应用程序视图中,并且如果有来电,则android传入的窗口会消失.我的应用程序窗口显示在顶部,并且本应覆盖传入呼叫窗口的文本视图也可见.

If i am in my app , ie in a view of my app , and if an incoming call comes, the android incoming window comes and disappears. My app window comes to top and the text view which was supposed to override incoming call window also visible.

请解释此行为.我该如何解决?

Please explain this behavior. How can i fix this?

super.onCreate(savedInstanceState);
Log.i(TAG,"oncreate");
getWindow().addFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.incomingcallscreen);
TextView name = (TextView)findViewById(R.id.textView1);
name.setText(getIntent().getExtras().getString("NAME"));
incomingCallActivityContext = this;

布局是

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="250dip"
        android:src="@drawable/icon"
        android:text="CALLER NAME"
        android:textSize="35sp"
        android:textColor="@color/WHITE"
        android:layout_gravity="center_horizontal"
        android:windowAnimationStyle="@android:style/Animation.Translucent"
        android:windowBackground="@android:color/transparent"
        android:windowIsTranslucent="true" />

</LinearLayout>

推荐答案

android:launchMode="singleInstance"放入清单活动中.
解释(小)
"singleTask"和"singleInstance"模式也仅在一个方面彼此不同:"singleTask"活动允许其他活动成为其任务的一部分.它始终是任务的根本,但是其他活动(必要时为标准"和"singleTop"活动)也可以启动到该任务中. 另一方面,"singleInstance"活动不允许其他活动成为其任务的一部分.这是任务中唯一的活动.如果启动另一个活动,则该活动将分配给另一个任务-就像意图中的FLAG_ACTIVITY_NEW_TASK一样.

Put android:launchMode="singleInstance" into your manifest Activity.
Explaination(little)
The "singleTask" and "singleInstance" modes also differ from each other in only one respect: A "singleTask" activity allows other activities to be part of its task. It's always at the root of its task, but other activities (necessarily "standard" and "singleTop" activities) can be launched into that task. A "singleInstance" activity, on the other hand, permits no other activities to be part of its task. It's the only activity in the task. If it starts another activity, that activity is assigned to a different task — as if FLAG_ACTIVITY_NEW_TASK was in the intent.

完整说明可在此处找到

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

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