Read about how to send multimedia message on android, The latest news, videos, and discussion topics about how to send multimedia message on android from alibabacloud.com
hell is going on here? The reason is that the view components in the Android system are not thread-safe, and if you want to update the view, you must update it in the main thread, and you cannot perform the updated operation on the child thread.In this case, we will notify the main thread in the child threads, let the main thread do the update operation. So how do we notify the main thread? We need to use the handler object.Let's modify the above cod
In Android, it's not safe to update UI controls in a non main thread, and app runs directly crash, so when we need to update UI controls in a non main thread, we need to use handler and message to implement demo, Use to a button and a TextView, click on the button to change the content of the TextView, button click to create a new process, the UI control in the process to modify.
public class Mainac
Before also because weekend night watching TI3 competition, has not found the time to write a blog, resulting in a long period of not updated. Ashamed! Back to the progress of the next, try to make sure to write every week. Here is also the first to congratulate the Alliance team from Sweden won the TI3 champion, I hope next year China team can tiger up!Getting started, we all know that the Android UI is thread insecure, and if you try to do UI action
Parse Android Message Processing Mechanism
-- Handler/thread/logoff messagequeue
Tian haili @ csdn
Keywords: Android message handlerthread low.uml
This article explains how Android uses handler/thread/logoff and messagequeue to implement the internal implementation of t
object described in section 2 are called in the working thread, the thread synchronization issue should be carefully considered. If necessary, add a synchronization object to protect the variable.
4. The handleMessage interface of the handler object will be called in the main thread. In this function, you can call any variables and functions in the main thread with confidence to complete the UI update task.
5. Many Android APIS also use the Handler t
(); Bundle.putint (Upper_num, Integer.parseint (Etnum.gettext (). toString ())); Msg.setdata (bundle);//Send a message to handler in a new threadCalThread.mHandler.sendMessage (msg); } }PS: This example comes from "Android Crazy Handout" ~Summary of this sectionThis section is a simple analysis of the handler event transmission in
handler for the multipart/mixed part, so this bit needs to be added. MailcapCommandMap mc = (MailcapCommandMap) CommandMap.getDefaultCommandMap(); mc.addMailcap("text/html;; x-java-content-handler=com.sun.mail.handlers.text_html"); mc.addMailcap("text/xml;; x-java-content-handler=com.sun.mail.handlers.text_xml"); mc.addMailcap("text/plain;; x-java-content-handler=com.sun.mail.handlers.text_plain"); mc.addMailcap("multipart/*;; x-java-content-handler=com.sun.mail.handlers.multipart_mixed"); mc.a
$calledfromwrongthreadexception:
Only the original thread, created a view hierarchy can touch its views.
What the hell is going on here? The reason is that the view components in the Android system are not thread-safe, and if you want to update the view, you must update it in the main thread, and you cannot perform the updated operation on the child thread.In this case, we will notify the main thread in the child threads, let the main thread
ObjectiveAndroid developers know that the UI control cannot be modified on a non-main thread because Android rules to access the UI only in the main thread, and if the UI is accessed in a child thread, the program throws an exceptionandroid.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy .Also, Android does not recommend that you take some time-consum
In Android, the UI thread does not agree to be blocked. So we're going to put the time-consuming work into a sub-thread to deal with.How do you notify the UI thread when the child threads are time-consuming to process?We can create a handler object in the main thread of the UI, and then, by overriding its Handlemessage (Message msg) method, it receives SendMessage (mess
Android sends SMS messages with more than 70 Chinese characters. The text message is automatically split and android sends SMS messages.
1. Text message sending code
SmsManager smg = SmsManager. getDefault ();// Text messages have a limit on the number of words. 70 Chinese characters. Make judgment.
ArrayList //
(); } //Worker Threads Private classWorkthreadextendsThread {@Override Public voidrun () {//...... Handle more time-consuming operations//send message to Handler when processing is completeMessage msg =NewMessage (); Msg.what=completed; Handler.sendmessage (msg); } }}In this way, we can solve the problem of thread safety, the complex task processing to the child thread to complete, and
();
Final String message = Ex.getmessage ();
Use Toast to display exception information
New Thread () {
@Override
public void Run () {
Looper.prepare ();
Toast.maketext (Mcontext, "program error:" + message, Toast.length_long). Show ();
You can create only one file, then all the way to the inside append and then send, so there will be duplicate informati
();//fill in the message host, I am using 163email.sethostname ("smtp.163.com"), Email.settls (True), Email.setssl (TRUE);//Set character encoding format,Prevent Chinese garbled email.setcharset ("GBK");//Set the recipient's mailbox Email.addto ("[email protected]");//Set the sender's mailbox Email.setfrom ("[Email Protected]///fill in the sender's username and password email.setauthentication ("123", "123");//fill in the subject of the
When learning an Android thread, using a child thread directly in the UI thread to update the contents of the TextView display will have the following error: Android.view.viewroot$calledfromwrongthreadexception:only the Original thread that created a view hierarchy can touch it views.The general idea is that only the thread that created the control can update the contents of the control.In Android, if you w
Removes the limit that Android 2.2 can send 100 messages per hour.
First install the Android 2.2 SDK,Http://developer.android.com/sdk/index.html orHttp://androidappdocs.appspot.com/sdk/index.html
Download android-sdk_r10-windows.zip, decompress it, and run the SDK manager.exe to install it.If JDK is not installed,
In Android, the UI thread is not allowed to be blocked, so we have to put the time-consuming work into the sub-thread to handle.So how do you tell the UI thread when a child thread takes time to process?We can create a handler object in the main thread of the UI, and then, by overriding its Handlemessage (Message msg) method, the method receives SendMessage (message
thread {@ overridepublic void run (){//...... processing time-consuming operations // send message MSG = new message (); MSG to handler after processing is complete. what = completed; handler. sendmessage (MSG );}}}
In this way, we can solve the thread security problem by handing over the complex task processing work to the subthread for completion, and then th
servicesclassSendMessage extends Thread {@Override Public voidrun () {//TODO auto-generated Method StubSuper.run (); Try { //creating the Htmlemail classHtmlemail email =NewHtmlemail (); //The host of the message is filled out, and I'm using 163.Email.sethostname ("smtp.163.com"); Email.settls (true); Email.setssl (true); //set character encoding format to prevent Chinese garbled charactersEmail.setcharset ("GBK"); //set the recipient's m
Android Summary SeriesI. Message system elements and fundamentalsL Message QueuingL Send a messageL message ReadL Message DistributionL message loop ThreadThe
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.