Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8359439
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T11:08:41+00:00 2026-06-09T11:08:41+00:00

I am working on a chat application where pictures are discussed. When I receive

  • 0

I am working on a chat application where pictures are discussed.
When I receive a c2dm message, the payload contains the message and an md5 which identifies the picture this message is about. When a ChatActivity with a matching md5 is in foreground I want to only play a sound. When it is not, I want to add a notification to the notification bar.

This is the same behaviour as with whatsapp. How to implement this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T11:08:42+00:00Added an answer on June 9, 2026 at 11:08 am

    Have the ChatActivity register a BroadcastReceiver to receive the C2DM message, in addition to having your existing manifest-registerd BroadcastReceiver for the C2DM message. Have the IntentFilter used by the ChatActivity in registerReceiver() use a positive value for setPriority(), as the default is 0. Use registerReceiver() in onResume() or onStart(), and use unregisterReceiver() in onPause() or onStop().

    The result is that when the C2DM message arrives, if your ChatActivity is in the foreground, it will get the message first, due to the higher priority. It can do the check to see if the message is about its image. If it is, ChatActivity‘s BroadcastReceiver can call abortBroadcast(), to prevent your standard-priority manifest-registered receiver from getting the broadcast. Hence, if your manifest-registered receiver does get the broadcast, you know there was no relevant ChatActivity in the foreground, and it can raise the Notification.

    Here is a sample app that demonstrates most of this. The broadcast is coming from the app itself, rather than C2DM, but the rest of the structure is pretty much the same.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am working on a chat application. I am able to send and receive
I'm working on a chat application which I would love to use a SQL
I have written a chat application which is working as desired apart from 1
I am working on a mini-project which consists of doing a client-server chat application.
Hi everyone I am working on an Ajax web chat and this application is
Im working on a Client/server chat application which allows user to send files (images
I am working on android chat application. I am facing a problem in send
I'm working on a chat application with Node.js and Socket.io, and on disconnect, the
I am working in android chat application. I used SmartFox server. I am using
I have been working on on an AJAX chat application using php, mysql. It's

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.