C # Xamarin Mobile Development Foundation Learning Chapter

Source: Internet
Author: User
Tags sqlite database

I. Introduction of the Course

English Original: C # is the best language for mobile app development. Anything you can does in objective-c, Swift or Java, you can does in C #.

C # is the best language for mobile application development. Anything you can do in Objective-c,swift or Java, you can do it in C #.

1), this sharing course is suitable for the following groups:

1, Love Xamarin cross-platform mobile development.

2, learn more about Xamarin for Android mobile development knowledge.

Xamarin has so many technologies, xamarin.android, Xamarin.ios and Xamarin.Forms, in addition to XAMARIN.UWP, Xamarin.windows, Xamarin.winphone, etc. This time a stupid sharing course is the Xamarin.android series, I hope we should see clearly the course teaching focus and coverage.

2), this sharing course contains the following dry knowledge points:

1. How the BIOS can open virtual technology virtualization Technology

2, Android Phone (charm Blue Note 3) How to open the developer debugging

3. How to quickly get started by using Xamarin to create a mobile Android app.

4, Android Introduction and SDK, version.

5, Android adb common Command Introduction

6, Android commonly used several permissions (Permission)

7. Android Life cycle

8. Android Four components

9. Android six layouts (layout)

10, Android five large storage (Storage)

11. Operation of Android files (file)

12. Intent use of Android learning

13, Android page jump and Transfer value (Activity)

14, the use of Android Learning Broadcast (broadcast)

3), the ultimate goal of this sharing course:

I hope to learn and master the development of Xamarin for Android after this sharing course, so as to reduce the learning cost of everyone!

If you are also interested in this sharing course, "C # Xamarin Mobile Development Basics", then please learn it together!

Needless to say, directly on dry goods, we do not produce dry goods, we are just dry goods porter.

Ii. explanation of the meaning of concept name

2.1. Mono Introduction

Mono is a free open source project hosted by Xamarin Corporation (formerly Novell, First Ximian). Unlike Microsoft's. NET Framework (Common language runtime), the mono project can run on Windows systems as well as Linux,freebsd,unix,os X and Solaris, and even some game platforms.

Bottom line: Mono is an open source project dedicated to creating. NET for use on Linux. It contains a compiler for the C # language that enables developers to develop programs in Linux in C #.

2.2. About Xamarin and how it works

1), Xamarin Introduction

When considering how to build IOS and Android apps, many users think native languages, Objective-c, Swift, and Java are the only choices. Xamarin its goal is to develop iOS, Android, and Windows Phone native apps in C #.

Xamarin.android provides the complete Android SDK for. NET developers. Use C # or F # in Visual Studio to generate a fully native Android app.

Xamarin.ios provides the complete IOS SDK for. NET developers. Use C # or F # in Visual Studio to build a fully native IOS app.

XAMARIN.MAC provides the complete MacOS SDK for. NET developers. Build a full native app in Visual Studio for Mac.

Xamarin.Forms is a cross-platform UI Toolkit that allows developers to effectively create native user interface layouts that can be shared across IOS, Android, Windows Phone, and universal Windows platform apps.

2), Xamarin working principle

The android application is compiled into IL code and then JIT-compiled (dynamically compiled) at startup, and a mono runtime is included when the program is published.

iOS, however, compiles the code directly to the arm through AOT compilation (static compilation). See details: Http://xamarin.com/how-it-works

2.3. Xamarin Studio Introduction

Xamarin Studio is an integrated development environment for developing cross-platform applications in the C # language, which is tightly integrated with iOS and ANDROIDSDK. Developers can use Xamarin Studio to test and bug debug mobile apps on simulators and real machines. Xamarin Studio provides the perfect support for Windows and mac!

2.4. Visual Studio Tools for Xamarin Introduction

