After configuring the development environment, we will start learning about monoforandroid. Before entering development, we will give a brief introduction to some basic knowledge. The write may be messy or cool. Sorry.
In the past few years, the use of smartphones has grown at an astonishing rate. Unlike desktop computers, the growth and popularization of smartphones have also brought about competition. Currently, no one or platform has dominated the mobile device market; mobile devices can use Symbian, Research In Motion, Windows Mobile, Android, and other platforms. In addition, devices can run the same operating system and present it to users in different appearances. The cracks in the market are a big problem for developers: How do they use an existing development framework or tool and how they use knowledge about a certain device?
This chapter describes how. Net/C # developers can complete development on mobile phones (Android) with the highest platform popularity.
1.1 product comparison
This section describes. NET Framework, Mono, and mono for Android. These products allow a large number of Android Developers to develop for the Android mobile device family.
. NET Framework
The framework is based on a virtual machine used to execute software written for the framework. This virtual machine environment is called Clr and is mainly responsible for security, memory management, program running, and exception handling.
In. the source code of an application written in the. NET Framework is initially compiled into an intermediate language named msil, which is executed by a specific command line compiler, when an application is executed, it usually performs secondary compilation. The secondary compilation gets the intermediate language and compiles it into executable code that can be run in the operating system, secondary compilation is called JIT compilation.
The framework is language-independent and can be used in multiple languages. Such as VB, F #, C ++, and C #.
The framework contains a series of libraries that provide consistent functions for different languages. These libraries are called base class libraries.
However, this framework has a disadvantage: it cannot be used by non-Microsoft platforms.
All of this means that Microsoft has created a standard-based environment for. NET Framework, allowing many low-level developers to integrate into. NET Framework.
Mono
Mono is an open-source project that provides C # compilers and CLR in non-Windows operating systems. It can be run on Mac, Linux, BSD, and other operating systems. Through the C # compiler, you can also run other languages in mono, including F #, Java, Scala, and basic.
The founder of Mono is Miguel Icaza. As for the introduction of this person, I will not mention it. You can use Baidu or Google.
Although mono functions are expected to be as many as possible. net Framework functions match, but this is not possible, because Microsoft has more resources and has the advantage of starting to develop these functions. xamarin can only be implemented at most.. NET Framework.
One of the shortcomings of. Net/mono and Android is that. Net/MONO developers cannot use their existing. Net/MONO/C # knowledge on the Android platform .. Net/MONO developers cannot develop for Android, because they are two completely independent entities. Mono for Android was built on monotouch (allowing C # developers to develop Apple's iPhone) experience...
Mono for Android
The APIS exposed by mono for Android are core functions of. NET Framework 4, Silverlight APIs, and a combination of local Java VMS. The mono for Android native API provides a bridge (interoperability) layer between. NET and C # APIs that developers are familiar.
Mono for Android consists of a group of Assembly, namespace, and classes optimized for mobile platforms.
Namespaces and classes:
Mono. Android. dll |
This Assembly provides C # binding for Android APIs, including namespaces that support Android. * namespaces. |
System. dll |
This collection provides many. NET Framework functions for mono for Android. |
Momo. Data. SQLite. dll |
This Assembly is an ADO. net provider for the local SQLite database. |
Mono. Data. TDS. dll |
This Assembly provides support for the TDS protocol, which is mainly used to connect to SQL Server |
Opentk. dll |
This Assembly provides support for OpenGL |
System. JSON. dll |
This Assembly provides support for using JSON |
System. servicemodel. dll |
This Assembly provides support for WCF |
System. xml. dll |
This Assembly provides support for XML |
System. xml. LINQ. dll |
This Assembly provides support from LINQ to XML |
Below are some important namespaces provided by mono for Android. |
|
Android |
The android. * namespace provides support for resources, classes, and application permissions. |
Android. Bluetooth |
This namespace provides support for Bluetooth |
Android. Database |
This namespace provides support for the SQLite database on the device |
Android. Graphics |
This namespace provides graphic display support |
Android. Hardware |
The namespace provides support for hardware on Android devices. |
Android. Location |
This namespace provides necessary support for Location |
Android. net |
This namespace provides network support, including support for VoIP (Voice over IP) and WiFi |
These namespaces are only a small part of the available namespaces in mono for Android, and their functions are self-evident. These namespaces are specific to Android and the code they are written can only run on Android-based devices.
1.2 Mobile Development
When building an application, you must keep in mind the following points:
(1) The Android simulator is suitable for initial testing. It is not accurate for all tests. The final test should be completed on different Android devices.
(2). Net executable files are very small, because these files can use shared copies of the framework. Mono for Android can be deployed in two different ways. The most common method is to bind the application with mono for Android, the second method is to share the mono framework with applications.
(3) It is very important to become a good citizen on the device.
In addition to the technical issues involved in building apps for Android, developers also need to understand some design issues:
(1) do not design an application for a desktop environment before downgrading it to Android or any mobile device.
(2) The Android simulator is a very good tool, but do not restrict the test to this tool.
(3) When testing on a mobile device, although WiFi is also a mobile network, WiFi in the office or home can provide higher quality than the network of a mobile operator.
1.3 android
I will not talk about the development history of Android. If you are interested, click Baidu or Google.
Running applications on mobile devices is a problem that developers must consider:
(1) There are many appearance sizes, screen sizes, and devices, so developers must consider the differences between devices.
(2) developers must consider different versions of the Android operating system.
(3) developers must take a realistic attitude towards the app sales figures provided by Android Market.
1.4 cross-platform alternative
In addition to mono for Android, there are other cross-platform mobile development tools, such as phonegap, appcelerator titanium, and fig.
When selecting a cross-platform tool, consider many different situations. In some cases, selecting a tool may provide a solution that is too simple, and make maintenance/functions very difficult or even impossible to handle... Therefore, it is very important to select an appropriate tool.
This chapter will introduce you here and review:
A simple comparison of. NET Framework and mono
Precautions and brief introductions for mobile development, Android, and cross-platform tools.
You are welcome to make a brick...