Coming soon - Get a detailed view of why an account is flagged as spam!
view details

This post has been de-listed

It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.

0
How to handle notification actions without bringing app to the front
Post Body

Hi there.. as the title says, how can I call a method in an activity without bringing the app to the front? For example, when one gets a notification of a new mail and presses the "Delete" button inside the notification, the notification is dismissed and the mail is deleted in the background without starting the app.

The only way I found to do it is to keep a static reference to the main activity and using that reference to call a public method from a BroadcastReceiver, but that only works if the activity is alive. If I launch an intent for the activity, it's started and brought to the front.

Does anyone know how app achieve that behavior?

Author
Account Strength
90%
Account Age
8 years
Verified Email
Yes
Verified Flair
No
Total Karma
3,466
Link Karma
673
Comment Karma
2,707
Profile updated: 5 days ago
Posts updated: 3 months ago

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
4 years ago