How to block Specific outgoing calls - android

I want to block a specific phone number that is in my database
I do a comparison between the number the user dialed, and the number in memory. If they are equal, I block the call.
My code:
public void onReceive(Context context, Intent intent) {
PlaceDataSQL placeDataSQL =new PlaceDataSQL(context);
ArrayList<String> getUsersPhoneNumbers= placeDataSQL.getUsersPhoneNumbers();
//TODO
//===========
//here I need to check the number
Bundle b = intent.getExtras();
String incommingNumber = b.getString(TelephonyManager.EXTRA_INCOMING_NUMBER);
//String outGoingNumber = b.getString(TelephonyManager.);
Boolean find=false;
try {
for(int i=0;i<getUsersPhoneNumbers.size();i++)
{
if(incommingNumber.equals(getUsersPhoneNumbers.get(i)))
{
find=true;
break;
}
}
} catch (Exception e) {
incommingNumber="";
}
// ========================================
//here the problem
//=========================================
String phonenumber=b.getString(Intent.EXTRA_PHONE_NUMBER);
try {
for(int i=0;i<getUsersPhoneNumbers.size();i++)
{
if(phonenumber.equals(getUsersPhoneNumbers.get(i)))
{
find=true;
break;
}
}
if (!find)
return;
}catch (Exception e) {
phonenumber="";
}
if (!find)
return;
/* examine the state of the phone that caused this receiver to fire off */
String phone_state = intent.getStringExtra(TelephonyManager.EXTRA_STATE);
if (phone_state.equals(TelephonyManager.EXTRA_STATE_RINGING))
{
logMe("Phone Ringing: the phone is ringing, scheduling creation call answer screen activity");
Intent i = new Intent(context, CallAnswerIntentService.class);
i.putExtra("delay", 100L);
i.putExtra("number", incommingNumber);
context.startService(i);
logMe("Phone Ringing: started, time to go back to listening");
}
if (phone_state.equals(TelephonyManager.EXTRA_STATE_OFFHOOK))
{
Intent i = new Intent(context,InCallScreenGuardService.class);
i.putExtra("delay", 100L);
i.putExtra("number", phonenumber);
logMe("Phone Offhook: starting screen guard service");
context.startService(i);
}
if (phone_state.equals(TelephonyManager.EXTRA_STATE_IDLE))
{
Intent i = new Intent(context,InCallScreenGuardService.class);
logMe("Phone Idle: stopping screen guard service");
context.stopService(i);
}
return;
}
The problem:
I can get incoming numbers but I can't get outgoing numbers?

You will need a BroadcastReciever for this.
public class OutgoingCallReceiver extends BroadcastReceiver {
#Override
public void onReceive(Context context, Intent intent) {
Bundle bundle = intent.getExtras();
if(null == bundle)
return;
String phonenumber = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER);
Log.i("OutgoingCallReceiver",phonenumber);
Log.i("OutgoingCallReceiver",bundle.toString());
String info = "Detect Calls sample application\nOutgoing number: " + phonenumber;
Toast.makeText(context, info, Toast.LENGTH_LONG).show();
}
}

Related

Cannot send sms verification code using with the SMS User Consent API on android

