0

I am writing an android app that will send an SMS to a GSM module which will do something (what exactly is irrelevant).

This app will do stuff like choose whether some devices are going to be on or off.

The problem is that I want to make a button which will send an SMS with a question to a particular device. Then I want a notification to pop up ("Waiting for the device response").

I want to keep this notification on the screen until I get an SMS reply.

How do I make the toast linger until the reply comes?

1
  • One way to solve your problem is to create a custom toast use Dialog. Let me know if you want code example.
    – Wenhui
    Oct 7, 2012 at 21:10

1 Answer 1

2

How do I make the toast linger until the reply comes?

You don't. Since the user cannot get rid of a Toast, they have a limited lifetime, so the user will not get irritated with people cluttering up the screen for an indefinite period of time.

Since you apparently have an activity ("I want to make a button"), you can display your message in your activity's UI, or pop up a dialog.

4
  • I already have all menu, buttons and it's sending an sms. I used toast because it's easy to use. If dialog will be better I will try it. So how can I terminate dialog? I'm thinking about using threads. I will run sendSMS function in one of them and when response come I will just terminate dialog.
    – goral
    Oct 7, 2012 at 21:08
  • @user1727286: "So how can I terminate dialog?" -- call dismiss() on the Dialog. Oct 7, 2012 at 21:09
  • But can I terminate it from the outside? Since it will be running in different thread
    – goral
    Oct 7, 2012 at 21:11
  • @user1727286: AFAIK, yes. If you run into problems with that, use runOnUiThread() in your activity to call dismiss() on the main application thread. Oct 7, 2012 at 21:14

Not the answer you're looking for? Browse other questions tagged or ask your own question.