Check for dialogs open


Last Updated:

  1. miXer

    miXer Well-Known Member This Topic's Starter

    Joined:
    Aug 12, 2010
    Messages:
    313
    Likes Received:
    51
    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?
     

    Advertisement
  2. miXer

    miXer Well-Known Member This Topic's Starter

    Joined:
    Aug 12, 2010
    Messages:
    313
    Likes Received:
    51
    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 (Text):
    1. 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?
     
  3. miXer

    miXer Well-Known Member This Topic's Starter

    Joined:
    Aug 12, 2010
    Messages:
    313
    Likes Received:
    51
    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.
     
  4. id0001

    id0001 Well-Known Member

    Joined:
    Apr 20, 2010
    Messages:
    142
    Likes Received:
    23
    see, it isn't that hard :)
     
    blundell likes this.

Share This Page

Loading...