android:override incoming call screen

蓝咒 提交于 2019-12-06 09:55:06

问题


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 :

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;

and the layout is

<?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>

回答1:


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.

Full Explaination can be found here



来源:https://stackoverflow.com/questions/10913789/androidoverride-incoming-call-screen

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!