android - Acitivity ignores showing Toasts when executed from my Thread -


Why do I only see "first" toast and not others (should be made from my thread)?

  Expanding Public Category Banner Example Activity {@ Override Creature (Last Bundled Saved Instance) on Super Zero {super.onCreate (savedInstanceState); Toast toast = toast Maketext (this, "First Toast", Toast. LNNGHHRT); Toast.show (); New maththread (this). Start (); } The class extends the MyThread thread {Personal reference context; Public maththread (reference reference) {this.context = context; } Public Zero Run () {Looper.prepare (); // One exception was asked to add me - I have no clue why (int i = 0; i    

  1. You should not call Looper. . You were getting the exception because you were doing something wrong:
  2. The tour UI is part of the toolkit, and therefore should be used with the UI thread - this is why you are having an exception
  3. I suggest that you swap to thread and use the onProgressUpdate method to create your toasts because it runs on the UI thread automatically is. Otherwise you will need to use a handler.
  4. Pass reference from getBaseContext instead of context to your constructor with current activity

Comments