Kubernetes client UAP development and client uap

Source: Internet
Author: User
Tags mail account

Kubernetes client UAP development and client uap

When developing a Windows Phone application, you should have noticed that Windows Phone has many restrictions on the application for security purposes. I remember a 360 student reluctantly said: WP is too safe. We have nothing to do with 360 guard on WP. However, when the App WP360 came out, many users still installed it. Although it really does not provide much help for security, however, it is helpful for users to understand their mobile phone usage. One of the users commented: from android to PC, I have been using 360, so I also use it on WP. Haha, fans! He does not care about iron powder.

Far away! Go back to this essay topic: Our application can only access its own folders and limited public folders, but cannot access the folders of other applications. This is called Sandbox. What if we want to call them? There are still methods.

Today, we will introduce two main methods for calling apps:

Protocol call

Simply put, Windows is used. system. launcher class, through a form such as "mailto: ms-uap@outlook.com" by protocol prefix mailto, colon, and a string consisting of uri, call registered protocol prefix (here is mailto) application, the process of passing the entire uri to it for processing.

For example, this Code:

Await Launcher. launchiliasync (new Uri ("mailto: ms-uap@outlook.com "));

After running, our mail application will be called to the ms-uap@outlook.com mail account mail:

Is it easy?

Of course, this only calls the system application. You can also register a third-party application with the corresponding protocol prefix. You can also register a protocol prefix to call other applications.

So how to register?

Double-click the Package. appxmanifest file of our application, select the protocol in the Declaration panel, and click Add:

Generally, you only need to enter the protocol prefix you want to register on the name. This prefix is best for our application, such as cnbloguap. In addition, on Windows and Windows Phone platforms, protocol prefixes are limited. For example, on Windows Phone, even if our application registers the protocol prefix of mailto, the system still automatically calls the system's email application. For details, see https://msdn.microsoft.com/zh-cn/library/windows/#/xaml/hh779670. After registering the protocol prefix, our application can be called through a uri such as "cnbloguap: xxxx.

So how should we handle calling the uri of our application?

This requires the override "OnActivated" method in App. xaml. cs. The Code is as follows:

Protected async override void OnActivated (IActivatedEventArgs args)

{

If (args. Kind = ActivationKind. Protocol)

{

ProtocolActivatedEventArgs protocolArgs = args as ProtocolActivatedEventArgs;

// TODO: Handle URI activation

// The specified ed URI is eventArgs. Uri. AbsoluteUri

}

}

You can use protocolArgs. Uri to obtain the complete "cnbloguap: xxxx" uri. What to do next is free.

Note that it is best to add the code of the "OnLaunched" method to start the app. Otherwise, the application will exit after processing the uri. You can refer to the example on msdn: Example.

File call

If we need to transmit a large amount of information between applications, it is inconvenient to call the protocol. Then file calls can be used.

For example, we downloaded a song "myfavorite.mp3" in the music directory and wanted to hear it immediately.

Then we can add the following snippet to our code:

Var music = await KnownFolders. MusicLibrary. GetFileAsync ("myFavorite.mp3 ");

Await Launcher. LaunchFileAsync (music );

The system will automatically call the music player to play this song. However, when the player plays this song once, the error T.T will be reported when we access this MP3 file for a while.

Similar to the protocol call, we can also register our own file type.

On the Declaration panel in the Package. appxmanifest file, select File Type Association and click Add:

Fill in the name and file type, so that the system will call our app to process the files with the. cnblogFile suffix. Of course the system still has some suffix file names, see https://msdn.microsoft.com/zh-CN/library/windows/apps/xaml/hh779669.

Of course, we also need to get the corresponding file, which requires the override "OnFileActivated" method in App. xaml. cs. The Code is as follows:

Protected override void OnFileActivated (FileActivatedEventArgs args)

{

Foreach (StorageFile argFile in args. Files)

{

// Process the corresponding file

}

}

In this way, we can get the list of Files passed to us from the Files attribute of args, and then we can process them as needed. The OnFileActivated method should also add the code of the "OnLaunched" method to start the app.

The use of file calls can also be seen in the example https://code.msdn.microsoft.com/windowsapps/Association-Launching-535d2cec/ mentioned above.

Different calls

Both the LaunchFileAsync and launchiliasync methods have heavy loads with LauncherOptions. See the use in the example and a description of the https://msdn.microsoft.com/zh-cn/library/windows/apps/windows.system.launcheroptions.aspx.

 

Share code and change the world!

Windows Phone Store App link:

Bytes

Windows Store App link:

Http://apps.microsoft.com/windows/zh-cn/app/c76b99a0-9abd-4a4e-86f0-b29bfcc51059

GitHub open source link:

Https://github.com/MS-UAP/cnblogs-UAP

MSDN Sample Code:

Https://code.msdn.microsoft.com/CNBlogs-Client-Universal-477943ab

Related Article

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.