Native code on Windows Phone 8(转)
Windows Phone 8 introduces the ability to use native code to implement Windows Phone. In this section, we explain how you can use C++ in your app, and provide some recommended scenarios.
When to use native code in your app
All Windows Phone 8 apps can use native code but not all apps need to. For many app scenarios, a managed app provides the same features and performance as an app that uses native code. The following are reasons why you may want to use native code in your app.
- Portability – If you are targeting multiple platforms, it may make sense to implement your core functionality in a native library that can be used on all of the platforms you are targeting.
- Direct3D graphics – If your app needs to use Direct3D to render graphics to the screen, this must be done using native code.
- Performance – For some scenarios, you can achieve a performance benefit in large computation tasks by using native code. Note that there is overhead associated with the interop between native and managed code. This overhead may cancel out any performance gains from using native code, so don’t assume that using C++ will automatically increase the performance of your app.
Windows Phone 8 supports Visual C++ 2012. This is the full version of C++ that is available on the desktop, and the two versions use the same compiler and IDE. This means that your phone app can reuse existing C and C++ libraries that you have developed for other platforms, in addition to third-party libraries and middleware.
Windows Phone 8 supports a limited set of COM and Win32 APIs that are available on the desktop. For info about which APIs are supported, see Win32 and COM API for Windows Phone 8.
All Windows Phone 8 apps also can use the Windows Phone Runtime, which is a phone-specific implementation of the Windows Runtime, which is used for desktop apps. The Windows Phone Runtime provides infrastructure and an API library. The infrastructure is the core plumbing of the language, including type activation, memory management, a common type system, and a standard programming model that encompasses objects, methods, events, exceptions, and so on. The Windows Phone Runtime library contains phone-specific APIs for features such as speech, managing contacts, location, sensors, networking, and more. In addition, the library supports a subset of the Windows Runtime library that’s available on the desktop. All of these APIs are projected into Visual Basic, C#, and C++ on the phone. For more info about the APIs supported on the phone, see Windows Phone Runtime API.
The Windows Phone Runtime also enables interop between managed and native code. You can add a Windows Phone Runtime component implemented in C++ to your project and then access the objects and methods in the component directly from managed code. Note that there is some overhead cost when using Windows Phone Runtime because of things like reference counting and array bounds checking. For this reason, we recommend that you use it only on the boundary between managed and native. Especially if you are implementing a computation scenario in which performance is key, you should write your computation library in straight C or C++ and then create a Windows Phone Runtime wrapper that can be called from managed code.
Direct3D graphics on Windows Phone
Windows Phone 8 introduces the ability to use Direct3D in your app, and Direct3D code must be written in C++. You can use the XAML and Direct3D app and the Direct3D with XAML app project templates to create hybrid apps in which the UI is defined in XAML with managed (C# or Visual Basic .NET [VB.NET]) code-behind pages. With these apps, a Windows Phone Runtime component contains the native Direct3D code, which renders to the screen within or behind the XAML UI. The Direct3D app project template creates a pure native app that uses no XAML or managed code. Because of this, there are several feature and app model differences between this type of app and a XAML-based app. For guidance on determining which app type is right for your app, see Choosing the right project template for your game for Windows Phone 8.
For info about Direct3D API support on Windows Phone, see Direct3D for Windows Phone 8.
Unsupported native code scenarios
The following uses of native code are not supported for Windows Phone apps.
- Native code can’t be called from an XNA app.
- Windows Phone 8 doesn’t support the XAML UI with C++ code-behind app model that is supported for Windows Store apps.
- Native code can’t be called from Windows Phone OS 7.0 or Windows Phone OS 7.1 apps. Only Windows Phone 8 apps can use this feature.
from http://msdn.microsoft.com/en-US/library/windowsphone/develop/jj681687(v=vs.105).aspx
Native code on Windows Phone 8(转)的更多相关文章
- Windows Phone中使用Native Code
前言 Windows Phone 8 SDK中一个非常有用的特性,就是可以通过Windows Phone Runtime Component (WinPRT)使用C++代码来处理运算量大的任 ...
- NDK开发历程(一):android native code的调试方法
引用:http://www.cnblogs.com/ychellboy/archive/2013/02/22/2922683.html 使用NDK在android上做开发是一件“痛并快乐着”的差事,之 ...
- NDK环境搭建(Native Code的编译,不需要Cygwin)
分类: android2013-06-21 15:49 475人阅读 评论(0) 收藏 举报 Android NDK 目录(?)[-] System and Software Requirements ...
- DEPLOYING NATIVE UWP (UNIVERSAL WINDOWS PLATFORM) APPS FOR JAVA DEVELOPERS & PUBLISHING THEM TO THE MICROSOFT STORE
原文: DEPLOYING NATIVE UWP (UNIVERSAL WINDOWS PLATFORM) APPS FOR JAVA DEVELOPERS & PUBLISHING THEM ...
- [Xamarin] 透過Native Code呼叫 JavaScript function (转帖)
今天我們來聊聊關於如何使用WebView 中的Javascript 來呼叫 Native Code 的部分 首先,你得先來看看這篇[Xamarin] 使用Webview 來做APP因為這篇文章至少講解 ...
- 打印发现function toUpperCase() { [native code] }
var s='hello' undefined s.toUpperCase function toUpperCase() { [native code] } s.toUpperCase() " ...
- 不可或缺 Windows Native (25) - C++: windows app native, android app native, ios app native
[源码下载] 不可或缺 Windows Native (25) - C++: windows app native, android app native, ios app native 作者:web ...
- [Cordova] 无法编译Visual Studio项目里Plugin副本的Native Code
[Cordova] 无法编译Visual Studio项目里Plugin副本的Native Code 问题情景 开发Cordova Plugin的时候,开发的流程应该是: 建立Cordova Plug ...
- 优秀开源代码解读之JS与iOS Native Code互调的优雅实现方案
简介 本篇为大家介绍一个优秀的开源小项目:WebViewJavascriptBridge. 它优雅地实现了在使用UIWebView时JS与ios 的ObjC nativecode之间的互调,支持消息发 ...
随机推荐
- 【代码笔记】iOS-判断是否是模拟机
一,代码. - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. ...
- Android touch事件处理流程
前面我们看了key事件的处理流程,相信大家对此已经有了新的认识,这篇文章我打算带领大家来看看稍微复杂些的touch 事件的处理流程.说它复杂是因为key事件本身就key down,up,long pr ...
- WPF学习之路(一) 初识WPF
参考<葵花宝典-WPF自学手册> VS2012 先创建第一个WPF小程序 1.创建WPF程序 2.查看Solution,WPF中xaml文件和cs文件经常成对出现 两个主要的类:APP(W ...
- 对js中Function的浅见
它到底是什么 String Array 都是系统内置对象(已经定义好,可以直接使用)当然,这货也是一样,我们之前定义的函数,其实就是一个这货的实例. 在JS中,所有的对象都是由函数实现的,函数的数据类 ...
- ARC下的所有权修饰符
ARC有效时,id类型必须加上所有权修饰符 下面为三种等效的声明,为了便于和二级指针的情况联系起来,采用第一种. NSError * __weak error = nil; NSError __wea ...
- Linux Swap交换分区介绍总结
Swap交换分区概念 什么是Linux swap space呢?我们先来看看下面两段关于Linux swap space的英文介绍资料: Linux divides its physical RA ...
- Android海康监控视频调用demo
一. 开发环境 1. 操作系统:windows7(X64) 2. 开发工具:eclipse adt Build: v22.2.1-833290 JDK7 android SDK 3. 客户端设备版本: ...
- spring 依赖注入(IOC DI)
依赖注入(IOC DI) 依赖注入的两种方式: 1. set注入 Spring要求使用set注入方式的时候,Bean需要提供一个无参数的构造方法.并提供一个属性的setter方法.例如: packag ...
- C#显示SQL语句格式
--SQL SERVER生成测试环境: Create database Test; go USE [Test] GO if OBJECT_ID('Tab','U') is not null drop ...
- 烂泥:rsync配置文件详解
本文由秀依林枫提供友情赞助,首发于烂泥行天下. 对于rsync服务器来说,最重要和复杂的就是它的配置了.rsync服务器的配置文件为/etc/rsyncd.conf,其控制认证.访问.日志记录等等. ...