'Security Error in the App Implicit Internal Intent Vulnerability

We are receiving a security error in our app: Implicit Internal Intent: Your app contains an Implicit Internal Intent vulnerability. Our use case is : We are sending out a broadcast event with an action item and broadcasting it so that our activity can listen to this event and finish itself.

    Intent alarmKilled = new Intent("alarmKilled");
    alarmKilled.putExtra(...);
    this.sendBroadcast(alarmKilled);

The Activity has an inner class which is a Broadcast Receiver and it listens for the broadcast.

 private final BroadcastReceiver alarmKilledReceiver = new BroadcastReceiver() {
    @Override
    public void onReceive(Context context, Intent intent) {
     ...
    }

this.registerReceiver(this.alarmKilledReceiver, new IntentFilter("alarmKilledEvent"));

How can we convert this to an explicit intent? To convert it to an explicit intent, we need to pass it to a specific component, and in our case the Activity itself has the BroadcastReceiver as an inner class? If I create a separate class as a BroadcastReceiver how can I finish an activity outside the activity in the Broadcast Receiver?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source