Unable to send values from Local BroadcastManager to activity
<p>Here i'm calling USSD code and then i'm trying to read that corresponding response by extending AccessibilityService. This process is working fine.
But my problem is when i'm trying to transfer that corresponding data (or value) using LocalBroadCast Manager to activity <strong>say(MainActivity.java)</strong> BroadcastReceiver not even being called.</p>

<p>Can anyone help me to transfer data using LocalBroadcastManager to activity ?</p>

<p>Please find my java classes below.</p>

<p><strong>MainActivity.java</strong></p>

<pre><code>public class MainActivity extends AppCompatActivity {

EditText edt_ussd;
String callstring = "";
Button btn_call;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    edt_ussd = (EditText) findViewById(R.id.editText);
    btn_call = (Button) findViewById(R.id.btn_call);
    btn_call.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            startService(new Intent(MainActivity.this, UssdDemo.class));
            call_Ussd(edt_ussd.getText().toString().trim());
        }
    });

    LocalBroadcastManager.getInstance(MainActivity.this).registerReceiver(mMsgReceiver,
            new IntentFilter("test_ussd.twinkletech.org.ussd_test.LBroadCst"));

}


public void call_Ussd(String ussd) {

    String s = edt_ussd.getText().toString();//calledittext is editText on the
    //screen   from  which  can get the number
    if ((s.startsWith("*")) &amp;&amp; (s.endsWith("#"))) {
        //if true then it is a USSD call----
        callstring = s.substring(0, s.length() - 1);
        callstring = callstring + Uri.encode("#");

        Log.d("CALL TYPE----------&gt;", "USSD CALL");
        System.out.println("==== output  :  " + callstring);

    } else {
        callstring = s;
        Log.d("CALL TYPE----------&gt;", "Not a USSD CALL");
    }

    System.out.println("==== callstring  :  " + callstring);
    Intent i = new Intent(android.content.Intent.ACTION_CALL, Uri.parse("tel:" + callstring));
    startActivity(i);
}




@Override
protected void onResume() {
    super.onResume();

    System.out.println("--Coming inside onResume--");
    LocalBroadcastManager.getInstance(MainActivity.this).registerReceiver(mMsgReceiver, new IntentFilter("test_ussd.twinkletech.org.ussd_test.LBroadCst"));
}

@Override
protected void onPause() {
    super.onPause();
    System.out.println("--Coming inside onPause--");
    LocalBroadcastManager.getInstance(MainActivity.this).unregisterReceiver(mMsgReceiver);

}

private BroadcastReceiver mMsgReceiver = new BroadcastReceiver() {
    @Override
    public void onReceive(Context context, Intent intent) {

        System.out.println("--&gt;&gt; Msg  received  from LOCAL broadcast receiver MainActivity  &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;");

        System.out.println("--&gt;&gt; Get actiion : "+intent.getAction());

        System.out.println("--&gt;&gt; Intent value : "+intent.getStringExtra("response_msg"));

    }
} ;

@Override
protected void onDestroy() {
    super.onDestroy();
    // Unregister since the activity is about to be closed
    LocalBroadcastManager.getInstance(MainActivity.this).unregisterReceiver(mMsgReceiver);

}
}
</code></pre>

<p><strong>UssdDemo.java</strong></p>

<pre><code>public class UssdDemo extends AccessibilityService {

public static String TAG = "UssdDemo";

@Override
public void onAccessibilityEvent(AccessibilityEvent event) {

    System.out.println("&lt;&lt;&lt; onAccessbltyEvent");
    String text = event.getText().toString();
    System.out.println("&lt;&lt;&lt; --- :  " + text);

    if (event.getClassName().equals("android.app.AlertDialog")) {
        performGlobalAction(GLOBAL_ACTION_BACK);
        System.out.println("&lt;&lt;&lt; Return value : " + text);
        Intent intent = new Intent();
        intent.setAction("test_ussd.twinkletech.org.ussd_test.LBroadCst");
        intent.putExtra("response_msg", text);

        // write a broad cast receiver and call sendbroadcast() from here, if you want to parse the message for balance, date
            LocalBroadcastManager.getInstance(UssdDemo.this).sendBroadcast(intent);
    }
}

@Override
public void onInterrupt() {
}

@Override
protected void onServiceConnected() {
    super.onServiceConnected();
    Log.d(TAG, "onServiceConnected");
    AccessibilityServiceInfo info = new AccessibilityServiceInfo();
    info.flags = AccessibilityServiceInfo.DEFAULT;
    info.packageNames = new String[]{"com.android.phone"};
    info.eventTypes = AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED;
    info.feedbackType = AccessibilityServiceInfo.FEEDBACK_GENERIC;
    setServiceInfo(info);
}}
</code></pre>

<p><strong>activity_main.xml</strong></p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="test_ussd.twinkletech.org.ussd_test.MainActivity"
tools:showIn="@layout/activity_main"&gt;

&lt;ScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center|top"&gt;



&lt;LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
android:orientation="vertical"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
    &gt;

    &lt;TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:paddingLeft="5dp"
        android:text="Enter USSD code"
        android:textSize="30sp"
        android:layout_marginTop="10dp"
        android:gravity="center"
        android:textStyle="bold"
        android:textColor="@color/colorPrimary"
        android:shadowColor="#806A6A"
        android:shadowDx="7"
        android:shadowDy="7"
        android:shadowRadius="10"
        android:layout_marginBottom="20dp"
        /&gt;

    &lt;EditText
        android:id="@+id/editText"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:paddingTop="10dp"
        android:paddingLeft="5dp"
        android:paddingBottom="10dp"
        android:layout_marginTop="30dp"
        android:hint="ussd code"
        android:inputType="phone" /&gt;

    &lt;Button
        android:id="@+id/btn_call"
        android:layout_width="match_parent"
        android:layout_height="40dp"
        android:background="@color/colorPrimary"
        android:text="CALL"
        android:layout_marginTop="10dp"
        android:textColor="@android:color/white"
        /&gt;



    &lt;LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:gravity="center|left"
        android:layout_marginTop="20dp"&gt;
    &lt;TextView

        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="RESPONSE : "
        android:textSize="16dp"
        android:textColor="@color/colorPrimaryDark"
        android:textStyle="bold"

        /&gt;

        &lt;TextView
            android:id="@+id/txt_talkBal"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dp"
            android:textColor="@android:color/black"
            android:text=""
            /&gt;

    &lt;/LinearLayout&gt;

&lt;/LinearLayout&gt;

&lt;/ScrollView&gt;&lt;/LinearLayout&gt;
</code></pre>

<p><strong>Manifest.xml</strong></p>

<pre><code>&lt;service android:name=".UssdDemo"
        android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE"&gt;
        &lt;intent-filter&gt;
            &lt;action android:name="android.accessibilityservice.AccessibilityService" /&gt;
        &lt;/intent-filter&gt;
        &lt;meta-data android:name="android.accessibilityservice"
            android:resource="@xml/config_service" /&gt;


    &lt;/service&gt;
</code></pre>