Android Receiver Sorunu
Merhaba bir tane receiver sınıfım var, telefona gelen aramaları dinlemesi ve service tarafından calınan müziği kesmesi için receiver kullandım. Arama geldiğinde müziği kesiyor, fakat sonra otomatik olarak devam ettirmiyor. Bu sorunu nasıl aşabilirim?
Receiver Sınıfım;
package com.denemeservis;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.telephony.TelephonyManager;public class Receiver extends BroadcastReceiver {
@Override
public void onReceive(final Context context, Intent intent) {Intent myIntent = new Intent(context, DinlemeServisi.class);
String state = intent.getStringExtra(TelephonyManager.EXTRA_STATE);
if (state == null)
return;
if (state.equals(TelephonyManager.EXTRA_STATE_RINGING)) {
context.stopService(myIntent);
}
if (state.equals(TelephonyManager.EXTRA_STATE_IDLE)) {context.stopService(myIntent);
}Intent myIntentRahmet = new Intent(context,
DinlemeServisiRahmetFM.class);
String stateRahmet = intent
.getStringExtra(TelephonyManager.EXTRA_STATE);
if (stateRahmet == null)
return;
if (stateRahmet.equals(TelephonyManager.EXTRA_STATE_RINGING)) {
context.stopService(myIntentRahmet);
}
if (stateRahmet.equals(TelephonyManager.EXTRA_STATE_IDLE)) {context.stopService(myIntentRahmet);
}Intent myIntentYurt = new Intent(context, DinlemeServisiYurtFM.class);
String stateYurt = intent.getStringExtra(TelephonyManager.EXTRA_STATE);
if (stateYurt == null)
return;
if (stateYurt.equals(TelephonyManager.EXTRA_STATE_RINGING)) {
context.stopService(myIntentYurt);
}
if (stateRahmet.equals(TelephonyManager.EXTRA_STATE_IDLE)) {context.stopService(myIntentYurt);
}Intent myIntentRisale = new Intent(context,
DinlemeServisiRisaleFM.class);
String stateRisale = intent
.getStringExtra(TelephonyManager.EXTRA_STATE);
if (stateRisale == null)
return;
if (stateRisale.equals(TelephonyManager.EXTRA_STATE_RINGING)) {
context.stopService(myIntentRisale);
}
if (stateRisale.equals(TelephonyManager.EXTRA_STATE_IDLE)) {context.stopService(myIntentRisale);
}Intent myIntentIrsad = new Intent(context, DinlemeServisiIrsadFM.class);
String stateIrsad = intent.getStringExtra(TelephonyManager.EXTRA_STATE);
if (stateIrsad == null)
return;
if (stateIrsad.equals(TelephonyManager.EXTRA_STATE_RINGING)) {
context.stopService(myIntentIrsad);
}
if (stateIrsad.equals(TelephonyManager.EXTRA_STATE_IDLE)) {context.stopService(myIntentIrsad);
}Intent myIntentHikmet = new Intent(context,
DinlemeServisiHikmetFM.class);
String stateHikmet = intent
.getStringExtra(TelephonyManager.EXTRA_STATE);
if (stateHikmet == null)
return;
if (stateHikmet.equals(TelephonyManager.EXTRA_STATE_RINGING)) {
context.stopService(myIntentHikmet);
}
if (stateHikmet.equals(TelephonyManager.EXTRA_STATE_IDLE)) {context.stopService(myIntentHikmet);
}}
}
Teşekkürler.