0
我正在創建應用程序和我的代碼的某個部分,以便在接到來電時創建通知。問題是我無法執行通知,因爲我必須傳遞給我打電話的人數。以下幾段我的代碼。在接到來電時創建通知
我的收款人:
@Override
public void onReceive(Context context, Intent intent) {
TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
CallIntercepterListener callIntercepterListener = new CallIntercepterListener();
telephonyManager.listen(callIntercepterListener, PhoneStateListener.LISTEN_CALL_STATE);
Bundle bundle = intent.getExtras();
String phoneNumber = bundle.getString("incoming_number");
Log.d(TAG, "phoneNumber: " + phoneNumber);
}
和我的聽衆:
@Override
public void onCallStateChanged(int state, String incomingNumber) {
Log.v(TAG, "Event Call: " + incomingNumber);
switch (state) {
case TelephonyManager.CALL_STATE_RINGING:
// Create a notification with de incomingNumber
break;
}
}
謝謝!這對我幫助很大!! – rmenezes 2013-03-01 00:14:37