I am trying to make a phone number verification on android studio using java. I followed the instructions from the documentation here https://developers.google.com/identity/sms-retriever/user-consent/overview but sadly it isn't sending me an SMS code, and I am not getting any error. Below is my code:
public class OTPSMSActivity extends AppCompatActivity {
private ImageView blur;
private TextView resend;
private CustomEditText editText;
private FirebaseFirestore db = FirebaseFirestore.getInstance();
private KProgressHUD loadingBar;
private static final int SMS_CONSENT_REQUEST = 2;
// Set to an unused request code
private final BroadcastReceiver smsVerificationReceiver = new BroadcastReceiver() {
#Override
public void onReceive(Context context, Intent intent) {
if (SmsRetriever.SMS_RETRIEVED_ACTION.equals(intent.getAction())) {
Bundle extras = intent.getExtras();
Status smsRetrieverStatus = (Status) extras.get(SmsRetriever.EXTRA_STATUS);
switch (smsRetrieverStatus.getStatusCode()) {
case CommonStatusCodes.SUCCESS:
// Get consent intent
Intent consentIntent = extras.getParcelable(SmsRetriever.EXTRA_CONSENT_INTENT);
try {
/*Start activity to show consent dialog to user within
*5 minutes, otherwise you'll receive another TIMEOUT intent
*/
startActivityForResult(consentIntent, SMS_CONSENT_REQUEST);
Log.d("life", "Intent to send image");
} catch (ActivityNotFoundException e) {
Log.e("life", "Exception: " + e.toString());
}
break;
case CommonStatusCodes.TIMEOUT:
Log.d("life", "Timeout!");
break;
}
} else {
Log.d("life", "SmsRetriever don't matched");
}
}
};
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_otpsms);
blur = findViewById(R.id.blur);
editText = findViewById(R.id.number);
Button verify = findViewById(R.id.verify);
TextView change = findViewById(R.id.textView42);
resend = findViewById(R.id.resend);
Paper.init(this);
getBackgroundImage();
change.setOnClickListener(view -> {
finish();
});
String phoneNumber = getIntent().getStringExtra("phone");
loadingBar = KProgressHUD.create(OTPSMSActivity.this)
.setStyle(KProgressHUD.Style.SPIN_INDETERMINATE)
.setLabel("Please wait")
.setDetailsLabel("Sending sms code to your phone number.")
.setCancellable(true)
.setAnimationSpeed(2)
.setDimAmount(0.5f)
.show();
verify.setOnClickListener(view -> {
loadingBar = KProgressHUD.create(OTPSMSActivity.this)
.setStyle(KProgressHUD.Style.SPIN_INDETERMINATE)
.setLabel("Loading")
.setDetailsLabel("Verifying code")
.setCancellable(true)
.setAnimationSpeed(2)
.setDimAmount(0.5f)
.show();
String theCode = editText.getText().toString();
if (theCode.length() != 6){
new StyleableToast
.Builder(OTPSMSActivity.this)
.text("Invalid code.")
.iconStart(R.drawable.error)
.textColor(Color.WHITE)
.backgroundColor(getResources().getColor(R.color.error))
.show();
editText.setError("Invalid phone number.");
editText.requestFocus();
loadingBar.dismiss();
return;
}
verifyCode(theCode);
});
resend.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
}
});
String phone = "+63" + phoneNumber.substring(1);
Log.d("life", phone);
Task<Void> task = SmsRetriever.getClient(this).startSmsUserConsent(phone);
task.addOnCompleteListener(listener -> {
if (listener.isSuccessful()) {
Log.d("life", "Success");
loadingBar.dismiss();
IntentFilter intentFilter = new IntentFilter(SmsRetriever.SMS_RETRIEVED_ACTION);
registerReceiver(smsVerificationReceiver, intentFilter);
} else {
Exception exception = listener.getException();
exception.printStackTrace();
}
});
}
private void verifyCode(String code) {
if (code.equals(editText.getText().toString())) {
String phoneNumber = getIntent().getStringExtra("phone");
String userID = Paper.book().read("userID");
loadingBar.setDetailsLabel("Uploading number to database");
db.collection("Buyers").document(userID)
.update("phone", "+63" + phoneNumber.substring(1))
.addOnCompleteListener(task11 -> {
if (task11.isSuccessful()){
loadingBar.dismiss();
StyleableToast.makeText(OTPSMSActivity.this, "Success! Phone number updated.", Toast.LENGTH_LONG, R.style.successtoast).show();
finish();
}
});
} else {
new StyleableToast
.Builder(OTPSMSActivity.this)
.text("Code does not matched.")
.iconStart(R.drawable.error)
.textColor(Color.WHITE)
.backgroundColor(getResources().getColor(R.color.error))
.show();
loadingBar.dismiss();
}
}
#Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == SMS_CONSENT_REQUEST) {
if (resultCode == RESULT_OK) {
// Get SMS message content
String message = data.getStringExtra(SmsRetriever.EXTRA_SMS_MESSAGE);
// Extract one-time code from the message and complete verification
String oneTimeCode = parseOneTimeCode(message);
Log.d("life", "oneTimeCode: " + oneTimeCode);
//for this demo we will display it instead
editText.setText(oneTimeCode);
} else {
Log.d("life", "Error2");
}
} else {
Log.d("life", "Error1");
}
}
private String parseOneTimeCode(String message) {
//simple number extractor
return message.replaceAll("[^0-9]", "");
}
#Override
protected void onDestroy() {
super.onDestroy();
//to prevent IntentReceiver leakage unregister
unregisterReceiver(smsVerificationReceiver);
}
I want to know what am I doing wrong here.
Calling this API won't be sending you an SMS. This API listens to the SMS that you will receive on your device, ask for your permission and then retrieve it.
You should not wait for the task to complete. It is there to listen to the SMS you receive. So the first thing that you need to correct in your onCreate function:
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_otpsms);
...
Task<Void> task = SmsRetriever.getClient(this).startSmsUserConsent(null);
IntentFilter intentFilter = new IntentFilter(SmsRetriever.SMS_RETRIEVED_ACTION);
registerReceiver(smsVerificationReceiver, intentFilter);
...
}
The phone number you are passing to SmsRetriever.getClient(this).startSmsUserConsent is the phone number of the sender. So if you know which number will send you an SMS, then pass it to this function. But if you don't know the number of the sender, keep it null.
And note that the sender phone number should not be in the phone's contacts list as mentioned in the documentation: https://developers.google.com/identity/sms-retriever/choose-an-api
So first call create this task instruction above, have it wait for your sms and then request an SMS. You could use third party platforms to send SMS messages. To test that you can send an SMS using your emulator to the emulator device.

