• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Check for dialogs open

miXer

Android Enthusiast
Hey. I'm writing an app that receives incoming sms.
I have tried two different approaches.

1. One app that receives and displays the message in a custom dialog. The problem here is that my app holds the broadcast receiver so the builtin sms application doesn't get the sms until i close my dialog, and i can't get the message_id until the builtin sms application receives it. If i receive another sms before the previous sms dialog is closed, then the new sms is not showed because there is already one showing.

2. Two separate apps. One that receives the sms and then starts my sms dialog which is another app. This way my dialog and the builtin sms application receives the sms in about the same time. Here is the same problem. If i receive another sms before the previous sms dialog is closed, then the new sms is not showed because there is already one showing.

I would really like to use approach number 1. That is the best way.
But can i get information about open dialogs from the same app?
Can i send a request to the opened dialog from the new one trying to open, requesting for dialog re-layout to let the user know there has been received more messages?
 
I have found some solutions to approach number 1.
I found out that if i used Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_ACTIVITY_SINGLE_TOP
then it would not try to open a new task if there were already one running. Instead the sms dialog would receive a new intent in method:
Code:
protected void onNewIntent(Intent intent)

This way when a new sms is received while another sms is beeing shown, i can re-layout the sms dialog and show a counter(1/2).

But i still have one problem though.
The app still holds on all sms broadcast receivers until the app is finished. So i can't get the message_id and can't show the message to the user via the builtin sms application.

Any suggestions?
 
Once again i have found the solution for my self! :)
I found that an broadcast receiver intent filter can have a priority. And when i gave it priority -10, then the builtin sms applicaton receives the sms first, then my application gets it. This way i can get the message_id and thread_id.
 
Back
Top Bottom