This article introduces you to the implementation of some common initiators in Windows Phone 8.1. Call calls, send text messages, send messages, add appointments to calendars, launch maps, map route displays, map downloads, and map updates, respectively.
1. Call the phone
We use Phonecallmanager's Showphonecallui method to implement call calls. The two parameters of the method are the phone number and display name, respectively.
Windows.ApplicationModel.Calls.PhoneCallManager.ShowPhoneCallUI ("10086"" China Mobile ");
2. Send SMS
We use Chatmessagemanager's Showcomposesmsmessageasync method to send text messages. The method receives the parameter as a Chatmessage object, where the important attributes are Body (information content) and Recipients (the collection of phone numbers sent to).
New"This isbody of demo message. " ; Msg. Recipients.add ("10086"); Msg. Recipients.add ("10010"); await Windows.ApplicationModel.Chat.ChatMessageManager.ShowComposeSmsMessageAsync (msg);
3. Send mail
We use Emailmanager's Showcomposenewemailasync method to send text messages. The method receives a parameter that is a Emailmessage object, which has several important properties:
- To: Recipient list
- BCC:BCC List
- CC:CC List
- Subject: Message subject
- Body: Message body
- Attachments: List of attachments
varFile =awaitgetattachment (); Windows.ApplicationModel.Email.EmailAttachment emailattachment=NewWindows.ApplicationModel.Email.EmailAttachment (file. Name, file); Windows.ApplicationModel.Email.EmailMessage Mail=NewWindows.ApplicationModel.Email.EmailMessage (); Mail. Attachments.Add (emailattachment); Mail. Subject="This is Subject"; Mail. Body="This is body of demo mail"; Mail. To.add (NewWindows.ApplicationModel.Email.EmailRecipient ("[email protected]","Shaomeng")); awaitWindows.ApplicationModel.Email.EmailManager.ShowComposeNewEmailAsync (mail);
The GetAttachment method is as follows:
Private AsyncTask<storagefile>getattachment () {varfolder =Windows.Storage.ApplicationData.Current.LocalFolder; varsubfolder =awaitFolder. Createfolderasync ("MyFolder", Windows.Storage.CreationCollisionOption.OpenIfExists); varFile =awaitsubfolder. Createfileasync ("MyAttachment.txt", Windows.Storage.CreationCollisionOption.ReplaceExisting); awaitWindows.Storage.FileIO.WriteTextAsync (file,"Hello world!"); returnfile; }
4. Add an appointment to the calendar
We use Appointmentmanager's Showaddappointmentasync method to add our defined appointments to the calendar and to manage existing appointments. The method receives the parameter as a appointment object. There are several important attributes:
- Subject-the subject of the appointment
- Location-where the appointment is
- Details-Detailed information about the appointment
- Duration-duration of the appointment
- StartTime-time to start dating
- AllDay-whether it lasts all day
In addition, there are many properties can be set, no longer one by one cases, we can study on their own. Take a look at the code implementation:
Windows.ApplicationModel.Appointments.Appointment appointment =NewWindows.ApplicationModel.Appointments.Appointment (); Appointment. AllDay=false; Appointment. Details="appointment ' s Detail"; Appointment. Duration= Timespan.fromhours (2.0); Appointment. Location="Demo Location"; Appointment. StartTime=DateTime.Now; Appointment. Subject="Demo Subject"; awaitWindows.ApplicationModel.Appointments.AppointmentManager.ShowAddAppointmentAsync (Appointment,NewRect ());
We've created a new date that lasts for two hours now. To see how the results work:
5. Start the map
The Uri,uri format that we use Windows.System.Launcher's Launchuriasync to launch Bing Maps is Bingmaps:uri scheme. For specific URI scheme, please refer to: URI scheme for maps application.
await Windows.System.Launcher.LaunchUriAsync (Thenew Uri ("bingmaps:?lvl=10&where=beijings ", Urikind.absolute));
As in the code above, we launch Bing Maps, showing the results of the search at level 10, which is Beijing. To see the results of the operation:
6. Map Route Display
We also use Windows.System.Launcher's launchuriasync to launch the Bing map URI to show the route plan, which is also referenced in the following format: URI Scheme for maps application.
await Windows.System.Launcher.LaunchUriAsync (Thenew Uri ("Bingmaps:?rtp=adr"). Beijing~adr. Tianjin", Urikind.absolute));
This is the route we want to show Beijing to Tianjin, to see the results of the operation:
7. Map download
We use Mapmanager's Showdownloadedmapsui method to launch the map download interface.
Windows.Services.Maps.MapManager.ShowDownloadedMapsUI ();
8. Map Updates
We use Mapmanager's Showmapsupdateui method to launch the map update interface.
Windows.Services.Maps.MapManager.ShowMapsUpdateUI ();
OK, here we have the Windows Phone 8.1 part of the commonly used launcher is finished, we hope to help, thank you.