【问题标题】:android:override incoming call screenandroid:覆盖来电屏幕
【发布时间】:2014-06-09 03:49:34
【问题描述】:

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

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

如果我在我的应用程序中,即在我的应用程序的视图中,并且如果有来电,android 来电窗口就会出现并消失。我的应用程序窗口位于顶部,并且应该覆盖来电窗口的文本视图也可见。

请解释这种行为。我该如何解决这个问题?

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>

【问题讨论】:

  • 我相信我之前遇到过这个问题。这可能是两件事之一。首先,尝试在显示覆盖之前添加 1000 毫秒延迟,以防来电窗口迟到 如果这不起作用,请在此处查看答案:stackoverflow.com/a/5512519/653362 我想我最后使用了 toast 方法升级到姜饼。
  • 您好,感谢您的回复。我的问题与 MODIFY_PHONE 状态无关。如果我不在我的应用程序中,我会得到正确的行为。如果在我的应用程序中,覆盖屏幕将覆盖我自己的活动屏幕并将拨号器推到后面。你遇到过这个问题吗?你记得它是如何被修复的。我已经有时间延迟了。首先我的拨号器来了,然后当我的覆盖屏幕弹出时,我当前的活动也出现了

标签: android screen overriding phone-call


【解决方案1】:

android:launchMode="singleInstance" 放入您的清单活动中。
说明(小)
“singleTask”和“singleInstance”模式也仅在一个方面彼此不同:“singleTask”活动允许其他活动成为其任务的一部分。它始终位于其任务的根部,但其他活动(必须是“标准”和“singleTop”活动)可以启动到该任务中。 另一方面,“singleInstance”活动不允许其他活动成为其任务的一部分。它是任务中的唯一活动。如果它启动另一个活动,则该活动被分配给不同的任务——就好像 FLAG_ACTIVITY_NEW_TASK 在意图中一样。

Full Explaination can be found here

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-11-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多