Mono for Android Introduction

Source: Internet
Author: User

The first chapter briefly describes mono and mobile device related knowledge, and review the main content of the previous chapter:

A simple comparison of. NET Framework and mono

Precautions and brief introductions for mobile development, Android, and cross-platform tools

In this chapter, we will give a brief introduction to mono for Android. The main contents of this chapter include:

1. Introduction to mono and mono for Android

2. Configure the development environment

3. mono for Android tool for Visual Studio

4. debugging and deployment

---------------------------------------------------------------------- I am a gorgeous splitting line ----------------------------------------------------------------------------------------------

I. Preparations before development

Mono: Mono is an open-source project launched by xamarin. It is mainly used to create. Net CLI, C # compiler, and ECMA standard implementation of Open Development stacks.

Currently, Mono has three main goals:

(1) Open-source CLI

(2) C # Compiler

(3) Open Development Stack

Mono complies with ECMA standards. ECMA International was established in 1961 to support standards of information and communication technologies.

Mono for Android: mono for Android is a runtime and Development stack. NET developers can make full use of their existing Visual Studio and C # knowledge to develop applications for Android-based devices.

(1) runtime: mono for Android is an application running on the Linux kernel of the android stack. It is responsible for interpreting the mono byte code and communicating with the Java VM, allows you to easily call the android API of a local machine.

(2) Development Stack: mono for Android is also a development stack that provides tools required to create and package Android device applications.

Why mono for Android:

(1) familiar Development Environment

(2) familiar APIs and library structures. The following table shows some Assembly sets in mono for Android 4.0.1.

Assembly Description
Mono. Android. dll Contains C # bound to the android API #
Mono. compileservices. symbolwriter. dll Mainly for Compiler writers
Mono. Data. SQLite. dll Ado. net provider for SQLite
Mono. Data. TDS. dll TDS supports the system. Data. sqlclient in system. Data.
Mono. Security. dll Encryption API
Mscorlib. dll Silverlight
Opentk. dll OpenGL/openal object-oriented API, which can be expanded to provide support for Android devices
System. dll

Silverlight, plus the types from the following namespaces:

System. Collections. Specialized

System. Componentmodel

System. componentmodel. Design

System. Diagnostics

System. Io. Compression

System. net

System. net. Cache

System. net. Mail

System. net. Mime

System. net. networkinformation

System. net. Security

System. net. Sockets

System. Security. Authentication

System. Security. Cryptography

System. Timers

System. Core. dll Silverlight
System. Data. dll . Net 3.5 with some features deleted
System. JSON. dll Silverlight
System. runtime. serialization. dll Silverlight
System. servicemodel. dll The WCF stack presented in Silverlight alpha
System. servicemodel. Web. dll

Silverlight, coupled with the following namespace:

System

System. servicemodel. Channels

System. servicemodel. Description

System. servicemodel. Web

Alpha Quality

System. Transactions. dll  
System. Web. Services. dll  
System. xml. dll . Net 3.5
System. xml. LINQ. dll . Net 3.5

 

Considerations to be weighed when using mono for Android

1. Wait for updates. That is to say, if the android SDK adds new features or enhances performance, you must wait for the next corresponding version of mono for Android.

2 potential performance impact

3. Memory Management: many objects allocated by mono for Android are packaged with Java objects represented by these objects. When a corresponding Java type is assigned, two objects are created:

(1) Java objects located in the Java heap

(2) The mono "proxy" object located in the mono heap

Mono for Android performs corresponding processing to ensure that when an object references another object, both objects remain active.

Ii. Use mono for Android for development

After installing the vs plug-in, you will see an android option when creating a project, but generally vs cannot be loaded, and the cracking program cannot crack the plug-in, it's a tough thing, ah...

:

Therefore, I directly use xamarin studio to create:

 

The default generated code is displayed, so I will not explain it much, because it can be understood...

By default, a button clicking function is generated, and the number of clicks is accumulated. If all the environment is configured, click debug to see the effect.

This section briefly introduces the button placement location. The button is placed in the main. axml file in the layout folder under the resources folder.

Log record:

Android. util can be referenced to use the logging function of Android.

Log. Info ("", ""); record information
Log. Error ("", ""); record Error
Log. Warn ("", ""); record warning

Test:

The best way to test a self-developed application is to construct a unit test and use nunit.

Deployment:

Deploying a helloandroid application to a mobile device is very simple. There are three steps:

(1) connect to the mobile phone through USB

(2) set the mobile phone to the Development Mode

(3) Click the debug button. When you find your device, select it. The installation process runs on the selected device through USB.

 

This chapter ends here. In the next chapter, we will start to learn about the core components of Android.

 

Welcome to shoot bricks...

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.