我想在来电屏幕上添加一些附加信息。为此,在我的应用程序中,我正在检查 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>
Put android:launchMode="singleInstance"
进入你的清单活动。
说明(小)
“singleTask”和“singleInstance”模式也仅在一个方面有所不同:“singleTask”活动允许其他活动成为其任务的一部分。它始终位于其任务的根部,但其他活动(必须是“标准”和“singleTop”活动)可以启动到该任务中。另一方面,“singleInstance”活动不允许其他活动成为其任务的一部分。这是任务中唯一的活动。如果它启动另一个活动,该活动将被分配给另一个任务 - 就好像 FLAG_ACTIVITY_NEW_TASK 在意图中一样。
完整的解释可以在这里找到 http://developer.android.com/guide/topics/manifest/activity-element.html
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)