toast

Unexpected behaviours in toast notification from desktop app in Windows 10

懵懂的女人 提交于 2019-11-28 14:18:29
I used the toast notifications for desktop app since Windows 8.1 but with the new action center in Windows 10, I am experiencing some unexpected behaviours. When the user do nothing with the toast, it simply disappear without going to the action center ( ToastNotification.Dismissed is ToastDismissalReason.TimedOut ). I don't know if it related to the fact that I use it in a win32 app but the same toast in a Windows Universal App goes to the action center when it timed out. One thing to note is that I have not registered an AppUserModelID for my win32 app like it was needed in W8.1, it seems to

how to present a toast when a widget is clicked?

心已入冬 提交于 2019-11-28 12:49:45
I need to do a simple widget that presents a Toast when clicking on it. My problem is that I cant find how to get or create an "oncreate" action. i see the examples with the pending intent that opens the web browser. But how do i simply create this: Toast.makeText(context, "activated", Toast.LENGTH_LONG).show(); and make it happen every time a user clicks on the widget? just to be clear, I mean a widget on the launcher of the phone. not a regular "button" widget etc... public class Widget extends AppWidgetProvider { NotificationManager mNotificationManager; Notification notification; @Override

Toast is crashing Application, even inside thread

只愿长相守 提交于 2019-11-28 12:44:07
I have an onClick event in my android app that triggers the following code but it keeps crashing my app. I put it in a thread only because i read that that's supposed to prevent crashing. Also ctx refers to the Activity's context (it's a variable I created in the activity set equal to this. I've read and tried several things. Any help would be awesome. Thanks! Thread toastThread = new Thread() { public void run() { Toast alertFailure = Toast.makeText(ctx, "Login Failed", Toast.LENGTH_LONG); alertFailure.show(); } }; toastThread.start(); You need to use runOnUiThread Something like

Problem with Toast in AsyncTask method call

余生长醉 提交于 2019-11-28 10:28:04
Hey Everybody, I have an AsyncTask that posts some data to a server. It does this by calling a static method that I wrote from doInBackground. When I run the AsyncTask, I send the context of the activity that called execute(), which I send to my static method, because it needs it to make a Toast if something goes wrong while talking to the server. However, I get this error when a Toast is made in the static method: 04-21 12:49:16.689: ERROR/AndroidRuntime(2123): FATAL EXCEPTION: AsyncTask #1 04-21 12:49:16.689: ERROR/AndroidRuntime(2123): java.lang.RuntimeException: An error occured while

Android - Confirm app exit with toast

不问归期 提交于 2019-11-28 07:02:31
I'm new to Android development and I want it so when the user presses the back button on the main activity, a toast message appears with a "confirm exit by pressing the back button again" message. How would I do this? This is what I have so far: @Override public void onBackPressed() { // TODO Auto-generated method stub super.onBackPressed(); Toast s = Toast.makeText(getBaseContext(), "Press back again to exit", Toast.LENGTH_LONG); s.show(); wait(); public boolean onBackPressed() { finish(); } } I would just save the time of the backpress and then compare the time of the latest press to the new

Show toast at current Activity from service

杀马特。学长 韩版系。学妹 提交于 2019-11-28 05:49:13
问题 I need to show Toast at the current Activity if it come some updatings to the Service. So Service call server and if it is some updatings, I need to notificate user nevermind at which Activity he is. I try to implement it like this: Toast.makeText(ApplicationMemory.getInstance(), "Your order "+progress+"was updated", Toast.LENGTH_LONG).show(); where public class ApplicationMemory extends Application{ static ApplicationMemory instance; public static ApplicationMemory getInstance(){ return

How can I show a toast for a specific duration?

大兔子大兔子 提交于 2019-11-28 04:33:52
This is the way I have to show the Toast for 500 milliseconds. Though, it's showing more than a second. Toast.makeText(LiveChat.this, "Typing", 500).show(); How can I show Toast only for 500 milliseconds? This cannot be done. To show a toast for a length shorter than Toast.LENGTH_SHORT , you must cancel it after the time you want. Something like: final Toast toast = Toast.makeText(getApplicationContext(), "This message will disappear in half a second", Toast.LENGTH_SHORT); toast.show(); Handler handler = new Handler(); handler.postDelayed(new Runnable() { @Override public void run() { toast

Android: How to set the colour of a Toast's text

孤人 提交于 2019-11-28 04:18:21
I am displaying a toast message as the result of an if statement using the following code: Toast.makeText(getBaseContext(), "Please Enter Price", Toast.LENGTH_SHORT).show(); It is displayed as white text on a white background, as such it can not be read! My question is, how can I change the colour of the toast's text? Mandel You can create a custom Toast view to suit your requirements. See the section titled "Creating a Custom Toast View" at http://developer.android.com/guide/topics/ui/notifiers/toasts.html You can achieve this very easily, without creating a custom layout by modifying the

java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare();

微笑、不失礼 提交于 2019-11-28 03:25:50
I have an Android app running a thread. I want a Toast message to show with a message. When I do this, I get the below exception: Logcat trace: FATAL EXCEPTION: Timer-0 java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare() at android.os.Handler.<init>(Handler.java:121) at android.widget.Toast$TN.<init>(Toast.java:322) at android.widget.Toast.<init>(Toast.java:91) at android.widget.Toast.makeText(Toast.java:238) Is there a work around for pushing Toast messages from threads to the User Interface? Eric Leschinski I got this exception because I was

How to cancel Toast created in a different method on android?

ⅰ亾dé卋堺 提交于 2019-11-28 03:14:34
问题 I have the following code: private Toast movieRecordToast; private void displayNextMovie() { if (movieRecordToast != null) movieRecordToast.cancel(); // cancel previous Toast (if user changes movies too often) movieRecordToast = Toast.makeText(getApplicationContext(), "Next", Toast.LENGTH_SHORT); movieRecordToast.show(); private void displayPrevMovie() { if (movieRecordToast != null) movieRecordToast.cancel(); movieRecordToast = Toast.makeText(getApplicationContext(), "Prev", Toast.LENGTH