public void onCallStateChanged(int state, String incomingNumber) {
Intent testActivityIntent = new Intent(ServiceReceiver.context,
Voice_Main.class);
switch (state) {
// 전화받을때, 끊을때
case TelephonyManager.CALL_STATE_IDLE:
Log.d("test1", "통화를 끊었어요");
if(a == true){
ServiceReceiver.context.stopService(testActivityIntent);
Voice_Main.getActivity().finish();
}
break;
// 통화 연결 시작
case TelephonyManager.CALL_STATE_OFFHOOK:
Log.d("test", "통화중!!!!!!!!!");
if (a == false) {
a = true;
testActivityIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
testActivityIntent
.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
ServiceReceiver.context.startActivity(testActivityIntent);
}
break;
// 벨울림
case TelephonyManager.CALL_STATE_RINGING:
break;
// 그외
default:
break;
}
}
이렇게 코드를 작성하였고 Voice_Main 액티비티가 통화를 딱 받았을때 띄어집니다
그리곤 통화가 종료되면 자동으로 서비스가 스탑되고 액티비티를 종료하고싶은데 서비스는 종료되는거 같은데 액티비티는 정상 종료되지않고 오버플로가 납니다 아무래도 앞에 액티비티를 받아와서 종료시켜주는 부분에서 계속 get 되서 그런거 같은데 다른방법이 있는지 궁금합니다
앞에 Voic_Main 에서
public static Voice_Main getActivity() {
return getActivity();
}
이렇게 받아오기하였습니다
자세한 설명좀 부탁드려요~