spot7.org logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories

Notification like Toast but with longer duration


From a quick search in SO, you can find the Toast durations:

private static final int LONG_DELAY =
3500; // 3.5 seconds
private static final int SHORT_DELAY = 2000; // 2
seconds

Now you can display multiple Toasts one after the other to look like it has a longer duration:

final String msg = "Some text";
Runnable delayedToast = new Runnable() {
    @Override
    public void run() {
        Toast.makeText(ctx, msg,
Toast.LENGTH_LONG).show();
    }
};

Toast.makeText(ctx, msg,
Toast.LENGTH_LONG).show(); 
mHandler.postDelayed(delayedToast, 3000);
mHandler.postDelayed(delayedToast, 6000);

Where ctx is your activity/application context and mHandler is a handler on the UI Thread. The duration should be around 3000+3000+3500.


Categories : Java

Related to : Notification like Toast but with longer duration
Toast Notification From Background Task
Maybe you must use something like that ToastTemplateType toastTemplate = ToastTemplateType.ToastText02; XmlDocument toastXml = ToastNotificationManager.GetTemplateContent(toastTemplate); XmlNodeList toastTextElements = toastXml.GetElementsByTagName("text"); toastTextElements[0].AppendChild(toastXml.CreateTextNode("Hello from the background task. ")); ToastNotification toast = new ToastNotificat

Categories : Windows
How to change text in a Toast Notification dynamically while it's being displayed?
You can save your instance of Toast which you get from makeText and update it with setText. UPDATED Code: public class MainActivity extends ActionBarActivity { private Toast mToast; private int count = 0; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); findViewB

Categories : Android
CSS3 Animation Delay longer than Duration breaks animation
This boils down to a timing issue. Initially the p has display:none; and opacity:0;. On hover the p has display:block; and opacity:1;, and then, after the delay, this is reset to display:none; and opacity:0; when the animation starts. By setting the hover p to have display:block; and animating only the opacity, then I almost get the desired result. To stop the animation from completing and setti

Categories : CSS
How to suppress notification on lock screen in Android 5 (Lollipop) but let it in notification area?
You could set the notification's priority to PRIORITY_MIN. This should hide the notification on the lock screen. It also hides the icon from the statusbar (not sure if you want that), but the notification itself is still visible in the notification area.

Categories : Android
Apple Push Notification : Can we remove some text from notification message before it has to be displayed to user on iphone
The payload data which we send to APNS server is going to display on device. If you have to remove some text then it must have to remove before sending to APNS server. You can not manage notification text message.

Categories : Iphone
Recently Add
How to convert this for loop into an enhanced loop
Do-while, try-catch loop error
JavaFx use String with Double on table column
Equal Spacing In print statements
Android Poor Image Quality When Saving Image From takePicture callback
Why ConcurrentHashMap put() return null but the item is put successfully?
Executing the java program from command prompt
Query multiple Entity attributes with List of values
Android Collections.sort - doesn't work properly
Gdx.files.internal(...) wrapper not working correctly
How to do character math?
Android - How to stack the views added dynamically?
Java: implement a loop with duplicate values in Array
Graphics paint component and loop trouble
Java: Transfer a file from server to client and from client to server
Problems with struts2 interceptor
Beginners Java Blue J returning a String in a method
How to pass Array of complex objects as a IN parameter in a stored procedure using JPA 2
Android: Finding fundamental frequency of audio input
Generic Java Logger output null.null for class and member name
How to use semaphores correctly
Hystrix: HystrixBadRequestException for failed validations
Sending a file over java socket
How can I make a variable work in more that one class? (Java)
Java - What are the layout managers available in awt.* and swing.* packages?
Reading ints from file and storing value to an array
random integers between 2 values
Maven -- is there a command to download the parent poms of all dependency jars?
Null Pointer Exception in Array when adding ActionListener
Hystrix Request Caching by Example
© Copyright 2017 spot7.org Publishing Limited. All rights reserved.