2012-01-02 36 views
0

當我打電話時,我想要從後臺服務啓動一項活動。 我可以開始,當我打電話,手機是我的頭(與接近傳感器我asume做)如何在通話中顯示活動

但是,當接近傳感器檢測到的東西,我嘗試啓動活動,該活動的onStart被調用,之後直接調用onStop。

有誰知道如何在通話過程中開始活動,接近傳感器檢測到什麼?

01-02 15:42:14.829: I/KeepAliveService(5985): show pager call from Service 
01-02 15:42:14.849: I/ActivityManager(167): Starting: Intent { flg=0x14050004 cmp=com.clb.clbmobile/.NewMessage (has extras) } from pid 5985 
01-02 15:42:14.849: W/ActivityManager(167): Trying to launch com.clb.clbmobile/.NewMessage 
01-02 15:42:14.859: D/KeyguardViewMediator(167): adjustUserActivityLocked mShowing: false mHidden: false 
01-02 15:42:14.859: D/PowerManagerService(167): enableUserActivity true 
01-02 15:42:14.859: D/StatusBarManagerService(167): manageDisableList what=0x0 pkg=android 
01-02 15:42:14.859: D/InCallScreen(242): onWindowFocusChanged(false)... 
01-02 15:42:14.859: D/InCallScreen(242): - onWindowFocusChanged: faking onDialerKeyUp()... 
01-02 15:42:14.859: D/DTMFTwelveKeyDialer(242): Notifying dtmf key up. 
01-02 15:42:14.889: I/KeepAliveService(5985): activity started 
01-02 15:42:14.939: I/ClbActivity(5985): getting shared prefs 
01-02 15:42:14.939: I/ClbActivity(5985): end shared prefs 
01-02 15:42:14.939: I/AlertDialog(5985): Starting Alert Dialog 
01-02 15:42:15.019: I/AlertDialog(5985): Done with init 
01-02 15:42:15.079: D/BatteryService(167): update start 
01-02 15:42:15.079: D/BatteryService(167): update start 
01-02 15:42:15.079: D/BatteryService(167): update start 
01-02 15:42:15.099: E/PlayerDriver(95): Creating Non-Tunnel mode playback - uncompressed MIO 
01-02 15:42:15.099: W/MediaPlayer(5985): info/warning (1, 44) 
01-02 15:42:15.109: I/AlertDialog(5985): Current volume = 15 
01-02 15:42:15.109: E/MediaPlayer(5985): prepareAsync called in state 8 
01-02 15:42:15.109: I/AlertDialog(5985): cant prepare Media Player 
01-02 15:42:15.109: V/AudioPolicyManager(95): startOutput() output 1, stream 3, session 241 
01-02 15:42:15.109: V/AudioPolicyManager(95): getDeviceForStrategy() from cache strategy 1, device 1 
01-02 15:42:15.109: V/AudioPolicyManager(95): getNewDevice() selected device 1 
01-02 15:42:15.109: V/AudioPolicyManager(95): setOutputDevice() output 1 device 1 delayMs 0 
01-02 15:42:15.109: V/AudioPolicyManager(95): setOutputDevice() setting same device 1 or null device for output 1 
01-02 15:42:15.109: V/AudioHardwareMSM72XX(95): open driver 
01-02 15:42:15.109: V/AudioHardwareMSM72XX(95): get config 
01-02 15:42:15.109: V/AudioHardwareMSM72XX(95): set config 
01-02 15:42:15.109: V/AudioHardwareMSM72XX(95): buffer_size: 4800 
01-02 15:42:15.109: V/AudioHardwareMSM72XX(95): buffer_count: 2 
01-02 15:42:15.109: V/AudioHardwareMSM72XX(95): channel_count: 2 
01-02 15:42:15.109: V/AudioHardwareMSM72XX(95): sample_rate: 44100 
01-02 15:42:15.109: V/AudioHardwareMSM72XX(95): count : 4800 
01-02 15:42:15.139: I/AlertDialog(5985): start pausing 
01-02 15:42:15.149: I/MediaPlayer(5985): Info (1,44) 
01-02 15:42:15.369: I/ActivityManager(167): Displayed com.clb.clbmobile/.NewMessage: +517ms 
01-02 15:42:15.489: W/IInputConnectionWrapper(5985): showStatusIcon on inactive InputConnection 
01-02 15:42:15.489: W/IInputConnectionWrapper(5985): getExtractedText on inactive InputConnection 
01-02 15:42:15.499: D/InCallScreen(242): onStop()... 
01-02 15:42:15.499: D/InCallScreen(242): onStop: state = OFFHOOK 
01-02 15:42:15.509: D/InCallScreen(242): onResume()... 
01-02 15:42:15.519: D/PhoneApp(242): setIgnoreTouchUserActivity(true)... 
01-02 15:42:15.519: D/DTMFTwelveKeyDialer(242): startDialerSession()... this = [email protected] 
01-02 15:42:15.519: D/DTMFTwelveKeyDialer(242): - startDialerSession: mDTMFToneEnabled = true 
01-02 15:42:15.519: D/InCallScreen(242): - onResume: initial status = SUCCESS 
01-02 15:42:15.519: D/InCallScreen(242): isBluetoothAudioConnected: ==> isAudioOn = false 
01-02 15:42:15.519: D/InCallScreen(242): setInCallScreenMode: NORMAL 
01-02 15:42:15.519: D/InCallScreen(242): [okToDialDTMFTones] foreground state: ACTIVE, ringing state: false, call screen mode: NORMAL, result: true 
01-02 15:42:15.519: D/InCallScreen(242): isBluetoothAudioConnected: ==> isAudioOn = false 
01-02 15:42:15.519: D/StatusBarManagerService(167): manageDisableList what=0x1 pkg=com.android.phone 
01-02 15:42:15.519: D/PowerManagerService(167): setPokeLock pokey=16 tag=PhoneApp 
01-02 15:42:15.519: D/PowerManagerService(167): setScreenOffTimeouts mKeylightDelay=3000 mDimDelay=7000 mScreenOffDelay=20000 mDimScreen=true 
01-02 15:42:15.519: D/StatusBarManagerService(167): manageDisableList what=0x1 pkg=com.android.phone 
01-02 15:42:15.519: I/CallOnGoingView(229): onDetachedFromWindow 
01-02 15:42:15.669: D/InCallScreen(242): Handler: handling message { what=101 when=-48ms [email protected] } while not in foreground 
01-02 15:42:15.669: D/InCallScreen(242): onPhoneStateChanged()... 
01-02 15:42:15.669: D/PhoneApp(242): updateWakeState: callscreen false, dialer false, speaker false, state OFFHOOK... 
01-02 15:42:15.669: D/PhoneApp(242): setScreenTimeout(DEFAULT)... 
01-02 15:42:15.669: D/PhoneApp(242): requestWakeState(SLEEP)... 
01-02 15:42:15.669: D/InCallScreen(242): onPhoneStateChanged: Activity not in foreground! Bailing out... 
01-02 15:42:15.669: I/StatusBarManagerService(167): UPDATE-null , 0x7f020143 
01-02 15:42:15.669: I/StatusBarService(229): REMOVE:MiniCon-1 
01-02 15:42:15.689: I/AlertDialog(5985): start stopping 
01-02 15:42:15.699: I/StatusBarService(229): ADD:MiniCon-1 

回答

0

我以不同的方式解決了這個問題。

- First I check if the person is in a call 
- Then I check if the proximity sensor is activated 

如果這兩種情況,那麼聲音是從服務播放。

然後我繼續檢查接近傳感器是否已停用(例如,電話是頭部)。如果是這樣,我的靈活性就會顯示出來。

相關問題