2012-06-06 131 views
2

我想添加一些附加信息到來電屏幕。對於我的應用程序,我正在檢查PHONE_STATE和RINGING,我打電話給一個活動。在這個活動中,我正在設置一個文本視圖如下。android:覆蓋來電屏幕

其按預期工作。文本被添加到來電屏幕 我的作品是:

如果我在我的應用程序,即在我的應用程序的視圖中,並且如果傳入呼叫來,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> 
+0

,我相信我有過這個問題。這可能是兩件事之一。 首先,在顯示覆蓋層之前,嘗試添加1000毫秒的延遲,以防輸入呼叫窗口進來 如果這樣不起作用,請在此處查看答案:http://stackoverflow.com/a/5512519/ 653362我想我升級到薑餅後最後使用了吐司法。 – Guykun

+0

嗨,謝謝你的回覆。我的問題與MODIFY_PHONE狀態無關。如果我不在我的應用程序中,我的行爲正常。如果在我的應用程序中,覆蓋屏幕正在覆蓋我自己的活動屏幕,並將撥號器推到後面。你有沒有遇到這個問題?你記得howit被修正了。我已經有時間延遲。首先我的撥號器出現了,然後當我的上面的屏幕彈出時,我的當前活動也出現了 – png

回答

0

android:launchMode="singleInstance"到您的清單活動。
解釋(小)
「singleTask」和「singleInstance」模式在一個方面也彼此不同:「singleTask」活動允許其他活動成爲其任務的一部分。它始終是其任務的根源,但其他活動(必然是「標準」活動和「單一活動」)可以啓動到該任務中。 另一方面,「singleInstance」活動不允許其他活動成爲其任務的一部分。這是該任務中唯一的活動。如果它開始另一個活動,那麼該活動被分配給一個不同的任務 - 就好像FLAG_ACTIVITY_NEW_TASK在意圖中一樣。

Full Explaination can be found here