Abhinay Sharma
Abhinay Sharma

Reputation: 178

BroadcastReceiver is not working after swiping app from recents list

I am working on internet calling app. In my app I am using to BroadcastReceiver to invoke call screen when app receives FCM data message with some specific keys. Normally is working fine, but if I swipe out my app from recent apps list it is not working. It seems like my BroadcastReceiver stops working after swiping app because all the FCM services are still and it receives FCM messages too and showing in logcat too.

I am registering my broadcast receiver in java code (not in manifest).

I used a service class to register broadcast receiver and also overrided onTaskRemoved() and used AlarmManager to keep service running but its not working too.

Why the BroadcastReceiver won't be fired and how to solve the problem?

Upvotes: 3

Views: 401

Answers (1)

azizbekian
azizbekian

Reputation: 62189

I am registering my broadcast receiver in java code (not in manifest).

That's the cause of your problem. When user swipes away your app from recents list, the process of your app is being destroyed. Thus, your BroadcastReceiver is being destroyed too.

Register your BroadcastReceiver in AndroidManifest, then onReceive() will be called regardless your app has a running process or no.

Upvotes: 1

Related Questions