Set Custom call activity

I would like to set my own activity infront the call screen. I have seen that there are many examples for this but with the older versions of android, while I want it to work with android 6.0 and above. This means that I have to deal with the permissions. I managed to grant the necessary permissions. After that I make a Class that inherits BroadcastReceiver so that I can detect when the phone is ringing, the only problem is that I can't send my activity infront of the call display. These are some of the classes I use:
public class PhoneStateReceiver extends BroadcastReceiver {
public void onReceive(Context context, Intent intent) {
try {
System.out.println("Receiver start");
String state = intent.getStringExtra(TelephonyManager.EXTRA_STATE);
Toast.makeText(context, " Receiver start ", Toast.LENGTH_SHORT).show();
if (state.equals(TelephonyManager.EXTRA_STATE_RINGING)) {
Toast.makeText(context, "Ringing State Number is -", Toast.LENGTH_SHORT).show();
Intent dialogIntent = new Intent(context, LockActivity.class);
dialogIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
context.startActivity(dialogIntent);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
public class LockActivity extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_lock_screen);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
+ WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD |
+WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED |
+WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
Button btnLock = (Button) findViewById(R.id.btnUnlock);
final EditText txtPass = (EditText) findViewById(R.id.txtPass);
btnLock.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
String pass = txtPass.getText().toString();
if(pass.equals("pass")||pass.equals("пасс")) {
finish();
}else{
Toast.makeText(LockActivity.this, "Wrong password!", Toast.LENGTH_SHORT).show();
}
}
});
}
}
If anything else is needed please ask!
I managed to solve it, the problem is that it takes time to start the in-built call activity, so my activity started first and the other went on top of it. Therefore I made the current thread of my activity to sleep for less than a second. The in-built activity was launched and then my activity went on top of it.
public class PhoneStateReceiver extends BroadcastReceiver {
public void onReceive(Context context, Intent intent) {
try {
System.out.println("Receiver start");
String state = intent.getStringExtra(TelephonyManager.EXTRA_STATE);
Toast.makeText(context, " Receiver start ", Toast.LENGTH_SHORT).show();
if (state.equals(TelephonyManager.EXTRA_STATE_RINGING)) {
Toast.makeText(context, "Ringing State Number is -", Toast.LENGTH_SHORT).show();
Intent dialogIntent = new Intent(context, LockActivity.class);
dialogIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
Thread.sleep(700);
context.startActivity(dialogIntent);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}

android add extra and call programmatically

I am trying to make a call through my app by putting extra data and while but I am unable to receive that data during the call can some explain where I am wrong below is my code for making call and receiving call
String uri = "tel:"+my_name;
Intent callIntent = new Intent(Intent.ACTION_CALL, Uri.parse(uri));
callIntent.putExtra("data", "mynewdata");
callIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
_context.startActivity(callIntent);
And call receiver
public class PhoneStateReceiver extends BroadcastReceiver {
#Override
public void onReceive(Context context, Intent intent) {
final Bundle bundle = intent.getExtras();
if(bundle != null) {
showToast(intent.getExtras().getString("data"));
}
if (intent.getAction().equals("android.intent.action.PHONE_STATE")) {
String state = intent.getStringExtra(TelephonyManager.EXTRA_STATE);
Log.d(TAG,"PhoneStateReceiver**Call State=" + state);
if (state.equals(TelephonyManager.EXTRA_STATE_IDLE)) {
if(recieveCall){
}
Log.d(TAG,"PhoneStateReceiver**Idle");
} else if (state.equals(TelephonyManager.EXTRA_STATE_RINGING)) {
} else if (state.equals(TelephonyManager.EXTRA_STATE_OFFHOOK)) {
}
} else if (intent.getAction().equals("android.intent.action.NEW_OUTGOING_CALL")) {
// Outgoing call
String outgoingNumber = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER);
Log.d(TAG,"PhoneStateReceiver **Outgoing call " + outgoingNumber);
setResultData(null); // Kills the outgoing call
} else {
Log.d(TAG,"PhoneStateReceiver **unexpected intent.action=" + intent.getAction());
}
}
}
I'm receiving call perfectly and even broadcast is working perfectly but I am not getting data from intent "intent.getExtras().getBoolean("data")"
Here you need to create a java file (lets name it Constants.java):
public class Constants
{
public static boolean data;
public static String str = "";
}
Now see the changes i did in the project along with the comments.
String uri = "tel:"+my_name;
Intent callIntent = new Intent(Intent.ACTION_CALL, Uri.parse(uri));
Constants.data = true; /*see change, set data in Constants.data*/
Constants.str = "some data to pass..."; /*see change*/
callIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
_context.startActivity(callIntent);
Now in broadcast receiver see the changes done...
public class PhoneStateReceiver extends BroadcastReceiver {
#Override
public void onReceive(Context context, Intent intent) {
final Bundle bundle = intent.getExtras();
if(bundle != null && Constants.data) { /*changes done, get boolean from the Constants.data*/
showToast("hi i have recieve");
showToast(Constants.str); /*changes done*/
}
if (intent.getAction().equals("android.intent.action.PHONE_STATE")) {
String state = intent.getStringExtra(TelephonyManager.EXTRA_STATE);
Log.d(TAG,"PhoneStateReceiver**Call State=" + state);
if (state.equals(TelephonyManager.EXTRA_STATE_IDLE)) {
if(recieveCall){
}
Log.d(TAG,"PhoneStateReceiver**Idle");
} else if (state.equals(TelephonyManager.EXTRA_STATE_RINGING)) {
} else if (state.equals(TelephonyManager.EXTRA_STATE_OFFHOOK)) {
}
} else if (intent.getAction().equals("android.intent.action.NEW_OUTGOING_CALL")) {
// Outgoing call
String outgoingNumber = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER);
Log.d(TAG,"PhoneStateReceiver **Outgoing call " + outgoingNumber);
setResultData(null); // Kills the outgoing call
} else {
Log.d(TAG,"PhoneStateReceiver **unexpected intent.action=" + intent.getAction());
}
}
}
Hope this solved your problem of how to pass data

i can send value from my activity to broadcastreceiver but i can't use it for long time

actually in my app i want to send a message when my phone making any phone calls...here the app installing time asking for parent number and its number sending to the broadcast receiver activity from my first activity...its received there and also toasting the value..but when i making phone call it value change to null...can anybody help me for access that value at phone calling time ..is it possible ??how..thank you my code is given below...
in my first activity sending value to broadcast receiver:
try
{
Toast.makeText(getApplicationContext(), "try", Toast.LENGTH_LONG).show();
Intent in = new Intent("my.action.string");
in.putExtra("parent", PARENT);//this string sending to broadcast receiver
sendBroadcast(in);
}
catch (Exception e)
{
// TODO: handle exception
e.printStackTrace();
}
and my broadcast receiver is:
public class myBroadcast extends BroadcastReceiver
{
String out_number;
String myparent;
#Override
public void onReceive(Context context, Intent intent)
{
// TODO Auto-generated method stub
myparent = intent.getExtras().getString("parent"); //this sting access the number first and then change to null at making phone call
final String my=myparent;
Toast.makeText(context, "broadcst"+myparent, Toast.LENGTH_LONG).show();
if (intent.getAction().equals("android.intent.action.NEW_OUTGOING_CALL"))
{
out_number=intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER);
Toast.makeText(context, "broadcst"+my+" "+out_number, Toast.LENGTH_LONG).show();
SmsManager sm=SmsManager.getDefault();
sm.sendTextMessage(myparent, "5554", "calling..to"+myparent, null, null); //5554 is my emulator number to check its in emulator
Toast.makeText(context, "send"+out_number, Toast.LENGTH_SHORT).show();
}
}
}
/*
* The Receiver is intended for the incoming calls read though the phone
* state for more details see android.content.BroadcastReceiver
*
* #author parul
*
*/
public class InComingCallReciever extends BroadcastReceiver {
public static String LOG = "InComingCall";
/*
* (The onReceive is invoked when we receive an arbitrary intent from the
* Incoming call Service)
*
* #see android.content.BroadcastReceiver#onReceive(android.content.Context,
* android.content.Intent)
*/
#Override
public void onReceive(Context context, Intent intent) {
// TODO Auto-generated method stub
Log.v(LOG, "InComingCallReciever");
Bundle bundle = intent.getExtras();
if (bundle == null) {
return;
}
String state = bundle.getString(TelephonyManager.EXTRA_STATE);
Log.v(LOG, "" + state);
if (state.equalsIgnoreCase(TelephonyManager.EXTRA_STATE_RINGING)) {
String phoneNumber = bundle
.getString(TelephonyManager.EXTRA_INCOMING_NUMBER);
Toast.makeText(context, "The Incoming Number is ..." + phoneNumber,
Toast.LENGTH_SHORT).show();
Log.v(LOG, "incomming number is ... " + phoneNumber);
} else {
Log.v(LOG, "test 2 ");
}
}
}

