HoloLens Development Notes-build 2D apps Building 2D Apps

Source: Internet
Author: User
Tags try catch silverlight

HoloLens allows us to see holographic content in the real world. But it's essentially a Windows 10 device, which means that HoloLens can run most UWP apps in the Windows Store as a 2D app.

Target platform set to Windows.universaltargeting Windows.universal

Microsoft's platform has been changing over the past few years, so developers tend to have different starting points, so here are some guidelines to help developers of different starting points move smoothly through the code with the UWP platform.

a different starting pointstarting Points

There are a lot of Windows platforms that we've been exposed to in the last few years, and the following are guidelines for them.

Starting point

AppX Manifest Inventory Target platform

How do I migrate to the UWP?
Windows Phone (Silverlight) Silverlight APP Manifest Checklist Migrate to WinRT
Windows Phone 8.1 Universal 8.1 AppX manifest manifest that does not contain the target platform Migrate your app to the Universal Windows Platform
Windows Store 8 8 AppX manifest manifest that does not contain the target platform Migrate your app to the Universal Windows Platform
Windows Store 8.1 Universal 8.1 AppX manifest manifest that does not contain the target platform Migrate your app to the Universal Windows Platform

Modify target platform to Windows.universalChange your Target to Windows.universal

Once you've adapted to the guidelines, your app can run with the UWP platform, including phones, PCs, Xbox and HoloLens, and more.

Now let's open the APPX project manifest file and make sure your UWP app can run on HoloLens.

    • Open your VS project and navigate to the manifest file
    • Right- package.appxmanifest The manifest file, select View Code

    • Ensure that the target platform in the <Dependencies> section is Windows.universal

< Dependencies >  <  Name= "Windows.universal"  minversion= "10.0.10240.0"  maxversiontested= "10.0.10586.0"/></Dependencies  >

    • Save the manifest file

You can use any text editor to modify this manifest file, and the effect is the same.

Run the app on the emulatorRun in the HoloLens Emulator

Now you can build the project directly and run your app on the HoloLens emulator.

    • Make sure you have the HoloLens emulator installed
    • Select x86 as the target platform architecture

    • Select the HoloLens emulator as the deployment target

    • Start debugging on the emulator
    • You can use the keyboard mouse to simulate the operation of HoloLens to test your application

Subsequent steps next Steps

The following two scenarios may occur when you launch an app:

    1. The app runs immediately after it's been placed and displays a splash screen image, which means everything is OK.
    2. The app appears loaded after being placed, and the splash screen is still displayed, which indicates that your app started with an error and needs to be resolved.

How to DebugHow to Debug

HoloLens is a newly-emerged Windows 10 device, so many UWP APIs are still in beta and development stages on HoloLens. Here are some of the problems we found:

    • File system query operation is not supported at app startup
    • Use a traditional authentication method other than the Web authentication agent or Web account Manager
    • More in-depth query of hardware devices at startup
    • The calendar, contacts, protocols, and other APIs are used at startup
    • Using some large third-party libraries may result in auditing not being passed on HoloLens

To figure out what causes your app to not start properly, you need to debug it.

Running an app from the debuggerRunning your UWP app in the debugger

The debugging steps are simple, with the menu debug > Start Debugging.

    • If an unhandled exception occurs in the application, it is captured by the debugger the first time, and the relative exception information is displayed in VS. If you have already used the try catch in the application to do the exception capture processing, then the exception information can be obtained by your code, can be displayed like that.

    • You can also fix the problem code block in detail by interrupting point-by-step debugging, which generally solves most problems.

Understand the causes of application errors understanding the failure

As mentioned above, the HoloLens developer version has some known issues that are caused by the APIs in the test and development. If your app uses APIs from the list of potential problem APIs, you can get feedback to Microsoft via the Windows Feedback tool.

How to open the Windows Feedback tool

    1. Gesture to summon the Start menu
    2. Open the Windows Feedback app
    3. Select Developer Platform, then send error details to Microsoft

Microsoft will continue to fix problems with the UWP API. But for some APIs that don't support HoloLens because of design, here are some possible workarounds:

Error code codes

    • A special HRESULT error should not be returned because the API is not yet complete. Instead, the API should throw an error message by using an empty collection, a Boolean return value, an explicit status code, and so on. Note that if the API has returned an HRESULT because of a programming error, such as passing an invalid parameter, it will continue to return these errors as appropriate.
Set collections
    • When we use a property indexer or the return value of a method is a collection, you should not simply return a null object directly, but rather return a collection object with a quantity of 0.
    • In rare cases, the API exposes a read/write collection type attribute that allows the application to provide its own value. In these cases, if the API has returned null in full functionality, it should continue to return null in the case of partial functionality. Note that this is an anti-pattern for API design, and most UWP APIs should not follow it generally.
Async method Asynchronous functions
    • Empty iasyncaction or iasyncoperation results should not be returned from async async methods. Instead, they return a valid object that is already in the completion state of the task and has the appropriate results (empty collection, status code, and so on).
Event Events
    • Events should not fail or ignore event registration behavior. Instead, the API should accept the event Registration/cancellation event registration, but never raise an event. The API must hold any registered event handlers (rather than silently ignore them) because the application may inadvertently rely on registered events for lifecycle management.

Update UI update your UI

Now your app is showing up in the world in the form of a 2D panel in HoloLens, we should make our app look prettier below. Here are some things to consider:

    • HoloLens will run all 2D applications at fixed resolutions and dpi, equivalent to 853x480 effective pixels. Consider whether your design needs to be refined at this scale, and consider reviewing our 2D UI guidelines to improve the user experience.
    • The HoloLens does not support 2D live tiles. If your core functionality displays information on the active tile, consider moving the information back to the application.
    • HoloLens does not support shared contracts, 2D printing, full screen mode, projection and other features that may be in your application.

new input possibility-possibilities

HoloLens uses advanced depth sensors to perceive the world and its users. This allows advanced gestures to be used, such as Bloom and air-tap gestures. The powerful microphone also ensures a better voice experience. HoloLens is responsible for handling all the complex content of UWP apps, abstracting your gaze and gestures and translating them into pointer events for the regular UWP input mechanism. For example, HoloLens clicker simulates air-tap gestures, but 2D applications do not need to know where the input came from, they only know that a pointer click event has occurred.
The following is a high-level concept/scenario for how to enter a UWP app when migrating to HoloLens:

    • When the user stares at the app, gaze triggers a mouse hover event that could accidentally trigger a menu, pop-up window, or other user interface element,
    • Gaze is less accurate than mouse input. For HoloLens should use the appropriate size of the click Target, similar to touch-friendly mobile app UI. Small elements near the edge of the app UI are particularly difficult to interact with.
    • The user must be able to toggle the input mode in the app, from scrolling to dragging to two finger panning gestures. If your app is designed for touch input, consider making sure that no major features rely only on gestures. If so, consider using a different input mechanism, such as a button that initiates a finger panning gesture. For example, a map application can use two-finger panning for zooming, but with a plus, minus, and rotate buttons to simulate the same zoom interaction as a single click.

Voice input is a key part of the HoloLens experience. We have enabled all speech APIs in Windows 10 to provide support for Cortana on HoloLens.

Publish and maintain your UWP appPublish and maintain your Universal app on HoloLens

Once your app works, you can package it and upload it to the store.

HoloLens Development Notes-build 2D apps Building 2D apps

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.