2012-05-23 110 views
2

我正在寫一個基於sip的呼叫應用程序。當有來電時,相應的活動會被觸發並顯示在鎖定屏幕下方。但用戶不知道有關通話...鎖定屏幕出現一段時間,屏幕關閉。即使通話仍在振鈴......鈴聲在整個持續時間內都處於活動狀態,但屏幕不顯示不顯示來電用戶界面。我需要找到一種方法來顯示適當的用戶界面,並在整個來電期間保持屏幕...[android] [lock_screen]在來電SIP呼叫期間解鎖待機屏幕

對於保持整個來電期間的屏幕上的部分我使用wakelocks .. 。但我無法擺脫鎖屏...

我研究後發現,可以使用KeygaurdManagerWindowManager.LayoutParams與像FLAG_KEEP_SCREEN_ONFLAG_DISMISS_KEYGAURDFLAG_SHOW_WHEN_LOCKEDFLAG_TURN_SCREEN_ON適當的標誌來解鎖手機......然而,這些不要在我的情況下工作...我讀了以下鏈接之一,當電話被密碼/模式鎖定時,無法解鎖手機...這是爲什麼我無法顯示我想要的用戶界面的問題?來電時如何工作?請建議我一些解決方案

我提及的是

How can I unlock the screen programmatically in Android?

Unlock the Android Lockscreen

How do I prevent an Android device from going to sleep programmatically?

https://stackoverflow.com/questions/7006894/how-to-unlack-the-screen-and-power-on-when-my-application-is-in-background-when

Force Screen On

的聯繫0

unlock screen while in call android

Android: Turn screen ON and notify user

How to launch an activity when lock screen is enabled?

Android activity over default lock screen

Android Create An Activity That Float Over Lockscreen

Unlock Android phone programmatically?

How to display Activity when the screen is locked?

How to unlock the device when my activity will be launched programmatically?

Android: How to turn screen on and off programmatically?

https://stackoverflow.com/questions/10590918/how-to-display-dialog-when-user-get-incoming-call-on-default-call-screen-in-andr

How to show incoming call notification in android application

How to display Activity when the screen is locked?

How to dismiss lock screen?

problem with KeyGuardManager

How unlock and lock screen programatically in android

How to unlock the device when my activity will be launched programmatically?

Get the Sip Incoming call id

How to notify SIP client when there is an incoming call on another phone

Can an activity receive an unordered broadcast(incoming call) intent before system's default receiver?

在此先感謝。

+0

您是否得到了解決方案?如果您的問題得到解決,請告訴我該怎麼做對我非常有幫助。 – sri

+0

你找到了解決方案嗎? – Vinay

回答

1

對於我以下的代碼效果很好。

@Override 
protected void onCreate() { 
    KeyguardManager km = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE); 
    keyguard = km.newKeyguardLock("MyApp"); 
} 
//when we need to unlock screen 
@Override 
protected void onResume() { 
    keyguard.disableKeyguard(); 
} 
@Override 
protected void onPause() { 
    keyguard.enableKeyguard(); 
} 

記住添加權限以及

<uses-permission android:name="android.permission.DISABLE_KEYGUARD" />

+0

嗨,keygaurd幫助處理鍵...我想處理解鎖屏幕。請爲處理待機屏幕提供一些答案 – user1412027

0

FLAG_SHOW_WHEN_LOCKED對我的作品在大多數手機上。該活動必須是不透明的(不是對話框)。您可能還需要FLAG_TURN_SCREEN_ON和FLAG_KEEP_SCREEN_ON

但是,它目前不適用於運行4.0.3的Galaxy Note。不知道爲什麼...