Cob50nm Cob50nm -3 years ago 131
Android Question

Android broadcast receiver not receiving intent

I have two apps that I made, and am trying to send an intent from one to the other but the intent is never getting to the

however this problem is only one way. the first app can send to the second but the second cannot send back info. I am using a different intent action to send from the second to the first but otherwise they are identical. Any ideas on why this might not be working? I have tried everything I can think of and read most of the posts I could find on here and to no avail.

It's not crashing or giving me any indications as to what is happening in the logcat it's just doing nothing.

send function

private void sendFinishLog(String ID, String Cond)
Log.d("me", "send finish log");
Intent logIntent = new Intent();
logIntent.putExtra("ID", ID);
logIntent.putExtra("Cond", Cond);
Log.d("me","logIntent : " + logIntent.toString() +logIntent.getExtras().toString());

receive class

public class LogReceiver extends BroadcastReceiver {

public static ArrayList<LogDataHolder> logData = new ArrayList<LogDataHolder>();
private boolean found;
static SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
private static String lasttime;
private static String now = "Boot time";
public void onReceive(Context cont, Intent logIntent)
Log.d("me","On receive");

Receiving app manifest

<!-- for receiving logs -->
android:name = "LogReceiver"
<action android:name="" />

Answer Source

something like:

public void onResume() {
    IntentFilter filter = new IntentFilter();

and for un-register:

public void onPause() {

edit: i just figured that your LogReceiver-class has no constructor neither. you will need to write one aswell:

private LogReceiver mLogReceiver = new LogReceiver() {

and after that you can use the onReceive-method like you have it already in your code.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download