Android Activity does not receive messages from IntentService using BroadcastReceiver

I am trying to develop an android app to measure QoS of networks. The app sends UDP packets to a UDP server running on my system. Since this is a long running process, I have implemented the UDP connection in a class which extends IntentService.The reason behind using IntentService is that I need to pass some parameters to the Service. I have a BroadcastReceiver in my activity which listens for messages from the IntentService and prints it. My problem is that although the IntentService is running smoothly, but the activity is not receiving the messages from it. I am new to android development, so please excuse my lack of understanding and any guidance/suggestions will be deeply appreciated. I am posting some parts of my code below. The Logcat does not show any errors.
I have seen intent.setAction() method being used in some examples, but I am not very clear about how to use it in my case.
The BroadcastReceiver (defined within my Activity class)
public class UdpResponseReceiver extends BroadcastReceiver {
public static final String ACTION_RESP = "com.example.udpmessageclient.intent.action.MESSAGE_PROCESSED";
#Override
public void onReceive(Context context, Intent intent) {
System.out.println(UdpService.PARAM_OUT_MSG);
}
I have registered the receiver:
IntentFilter filter = new IntentFilter(UdpResponseReceiver.ACTION_RESP);
filter.addCategory(Intent.CATEGORY_DEFAULT);
receiver = new UdpResponseReceiver();
registerReceiver(receiver, filter);
IntentService class:
public class UdpService extends IntentService {
//..variable declarations
public UdpService() {
// TODO Auto-generated constructor stub
super("UdpService");
}
#Override
protected void onHandleIntent(Intent intent) {
// TODO Auto-generated method stub
host = intent.getStringExtra("host");
port = intent.getIntExtra("port", 4000);
pType= intent.getIntExtra("pType", 0);
delay = intent.getIntExtra("delay", 0);
msg= intent.getStringExtra("msg");
broadcastIntent = new Intent();
broadcastIntent.addCategory(Intent.CATEGORY_DEFAULT);
broadcastIntent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
try {
addr = InetAddress.getByName(host);
// addr=InetAddress.getLocalHost();
socket = new DatagramSocket();
// socket.connect(addr,port);
System.out.println("\nSocket Connected");
} catch (Exception e) {
System.out.println("\nConnection failed");
return;
}
send=true;
switch (pType) {
case 0:
while (send) {
sendPacket(msg);
}
case 1:
while (send) {
try {
Thread.currentThread().sleep(delay);
} catch (Exception e) {
}
sendPacket(msg);
}
case 2:
while (send) {
int u = want(30);
String data1 = "";
while ((u--) > 0)
data1 = data1 + msg;
sendPacket(data1);
}
case 3:
while (send) {
int u = want(30);
System.out.println(u);
String data1 = "";
while ((u--) > 0)
data1 = data1 + msg;
System.out.println("data length :" + data1.length());
try {
Thread.currentThread().sleep(delay);
} catch (Exception e) {
}
sendPacket(data1);
}
}
}
public void onDestroy(){
super.onDestroy();
send=false;
socket.close();
socket=null;
}
void sendPacket(String text) {
try {
System.out.println("\nClient:: Sending packet: " + " to " + addr
+ port);
byte[] data = text.getBytes();
spacket = new DatagramPacket(data, data.length, addr, port);
socket.send(spacket);
String resultTxt="Sent Packet at:"+DateFormat.format("MM/dd/yy h:mmaa", System.currentTimeMillis());
// this is where I am trying to send message back to the activity
broadcastIntent.putExtra(PARAM_OUT_MSG, resultTxt);
sendBroadcast(broadcastIntent);
} catch (Exception e) {
System.out.println("Error:" + e.getMessage());
e.printStackTrace();
return;
}
}
}
logcat error messages when the service is stopped:
01-14 15:53:41.446: W/System.err(1176): java.lang.NullPointerException
01-14 15:53:41.456: W/System.err(1176): at com.example.udpmessageclient.UdpService.sendPacket(UdpService.java:123)
01-14 15:53:41.466: W/System.err(1176): at com.example.udpmessageclient.UdpService.onHandleIntent(UdpService.java:74)
01-14 15:53:41.466: W/System.err(1176): at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
01-14 15:53:41.466: W/System.err(1176): at android.os.Handler.dispatchMessage(Handler.java:99)
01-14 15:53:41.466: W/System.err(1176): at android.os.Looper.loop(Looper.java:137)
01-14 15:53:41.476: W/System.err(1176): at android.os.HandlerThread.run(HandlerThread.java:60)
Change the code of UdpService as ...
broadcastIntent = new Intent(UdpResponseReceiver.ACTION_RESP); // You forgot to add your custom intent filter
broadcastIntent.addCategory(Intent.CATEGORY_DEFAULT);
//broadcastIntent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); // I don't think you really need it. So you can remove this flag.
UPDATE
public static final String ACTION_RESP = "com.example.udpmessageclient.intent.action.MESSAGE_PROCESSED";
private final BroadcastReceiver UdpResponseReceiver = new BroadcastReceiver() {
#Override
public void onReceive(Context context, Intent intent) {
//TODO handle results
}
};
And register it as
registerReceiver(UdpResponseReceiver, new IntentFilter(ACTION_RESP))

Categories

Resources