Debug: BroadcastReceiver and SMS

Job ID: 32708568

Budget: $30 – $250 USD

CHALLENGE:
In attached project, TxtMsgIn() extends BroadcastReceiver. TxtMsgIn's onReceive event listener sometimes responds to incoming SMS sent by the device to its own phone number. However, onReceive never responds to incoming SMS sent by other phones.

SOLUTION REQUIREMENTS:
(1) Make onReceive respond to all incoming SMS messages.
(2) Preserve object architecture already established in project.
(3) At a minimum, solution must work on BLU B130DL device running Android 10.
(3) Explain your corrections with inline //comments.

CODE SAMPLE:

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

// STEPS TO REPRODUCE THE PROBLEM:

// STEP 1
// Set testPhoneNumber, for phone running the app.
String testPhoneNumber = "7274333519";

// STEP 2
// Run app on a physical device, rather than an emulator.

// STEP 2
// Allow SMS permissions
// TxtMsgOut.sendTxtMsgWithoutUserInteraction will send a txt message to itself,
// which should prompt the myTxtMsgIn.onReceive
// including a Toast reading "Received TxtMsg! (Example Text)"
while(!checkPermission()){
// Wait for user permissions
};
TxtMsgIn myTxtMsgIn = new TxtMsgIn();
TxtMsgOut myTxtMsgOut = new TxtMsgOut();
myTxtMsgOut.sendTxtMsgWithoutUserInteraction(
testPhoneNumber,
"(Example Text)",
this);

// STEP 3
// From a separate device, manually send a test txt to testPhoneNumber.
// This should likewise prompt the onReceive method in myTxtMsgIn and Toast.
// However, it fails to do so. Why?

}