Hello guys i am trying to send two variables from an android service to a broadcast receiver, and i need help here..
i am setting up two var's in the oncreate method of the service class here..
@Override
public void onCreate() {
super.onCreate();
Intent eSendIntent = new Intent(getApplicationContext(), OutgoingCallReceiver.class);
eSendIntent.putStringArrayListExtra("BlockArray", contactsListB);
eSendIntent.putExtra("BlockBool", checkB);
getApplicationContext().sendOrderedBroadcast(eSendIntent, null);//Call receiver
}
and in my receiver class...
onReceive(Context context, Intent intent){
Bundle bundle = intent.getExtras();
if(bundle == null)
return;
boolean cb = bundle.getBooleanExtra("BlockBool", true);
ArrayList<String> ab = bundle.getStringArrayListExtra("BlockArray");
//disconnecting
try{
if(cb==false){
for(int ij = 0; ij < ab.size(); ij++){
if(ab.get(ij).contains(phonenumber)){
tempBoolean = true;
//Log.e("OutgoingCallReceiver", SmsBlockerService.contactsListB.get(ij));
}
}//for loop
if(tempBoolean==true){
setResultData(null);
Toast.makeText(context, phonenumber + " is Blocked", Toast.LENGTH_SHORT).show();
}
}else{
setResultData(null);
Toast.makeText(context, "All Out-Going Calls are Blocked", Toast.LENGTH_SHORT).show();
}//end of main if
} catch(Exception e){
Toast.makeText(context, "Detect Calls sample application Failed: ", Toast.LENGTH_LONG).show();
}
}
logcat:
E/BroadcastReceiver(1459): BroadcastReceiver trying to return result during a non-ordered broadcast