Since Microsoft acquired the Xamarin team, we have integrated Xamarin studio into Visual Studio, which has brought great benefits to our C # developers. Microsoft has finally acquired the cross-platform mobile development company Xamarin. The amount of the acquisition has not been disclosed. Scot Guthrie, executive vice president of Cloud and Enterprise, said in a blog that Xamarin will unite Visual Studio to provide customers with a wealth of mobile development products, and developers will be able to use C # to develop mobile software and push all the original mobile software to all major mobile platforms.

Since Microsoft formally acquired Xamarin in February 2016 and built Xamarin into VS2015 Update2 (Xamarin was acquired by Microsoft, Xamarin for VS has become all free and open source since May 2016), So the June 2016 release of Xamarin for VS 4.1.0.530 no longer needs to be cracked, no longer need a separate account, the direct installation or upgrade is the Enterprise version.

Third, the Xamarin app Mobile development environment and tools

3.1 工欲善其事, its prerequisite

工欲善其事, its prerequisite is saying: The craftsman wants to make his work well, must first make the tool sharp. It is very important to prepare for a good thing. We do not use vs2015, we do not use the mobile device simulator provided by Microsoft to us, we do not use third-party mobile device simulator such as: Genymotion and so on. Everybody's time is precious, devote the limited time to the infinite work. Here a stupid don't accompany everyone toss, we directly on the real machine really environment on the launch of our Xamarin for Android mobile development tour.

Early Vs2015+xamarin Studio Environment Configuration Tutorial:

C # Mobile cross-platform development (1) Environment readiness

Xamarin.android Introduction: XAMARIN+VS2015 Environment construction

vs2017 Installing Xamarin

3.2. Why choose the visual Studio 2017 universe first IDE tool?

Visual Studio 2017 is the first IDE in the universe, and since Microsoft acquired Xamarin, VS has integrated the Xamarin studio Tools, we can develop mobile application projects on Visual Studio 2015. Now, after upgrading to visual Studio 2017, the mobile development project has been greatly upgraded and perfected, directly to install vs after the development of mobile applications, eliminating the early many cumbersome Java, Android SDK environment installation and configuration work.

So to speak, visual Studio 2017 + is the best choice tool for. NET programmers to develop the Xamarin app mobile app!

3.3. Why do I need a mobile phone with an Android device?

The mobile simulator provided is very slow to start, after all, there are some discrepancies with the real environment, so our application is still deployed in our actual mobile device, the real restoration of the first "live" experience.

3.4. Why do I need to install virtual mirror phone software?

Little Lola Control Machine Master: is a free computer control of mobile phone tools, can help you with the computer through USB or WiFi real-time control of mobile phones, you can use a computer to control the operation of multiple mobile phones, you can record control scripts and so on. The bottom line is that you can monitor our phone screen in real time on your computer.

Four, Xamarin development resources sharing

Android Website: https://developer.android.com/guide/

Xamarin Official website: https://www.xamarin.com/https://developer.xamarin.com/zh-cn/

Focus on Xamarin Open Source community: https://github.com/CSharpCross?page=2

Xamarin MSDN English Document: https://docs.microsoft.com/zh-cn/xamarin/

Xamarin Github:https://github.com/xamarin

Xamarin components:https://github.com/xamarin/xamarincomponents

Xamarin components Five, how to quickly learn and master Xamarin for Android mobile development

Learn Xamarin for Android mobile development, a goofy summed up two points:

1, have a certain C # language basic development knowledge.

As long as you have a certain C # language Foundation, then getting started with Xamarin development will be without pressure.

2, master certain basic principles and knowledge of Android.

The Android interface layout and the use of common controls and the basics of Android must be mastered, and you can learn about video lessons from Java Android, because this piece of Android knowledge is the same, It doesn't have much to do with developing a language.

Tips: Many people feel that writing layout is very annoying, too difficult to write, too many attributes, in fact, the layout of the file is very simple to understand, it as in doing css+div layout on the line, so that understanding will be a great help to our writing layout.

Vi. Xamarin for Android Live instance sharing

