2012-08-28 56 views

回答

0

要獲得振鈴事件上:

private PhoneStateListener phoneStateListener = new PhoneStateListener() { 
                 @Override 
                 public void onCallStateChanged(int state, String incomingNumber) { 

                  switch (state) { 
                   case TelephonyManager.CALL_STATE_RINGING: 
                    break; 
                   case TelephonyManager.CALL_STATE_OFFHOOK: 
                    break; 
                   case TelephonyManager.CALL_STATE_IDLE: 
                    break; 
                  } 
                 } 
                }; 

設置觀察員:

try { 
      TelephonyManager telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); 
      telephonyManager.listen(phoneStateListener, PhoneStateListener.LISTEN_CALL_STATE); 
     } 
     catch (SecurityException e) { 
      // don't have READ_PHONE_STATE 
     } 

並隨時在屏幕上

解決方案1:

getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); 

解決方案2:

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

yourwakelock = getContext().getSystemService(Context.POWER_SERVICE).newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK, getClass().getName()); 

那就是現在