6.1. How the BIOS can open virtual technology virtualization Technology

Virtualization Technology (VT), virtualization technology, enabling VT can significantly improve operational performance and efficiency for Android simulators.

The core step is: Enter the BIOS, select the configuration option, select Intel Virtual Technology and enter and select Enabled. The specific method can be Baidu self-search. Http://www.udaxia.com/upqd/5254.html

6.2, Android Phone (charm Blue Note 3) How to open the developer debugging

Note3 How to enter the developer options step:

1, click the Settings button, first enter the settings interface, switch to the full set interface;

2, the sliding interface, enter the "About mobile" option, the sliding interface, find the "version number", in the "version number" of the project column, a continuous click 7 times, will prompt to open the developer options;

3, back to the Setup interface, down to the end, you can see the "developer Options", go to the "developer Options" to open "USB debugging".

6.3. How to quickly get started by using Xamarin to create a mobile Android app.

A goofy will bring the Xamarin for Android small white Quick start with a Hello World app sample.

Get a first look at Android mobile development, learn the basics of Android layout files, Android resource files, Android project structure, and more. The initial arrival experience has a relatively basic understanding and understanding of Android development.

6.4, Android Introduction and SDK, version.

Android Introduction is a free and open source Linux based operating system, mainly used in mobile devices, such as smartphones and tablets, led and developed by Google Inc. and the Open Mobile Alliance. It is also the name of the Linux platform-based open-source mobile operating system (36 photos) announced by Google on November 5, 2007, which consists of the operating system, middleware, user interface and application software.

The Android SDK:SDK (software Development Kit) Software Development Kit is a collection of development tools used by software development engineers to build applications for specific software packages, software frameworks, hardware platforms, operating systems, and more. The Android SDK provides you with the Android API Class library and development tools you need to develop your tests.

Note: The Android SDK uses the Java language, so you need to install the JDK first.

Reference article:

The latest Android system version corresponds to the API level table

Names and updates for each version of Android

SKD version SKD version

6.5, Android ADB common Command Introduction

The Android Debug Bridge (ADB) is a generic command-line tool that allows you to communicate with an emulator instance or a connected Android device. When it comes to the ADB everyone should be not unfamiliar, that is, Android debug Bridge,android Debug Bridge, as the Android development of us, skilled use of the ADB command will greatly enhance our development efficiency, the ADB command a lot, today to summarize the development of some of my commonly used ADB command.

1), after the Android emulation device starts, view the list of Android devices connected to the local computer: ADB devices (focus)

2), view Android version: ADB versions

3), start adb server:adb start-server

4), stop adb server:adb kill-server

5), list the package name of all apps installed on mobile phone: adb shell PM List Packages

6), list all package names for system applications: ADB shell PM List packages-s

7), list the third-party app package name in addition to the system application: ADB shell PM List packages-3

8), install an APK, execute the following command: adb install direct uninstall: ADB Uninstall

9), view adb help: adb

10), reference article: commonly used ADB commands

Thinking: Rage Jumping small Program C # Open program, the implementation is by simulating the ADB to send instructions to the mobile phone to achieve control purposes.

6.6, Android commonly used several permissions (Permission)

Access network Android.permission.INTERNET, access network connection, may generate GPRS traffic

Get network status Android.permission.ACCESS_NETWORK_STATE, get network information status, such as whether the current network connection is valid

Get WiFi status Android.permission.ACCESS_WIFI_STATE, get the status of your current WiFi access and information about Wi-Fi hotspots

Write to external storage Android.permission.WRITE_EXTERNAL_STORAGE, allow programs to write to external storage, such as SD card write file

Update detailed Android permissions can refer to: Android permissions Daquan

6.7. Android Life cycle

The Android system is a multitasking (multi-task) operating system that allows you to listen to music on your phone while performing several other programs. With each application, it consumes more system memory, and when too many programs are executed at the same time, or the closed program does not release the memory correctly, the system will feel slower and even more unstable. To solve this problem, Android introduced a new mechanism, the lifecycle (life cycle).

6.8. Android Four components

Android Four components are activity, service, content provider, broadcast receive, respectively

6.9. Android six layouts (layout)

Six main interface layouts include: linear layout (linearlayout), frame layout (framelayout), table layout (tablelayout), relative layout (relativelayout), Absolute layout (absolutelayout) and Grid layout (GridLayout)

6.10, Android five large storage (Storage)

1. Using Sharedpreferences to store data

2. File storage Data

3, SQLite database storage data (key learning)

4. Using ContentProvider to store data

5. Networked Storage data

6.11. Operation of Android files (file)

Android resources are divided into two, one is the res can be compiled resource file, this resource file system will automatically generate the ID of the resource file in R.java, access is very simple, only need to call R.xxx.id, the second is placed in the assets folder under the native resource file , the files placed under this folder will not be compiled by the R file, so it cannot be used directly as in the first one. Android provides a tool class that allows us to manipulate files under the assets file: Assetmanager

6.12. Intent use of Android learning

A simple numeric value is passed between activity in Xamarin Android

Incoming

Intent it =new Intent (this,typeof (otheractivity));

It. PutExtra ("name", "Kobe")

StartActivity (IT);

Receive

String name = Intent.getstringextra ("Name");

Xamarin transfer multiple values between activity in Android you can use the bundle object as a container, by calling the bundle's put**** first to store the data in the bundle. Then call intent's Putextras method to put the bundle into the intent, call the same reason. This key value is passed in the form of data, case sensitive, attention!

Incoming

Intent it = new Intent (this,typeof (otheractivity));

BUNDLE BD = new bundle ();

Bd. Putboolean ("Isniubi", true);

Bd. Putint ("Id", 123456);

Bd. Putstring ("Name", "James");

It. Putextras (BD);

StartActivity (IT);

Receive

Bundle bd = Intent.extras;

int Id = bd. GetInt ("Id");

String Name = Bd. GetString ("name");

BOOL Niubi = bd. Getboolean ("Niubi");

6.13, Android page jump and Transfer value (Activity)

There are two ways to open a new activity: startactivity () and Startactivityforresult ().

StartActivity Good Understanding, Startactivityforresult () on the trouble, the following picture to facilitate our understanding:

Requestcode, the request code, the arbitrary setting, but must be non-negative. When activity exits, the code returns to Onactivityresult () only if it is a non-negative number.

ResultCode, the result code, is used to identify which new activity the returned data is from, and its value is generally result_canceled, RESULT_OK, Result_first_user.

Startactivityforresult diagram

6.14, the use of Android Learning Broadcast (broadcast)

Broadcasting is a very important way to deliver messages in Android.

The broadcast can be registered statically, or it can be registered dynamically.

Static registration is registered in the Androidmanfiest.xml folder. (Static registration is registered in the Androidmanfiest.xml folder)

Dynamic registration is implemented in code.

Vii. Summary

1, we should have the spirit of network management-restart!. We have to admit that things are not perfect, and while Xamarin is still evolving, there are bugs that are normal, unstable and understandable. I have often encountered vs hang off, connection simulator failure, how can not solve, the code does not follow the normal thinking execution, vs self-flashback, view editor Open failed, compile always fail and so on some problems, after restarting the environment even restart the computer, everything is normal!

2. A follow-up plan will bring you a Xamarin for Adroid app developed in the actual project. At that time, in the "C # Xamarin Mobile development project in real-world" course, a stupid to his actual project experience to share without reservation to everyone. Quickly build an Android app for back-end management systems with Xamarin. If you continue to be interested in, you can follow the study together. Want to know how to funeral, and see tell!

As the saying goes: Master led the door to practice in the individual, I hope everyone in the road of learning has been continued!

Eight, online source view address

C # Xamarin Mobile Development Foundation Learning Chapter

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.