SlideShare a Scribd company logo
1
Developed your First Xamarin.Forms App
Prepared by Eng Soon Cheah, Microsoft MVP
Objective
Build your first mobile app for iOS,Android, and Windows with Xamarin.Forms
Requirements
1. Install Visual Studio 2015 Enterprise
2. Install Visual Studio Emulator for Android
3. Install Windows Standalone SDK for Windows 10 & Enable Developer Mode
4. Install Android SDK Manager for Tools and Extras
2
Content
Chapter 1: Create Your First Porject
Chapter 2: Layout & Control & Event Handler
Chapter 3: Plugin
Chapter 4: Integrate with HockeyApp
References
Chapter 1: Create Your First Project
1. Open your Visual Studio 2015/ Visual Studio Enterprise.
2. Go to File > New > Project
3
3. Select “Cross-Platform” > Select “ Blank App ( Xamarin.Forms Portable) “& Name
Your Project (App Name)
4. Your Xamarin.Forms App Solutions Successful Created.
4
* If you use Windows 10 & install Windows 10 SDK, You will saw the Universal Windows
Platform (UWP) App.
5. Select the Solution “FirstApp(Portable)”
6. Right- Click the Solution “FirstApp(Portable)” > Select “Add” > Select “New Item”
5
7. Select “Cross-Platform” > Select “Forms Xaml Page” > Name the Page
“HomePage.xaml”
8. Go to “FirstApp (Portable)” > Select “App.cs”
6
9. Highlight and Remove the Source Code in App()
7
10. And Replace with “MainPage = new HomePage();”
8
Chapter 2: Layout and Control
1. Go to “HomePage.xaml” add Layout and Control
2. Add Image to each Platform (iOS,Android,Windows/UWP)
• iOS – Add Image to “ Resources” Folder , Build Action: BundleResource in Properties
Tab.
• Android – Add Image to “Resources/drawable” Folder , Build
Action:AndroidResource.
• Windows /UWP – Place images in root directory , Build Action: Content.
Download the image and MP3 file from:
https://github.com/cheahengsoon/FirstXamarinFormsApp
9
Android Platform
iOS Platform
10
Windows Platform
Result:
Layout Done. But still not had any event or functions.
11
3. Add Event handler to the Entry for PhoneNumber.
And
Go to HomePage.xaml.cs , add the C# Code
12
4. Play Audio for Alarm
1. Right Click “FirstApp(Portable)” Solution, select “Add”, and “New item”.
2. Select “Interface” and name the class as “IAudio.cs”
13
3. “IAudio.cs” Success created, And Insert this line of code as below.
void PlayAudioFile(string filename);
4. Go to “HomePage.xaml” add event handler for “btnalarm”
<Button x:Name="btnalarm" Grid.Row="1" Grid.Column="1" Text="Alarm" Image="alarm.png"
Clicked="OnAlertYesNoClicked" />
And
Add the backend function to play the alarm sound.
5. Now add the “policeSiren.mp3” to iOS & Android.
**iOS: file should be added to the Resources folder
**Android: file should be added to the Assets folder
14
For Android
==========
Go to “FirstApp.Droid”, Select “Assets” folder and select “Add” and “Existing item”. Add
“policesiren.mp3”
For iOS
Go to “FirstApp.iOS”, Select “Resources” folder, select “Add” and “Existing Item”. Add
“policesiren.mp3”
15
6. Add class “AudioService.cs” to FirstApp.Droid.
16
And add the Code to “AudioServices.cs”
7. In iOS still same steps with Android add the “AudioServices.cs”
17
And Add the code to “AudioServices.cs”
UWP/Windows/Windows Phone 8.1
==========================
Temporary unavailable
18
Chapter 3: Plugin
Geolocator Plugin
1. Go to Tools > Nuget Package Manager > Package Manager Console.
2. Key In the Command & Enter for installation of Library.
Install-Package Xam.Plugin.Geolocator -Version 3.0.4
19
3. Go to HomePage.xaml.cs add the Function for retrieve the location details
GetGPS(); at Below InitializeComponent();
And Enter the Code Below
private async void GetGPS()
{
try
{
var locator = CrossGeolocator.Current;
locator.DesiredAccuracy = 1000;
lbllocation.Text = "Getting gps";
var position = await locator.GetPositionAsync(timeoutMilliseconds: 10000);
if (position == null)
{
lbllocation.Text = "null gps :(";
return;
}
lbllocation.Text = string.Format("Time: {0} nLat: {1} nLong: {2}"+
" nAltitude: {3} nAltitude Accuracy: {4} nAccuracy: {5} nHeading: {6} nSpeed:
{7}",
position.Timestamp, position.Latitude, position.Longitude,
position.Altitude, position.AltitudeAccuracy, position.Accuracy, position.Heading,
position.Speed);
}
catch //(Exception ex)
{
// Xamarin.Insights.Report(ex);
// await DisplayAlert("Uh oh", "Something went wrong, but don't worry we captured it
in Xamarin Insights! Thanks.", "OK");
}
}
20
protected override void OnAppearing()
{
base.OnAppearing();
try
{
CrossGeolocator.Current.PositionChanged +=
CrossGeolocator_Current_PositionChanged;
CrossGeolocator.Current.PositionError += CrossGeolocator_Current_PositionError;
}
catch
{
}
}
void CrossGeolocator_Current_PositionError(object sender,
Plugin.Geolocator.Abstractions.PositionErrorEventArgs e)
{
lbllocation.Text = "Location error: " + e.Error.ToString();
}
void CrossGeolocator_Current_PositionChanged(object sender,
Plugin.Geolocator.Abstractions.PositionEventArgs e)
{
var position = e.Position;
lbllocation.Text = string.Format("Time: {0} nLat: {1} nLong: {2} nAltitude: "
+"{3} nAltitude Accuracy: {4} nAccuracy: {5} nHeading: {6} nSpeed: {7}",
position.Timestamp, position.Latitude, position.Longitude,
position.Altitude, position.AltitudeAccuracy, position.Accuracy, position.Heading,
position.Speed);
}
protected override void OnDisappearing()
{
base.OnDisappearing();
try
{
CrossGeolocator.Current.PositionChanged -=
CrossGeolocator_Current_PositionChanged;
CrossGeolocator.Current.PositionError -= CrossGeolocator_Current_PositionError;
}
catch
21
{
}
}
4. Go to FirstApp.Droid , Right Click > Select Properties
5. Go to Android Manifest Enable Location Permission
22
For Windows Phone/Windows/UWP
Go to “Package.appxmanifest” to Enable Location Services
23
SMS & Call Plugin
1. Go to Tools > Nuget Package Manager > Package Manager Console.
2. Enter the Command & Enter for installation of Library.
Install-Package Xam.Plugins.Messaging
24
3. Go to HomePage.xaml create an event handler for Call & SMS Function
4. Go to HomePage.xaml.cs add the Backend Code.
5. Enable the CALL_PHONE and SEND_SMS in Android Manifest . For
WindowsPhone/UWP enable ID_CAP_PHONEDAILER
25
CHAPTER 4: Integrate with HockeyApp
1. Go to https://hockeyapp.net/
2. Sign Up with your Microsoft Account
3. Create a New App and Select “manually”
4. Fill in the Details & Save.
26
5. Go to Project > Manage NuGet Packages …. And Search HockeySDK.Xamarin
27
For Android
Open MainActivity.cs
Replace “$Your_App_Id” That you can get in Hockey App.
28
For iOS
1. Open AppDelegate.cs and add this new line of code.
For UWP
https://www.hockeyapp.net/blog/2016/10/18/the-latest-on-hockeysdk-for-uwp.html
29
References:
Microsoft Virtual Academy
https://mva.microsoft.com/en-US/training-courses/xamarin-for-absolute-beginners-16182
Xamarin Malaysia Developers
https://www.facebook.com/groups/xamarinmydev/
HockeyApp
https://hockeyapp.net/
Source Code

More Related Content

Similar to Developed your first Xamarin.Forms Application

DotNet Cologne 2015 - Windows 10 AppDev, Teil2: Coole APIs - (Daniel Meixner)
DotNet Cologne 2015 - Windows 10 AppDev, Teil2: Coole APIs - (Daniel Meixner)DotNet Cologne 2015 - Windows 10 AppDev, Teil2: Coole APIs - (Daniel Meixner)
DotNet Cologne 2015 - Windows 10 AppDev, Teil2: Coole APIs - (Daniel Meixner)
Daniel Meixner
 
Web versus Native: round 1!
Web versus Native: round 1!Web versus Native: round 1!
Web versus Native: round 1!
Chris Mills
 
WebAPIs & Apps - Mozilla London
WebAPIs & Apps - Mozilla LondonWebAPIs & Apps - Mozilla London
WebAPIs & Apps - Mozilla London
Robert Nyman
 
Bringing the open web and APIs to mobile devices with Firefox OS - Whisky W...
 	Bringing the open web and APIs to mobile devices with Firefox OS - Whisky W... 	Bringing the open web and APIs to mobile devices with Firefox OS - Whisky W...
Bringing the open web and APIs to mobile devices with Firefox OS - Whisky W...
Robert Nyman
 
Combining the Security Risks of Native and Web Development: Hybrid Apps
Combining the Security Risks of Native and Web Development: Hybrid AppsCombining the Security Risks of Native and Web Development: Hybrid Apps
Combining the Security Risks of Native and Web Development: Hybrid Apps
Achim D. Brucker
 
20150812 4시간만에 따라해보는 windows 10 앱 개발
20150812  4시간만에 따라해보는 windows 10 앱 개발20150812  4시간만에 따라해보는 windows 10 앱 개발
20150812 4시간만에 따라해보는 windows 10 앱 개발
영욱 김
 
Slide Deck - Shift Left Beyond App Performance Improvement at Gojek_.pptx
Slide Deck - Shift Left Beyond App Performance Improvement at Gojek_.pptxSlide Deck - Shift Left Beyond App Performance Improvement at Gojek_.pptx
Slide Deck - Shift Left Beyond App Performance Improvement at Gojek_.pptx
raditya gumay
 
MAF push notifications
MAF push notificationsMAF push notifications
MAF push notifications
Luc Bors
 
Non Conventional Android Programming En
Non Conventional Android Programming EnNon Conventional Android Programming En
Non Conventional Android Programming En
guest9bcef2f
 
Non Conventional Android Programming (English)
Non Conventional Android Programming (English)Non Conventional Android Programming (English)
Non Conventional Android Programming (English)
Davide Cerbo
 
How React Native, Appium and me made each other shine @ContinuousDeliveryAmst...
How React Native, Appium and me made each other shine @ContinuousDeliveryAmst...How React Native, Appium and me made each other shine @ContinuousDeliveryAmst...
How React Native, Appium and me made each other shine @ContinuousDeliveryAmst...
Wim Selles
 
Developing for android wear
Developing for android wearDeveloping for android wear
Developing for android wear
Thomas Oldervoll
 
JavaScript APIs - The Web is the Platform
JavaScript APIs - The Web is the PlatformJavaScript APIs - The Web is the Platform
JavaScript APIs - The Web is the Platform
Robert Nyman
 
Web APIs & Apps - Mozilla
Web APIs & Apps - MozillaWeb APIs & Apps - Mozilla
Web APIs & Apps - Mozilla
Robert Nyman
 
Lightning Talk - Xamarin
Lightning Talk - Xamarin Lightning Talk - Xamarin
Lightning Talk - Xamarin
Deivison Sporteman
 
Appium troubleshooting
Appium troubleshootingAppium troubleshooting
Appium troubleshooting
adi ben aroya
 
Cómo tener analíticas en tu app y no volverte loco
Cómo tener analíticas en tu app y no volverte locoCómo tener analíticas en tu app y no volverte loco
Cómo tener analíticas en tu app y no volverte loco
Gemma Del Olmo
 
GDG GeorgeTown Devfest 2014 Presentation: Android Wear: A Developer's Perspec...
GDG GeorgeTown Devfest 2014 Presentation: Android Wear: A Developer's Perspec...GDG GeorgeTown Devfest 2014 Presentation: Android Wear: A Developer's Perspec...
GDG GeorgeTown Devfest 2014 Presentation: Android Wear: A Developer's Perspec...
mharkus
 
Empowering the “Mobile Web” with Chris Mills
Empowering the “Mobile Web” with Chris MillsEmpowering the “Mobile Web” with Chris Mills
Empowering the “Mobile Web” with Chris Mills
FITC
 
Empowering the Mobile Web - Mills
Empowering the Mobile Web - MillsEmpowering the Mobile Web - Mills
Empowering the Mobile Web - Mills
Codemotion
 

Similar to Developed your first Xamarin.Forms Application (20)

DotNet Cologne 2015 - Windows 10 AppDev, Teil2: Coole APIs - (Daniel Meixner)
DotNet Cologne 2015 - Windows 10 AppDev, Teil2: Coole APIs - (Daniel Meixner)DotNet Cologne 2015 - Windows 10 AppDev, Teil2: Coole APIs - (Daniel Meixner)
DotNet Cologne 2015 - Windows 10 AppDev, Teil2: Coole APIs - (Daniel Meixner)
 
Web versus Native: round 1!
Web versus Native: round 1!Web versus Native: round 1!
Web versus Native: round 1!
 
WebAPIs & Apps - Mozilla London
WebAPIs & Apps - Mozilla LondonWebAPIs & Apps - Mozilla London
WebAPIs & Apps - Mozilla London
 
Bringing the open web and APIs to mobile devices with Firefox OS - Whisky W...
 	Bringing the open web and APIs to mobile devices with Firefox OS - Whisky W... 	Bringing the open web and APIs to mobile devices with Firefox OS - Whisky W...
Bringing the open web and APIs to mobile devices with Firefox OS - Whisky W...
 
Combining the Security Risks of Native and Web Development: Hybrid Apps
Combining the Security Risks of Native and Web Development: Hybrid AppsCombining the Security Risks of Native and Web Development: Hybrid Apps
Combining the Security Risks of Native and Web Development: Hybrid Apps
 
20150812 4시간만에 따라해보는 windows 10 앱 개발
20150812  4시간만에 따라해보는 windows 10 앱 개발20150812  4시간만에 따라해보는 windows 10 앱 개발
20150812 4시간만에 따라해보는 windows 10 앱 개발
 
Slide Deck - Shift Left Beyond App Performance Improvement at Gojek_.pptx
Slide Deck - Shift Left Beyond App Performance Improvement at Gojek_.pptxSlide Deck - Shift Left Beyond App Performance Improvement at Gojek_.pptx
Slide Deck - Shift Left Beyond App Performance Improvement at Gojek_.pptx
 
MAF push notifications
MAF push notificationsMAF push notifications
MAF push notifications
 
Non Conventional Android Programming En
Non Conventional Android Programming EnNon Conventional Android Programming En
Non Conventional Android Programming En
 
Non Conventional Android Programming (English)
Non Conventional Android Programming (English)Non Conventional Android Programming (English)
Non Conventional Android Programming (English)
 
How React Native, Appium and me made each other shine @ContinuousDeliveryAmst...
How React Native, Appium and me made each other shine @ContinuousDeliveryAmst...How React Native, Appium and me made each other shine @ContinuousDeliveryAmst...
How React Native, Appium and me made each other shine @ContinuousDeliveryAmst...
 
Developing for android wear
Developing for android wearDeveloping for android wear
Developing for android wear
 
JavaScript APIs - The Web is the Platform
JavaScript APIs - The Web is the PlatformJavaScript APIs - The Web is the Platform
JavaScript APIs - The Web is the Platform
 
Web APIs & Apps - Mozilla
Web APIs & Apps - MozillaWeb APIs & Apps - Mozilla
Web APIs & Apps - Mozilla
 
Lightning Talk - Xamarin
Lightning Talk - Xamarin Lightning Talk - Xamarin
Lightning Talk - Xamarin
 
Appium troubleshooting
Appium troubleshootingAppium troubleshooting
Appium troubleshooting
 
Cómo tener analíticas en tu app y no volverte loco
Cómo tener analíticas en tu app y no volverte locoCómo tener analíticas en tu app y no volverte loco
Cómo tener analíticas en tu app y no volverte loco
 
GDG GeorgeTown Devfest 2014 Presentation: Android Wear: A Developer's Perspec...
GDG GeorgeTown Devfest 2014 Presentation: Android Wear: A Developer's Perspec...GDG GeorgeTown Devfest 2014 Presentation: Android Wear: A Developer's Perspec...
GDG GeorgeTown Devfest 2014 Presentation: Android Wear: A Developer's Perspec...
 
Empowering the “Mobile Web” with Chris Mills
Empowering the “Mobile Web” with Chris MillsEmpowering the “Mobile Web” with Chris Mills
Empowering the “Mobile Web” with Chris Mills
 
Empowering the Mobile Web - Mills
Empowering the Mobile Web - MillsEmpowering the Mobile Web - Mills
Empowering the Mobile Web - Mills
 

More from Cheah Eng Soon

Microsoft Defender for Endpoint
Microsoft Defender for EndpointMicrosoft Defender for Endpoint
Microsoft Defender for Endpoint
Cheah Eng Soon
 
Azure Active Directory - Secure and Govern
Azure Active Directory - Secure and GovernAzure Active Directory - Secure and Govern
Azure Active Directory - Secure and Govern
Cheah Eng Soon
 
Microsoft Zero Trust
Microsoft Zero TrustMicrosoft Zero Trust
Microsoft Zero Trust
Cheah Eng Soon
 
MEM for OnPrem Environments
MEM for OnPrem EnvironmentsMEM for OnPrem Environments
MEM for OnPrem Environments
Cheah Eng Soon
 
Microsoft Threat Protection Automated Incident Response
Microsoft Threat Protection Automated Incident Response Microsoft Threat Protection Automated Incident Response
Microsoft Threat Protection Automated Incident Response
Cheah Eng Soon
 
Azure Penetration Testing
Azure Penetration TestingAzure Penetration Testing
Azure Penetration Testing
Cheah Eng Soon
 
Azure Penetration Testing
Azure Penetration TestingAzure Penetration Testing
Azure Penetration Testing
Cheah Eng Soon
 
Penetration Testing Azure for Ethical Hackers
Penetration Testing Azure for Ethical HackersPenetration Testing Azure for Ethical Hackers
Penetration Testing Azure for Ethical Hackers
Cheah Eng Soon
 
Microsoft Threat Protection Automated Incident Response Demo
Microsoft Threat Protection Automated Incident Response DemoMicrosoft Threat Protection Automated Incident Response Demo
Microsoft Threat Protection Automated Incident Response Demo
Cheah Eng Soon
 
Microsoft Secure Score Demo
Microsoft Secure Score DemoMicrosoft Secure Score Demo
Microsoft Secure Score Demo
Cheah Eng Soon
 
Microsoft Cloud App Security Demo
Microsoft Cloud App Security DemoMicrosoft Cloud App Security Demo
Microsoft Cloud App Security Demo
Cheah Eng Soon
 
M365 Attack Simulation Demo
M365 Attack Simulation DemoM365 Attack Simulation Demo
M365 Attack Simulation Demo
Cheah Eng Soon
 
Cloud Security Demo
Cloud Security DemoCloud Security Demo
Cloud Security Demo
Cheah Eng Soon
 
Azure Active Directory - External Identities Demo
Azure Active Directory - External Identities Demo Azure Active Directory - External Identities Demo
Azure Active Directory - External Identities Demo
Cheah Eng Soon
 
Azure WAF
Azure WAFAzure WAF
Azure WAF
Cheah Eng Soon
 
Azure Weekend 2020 Build Malaysia Bus Uncle Chatbot
Azure Weekend 2020 Build Malaysia Bus Uncle ChatbotAzure Weekend 2020 Build Malaysia Bus Uncle Chatbot
Azure Weekend 2020 Build Malaysia Bus Uncle Chatbot
Cheah Eng Soon
 
Microsoft Azure的20大常见安全漏洞与配置错误
Microsoft Azure的20大常见安全漏洞与配置错误Microsoft Azure的20大常见安全漏洞与配置错误
Microsoft Azure的20大常见安全漏洞与配置错误
Cheah Eng Soon
 
20 common security vulnerabilities and misconfiguration in Azure
20 common security vulnerabilities and misconfiguration in Azure20 common security vulnerabilities and misconfiguration in Azure
20 common security vulnerabilities and misconfiguration in Azure
Cheah Eng Soon
 
Integrate Microsoft Graph with Azure Bot Services
Integrate Microsoft Graph with Azure Bot ServicesIntegrate Microsoft Graph with Azure Bot Services
Integrate Microsoft Graph with Azure Bot Services
Cheah Eng Soon
 
Azure Sentinel with Office 365
Azure Sentinel with Office 365Azure Sentinel with Office 365
Azure Sentinel with Office 365
Cheah Eng Soon
 

More from Cheah Eng Soon (20)

Microsoft Defender for Endpoint
Microsoft Defender for EndpointMicrosoft Defender for Endpoint
Microsoft Defender for Endpoint
 
Azure Active Directory - Secure and Govern
Azure Active Directory - Secure and GovernAzure Active Directory - Secure and Govern
Azure Active Directory - Secure and Govern
 
Microsoft Zero Trust
Microsoft Zero TrustMicrosoft Zero Trust
Microsoft Zero Trust
 
MEM for OnPrem Environments
MEM for OnPrem EnvironmentsMEM for OnPrem Environments
MEM for OnPrem Environments
 
Microsoft Threat Protection Automated Incident Response
Microsoft Threat Protection Automated Incident Response Microsoft Threat Protection Automated Incident Response
Microsoft Threat Protection Automated Incident Response
 
Azure Penetration Testing
Azure Penetration TestingAzure Penetration Testing
Azure Penetration Testing
 
Azure Penetration Testing
Azure Penetration TestingAzure Penetration Testing
Azure Penetration Testing
 
Penetration Testing Azure for Ethical Hackers
Penetration Testing Azure for Ethical HackersPenetration Testing Azure for Ethical Hackers
Penetration Testing Azure for Ethical Hackers
 
Microsoft Threat Protection Automated Incident Response Demo
Microsoft Threat Protection Automated Incident Response DemoMicrosoft Threat Protection Automated Incident Response Demo
Microsoft Threat Protection Automated Incident Response Demo
 
Microsoft Secure Score Demo
Microsoft Secure Score DemoMicrosoft Secure Score Demo
Microsoft Secure Score Demo
 
Microsoft Cloud App Security Demo
Microsoft Cloud App Security DemoMicrosoft Cloud App Security Demo
Microsoft Cloud App Security Demo
 
M365 Attack Simulation Demo
M365 Attack Simulation DemoM365 Attack Simulation Demo
M365 Attack Simulation Demo
 
Cloud Security Demo
Cloud Security DemoCloud Security Demo
Cloud Security Demo
 
Azure Active Directory - External Identities Demo
Azure Active Directory - External Identities Demo Azure Active Directory - External Identities Demo
Azure Active Directory - External Identities Demo
 
Azure WAF
Azure WAFAzure WAF
Azure WAF
 
Azure Weekend 2020 Build Malaysia Bus Uncle Chatbot
Azure Weekend 2020 Build Malaysia Bus Uncle ChatbotAzure Weekend 2020 Build Malaysia Bus Uncle Chatbot
Azure Weekend 2020 Build Malaysia Bus Uncle Chatbot
 
Microsoft Azure的20大常见安全漏洞与配置错误
Microsoft Azure的20大常见安全漏洞与配置错误Microsoft Azure的20大常见安全漏洞与配置错误
Microsoft Azure的20大常见安全漏洞与配置错误
 
20 common security vulnerabilities and misconfiguration in Azure
20 common security vulnerabilities and misconfiguration in Azure20 common security vulnerabilities and misconfiguration in Azure
20 common security vulnerabilities and misconfiguration in Azure
 
Integrate Microsoft Graph with Azure Bot Services
Integrate Microsoft Graph with Azure Bot ServicesIntegrate Microsoft Graph with Azure Bot Services
Integrate Microsoft Graph with Azure Bot Services
 
Azure Sentinel with Office 365
Azure Sentinel with Office 365Azure Sentinel with Office 365
Azure Sentinel with Office 365
 

Recently uploaded

Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
saastr
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
danishmna97
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
panagenda
 
Skybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoptionSkybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoption
Tatiana Kojar
 
Best 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERPBest 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERP
Pixlogix Infotech
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Malak Abu Hammad
 
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing InstancesEnergy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
Alpen-Adria-Universität
 
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Speck&Tech
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
tolgahangng
 
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
Edge AI and Vision Alliance
 
Choosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptxChoosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptx
Brandon Minnick, MBA
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Safe Software
 
Nordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptxNordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptx
MichaelKnudsen27
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
Zilliz
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
panagenda
 
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial IntelligenceAI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
IndexBug
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
Matthew Sinclair
 
Generating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and MilvusGenerating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and Milvus
Zilliz
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
Matthew Sinclair
 
GenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizationsGenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizations
kumardaparthi1024
 

Recently uploaded (20)

Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
 
Skybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoptionSkybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoption
 
Best 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERPBest 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERP
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
 
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing InstancesEnergy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
 
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
 
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
 
Choosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptxChoosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptx
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
 
Nordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptxNordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptx
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
 
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial IntelligenceAI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
 
Generating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and MilvusGenerating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and Milvus
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
 
GenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizationsGenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizations
 

Developed your first Xamarin.Forms Application

  • 1. 1 Developed your First Xamarin.Forms App Prepared by Eng Soon Cheah, Microsoft MVP Objective Build your first mobile app for iOS,Android, and Windows with Xamarin.Forms Requirements 1. Install Visual Studio 2015 Enterprise 2. Install Visual Studio Emulator for Android 3. Install Windows Standalone SDK for Windows 10 & Enable Developer Mode 4. Install Android SDK Manager for Tools and Extras
  • 2. 2 Content Chapter 1: Create Your First Porject Chapter 2: Layout & Control & Event Handler Chapter 3: Plugin Chapter 4: Integrate with HockeyApp References Chapter 1: Create Your First Project 1. Open your Visual Studio 2015/ Visual Studio Enterprise. 2. Go to File > New > Project
  • 3. 3 3. Select “Cross-Platform” > Select “ Blank App ( Xamarin.Forms Portable) “& Name Your Project (App Name) 4. Your Xamarin.Forms App Solutions Successful Created.
  • 4. 4 * If you use Windows 10 & install Windows 10 SDK, You will saw the Universal Windows Platform (UWP) App. 5. Select the Solution “FirstApp(Portable)” 6. Right- Click the Solution “FirstApp(Portable)” > Select “Add” > Select “New Item”
  • 5. 5 7. Select “Cross-Platform” > Select “Forms Xaml Page” > Name the Page “HomePage.xaml” 8. Go to “FirstApp (Portable)” > Select “App.cs”
  • 6. 6 9. Highlight and Remove the Source Code in App()
  • 7. 7 10. And Replace with “MainPage = new HomePage();”
  • 8. 8 Chapter 2: Layout and Control 1. Go to “HomePage.xaml” add Layout and Control 2. Add Image to each Platform (iOS,Android,Windows/UWP) • iOS – Add Image to “ Resources” Folder , Build Action: BundleResource in Properties Tab. • Android – Add Image to “Resources/drawable” Folder , Build Action:AndroidResource. • Windows /UWP – Place images in root directory , Build Action: Content. Download the image and MP3 file from: https://github.com/cheahengsoon/FirstXamarinFormsApp
  • 10. 10 Windows Platform Result: Layout Done. But still not had any event or functions.
  • 11. 11 3. Add Event handler to the Entry for PhoneNumber. And Go to HomePage.xaml.cs , add the C# Code
  • 12. 12 4. Play Audio for Alarm 1. Right Click “FirstApp(Portable)” Solution, select “Add”, and “New item”. 2. Select “Interface” and name the class as “IAudio.cs”
  • 13. 13 3. “IAudio.cs” Success created, And Insert this line of code as below. void PlayAudioFile(string filename); 4. Go to “HomePage.xaml” add event handler for “btnalarm” <Button x:Name="btnalarm" Grid.Row="1" Grid.Column="1" Text="Alarm" Image="alarm.png" Clicked="OnAlertYesNoClicked" /> And Add the backend function to play the alarm sound. 5. Now add the “policeSiren.mp3” to iOS & Android. **iOS: file should be added to the Resources folder **Android: file should be added to the Assets folder
  • 14. 14 For Android ========== Go to “FirstApp.Droid”, Select “Assets” folder and select “Add” and “Existing item”. Add “policesiren.mp3” For iOS Go to “FirstApp.iOS”, Select “Resources” folder, select “Add” and “Existing Item”. Add “policesiren.mp3”
  • 15. 15 6. Add class “AudioService.cs” to FirstApp.Droid.
  • 16. 16 And add the Code to “AudioServices.cs” 7. In iOS still same steps with Android add the “AudioServices.cs”
  • 17. 17 And Add the code to “AudioServices.cs” UWP/Windows/Windows Phone 8.1 ========================== Temporary unavailable
  • 18. 18 Chapter 3: Plugin Geolocator Plugin 1. Go to Tools > Nuget Package Manager > Package Manager Console. 2. Key In the Command & Enter for installation of Library. Install-Package Xam.Plugin.Geolocator -Version 3.0.4
  • 19. 19 3. Go to HomePage.xaml.cs add the Function for retrieve the location details GetGPS(); at Below InitializeComponent(); And Enter the Code Below private async void GetGPS() { try { var locator = CrossGeolocator.Current; locator.DesiredAccuracy = 1000; lbllocation.Text = "Getting gps"; var position = await locator.GetPositionAsync(timeoutMilliseconds: 10000); if (position == null) { lbllocation.Text = "null gps :("; return; } lbllocation.Text = string.Format("Time: {0} nLat: {1} nLong: {2}"+ " nAltitude: {3} nAltitude Accuracy: {4} nAccuracy: {5} nHeading: {6} nSpeed: {7}", position.Timestamp, position.Latitude, position.Longitude, position.Altitude, position.AltitudeAccuracy, position.Accuracy, position.Heading, position.Speed); } catch //(Exception ex) { // Xamarin.Insights.Report(ex); // await DisplayAlert("Uh oh", "Something went wrong, but don't worry we captured it in Xamarin Insights! Thanks.", "OK"); } }
  • 20. 20 protected override void OnAppearing() { base.OnAppearing(); try { CrossGeolocator.Current.PositionChanged += CrossGeolocator_Current_PositionChanged; CrossGeolocator.Current.PositionError += CrossGeolocator_Current_PositionError; } catch { } } void CrossGeolocator_Current_PositionError(object sender, Plugin.Geolocator.Abstractions.PositionErrorEventArgs e) { lbllocation.Text = "Location error: " + e.Error.ToString(); } void CrossGeolocator_Current_PositionChanged(object sender, Plugin.Geolocator.Abstractions.PositionEventArgs e) { var position = e.Position; lbllocation.Text = string.Format("Time: {0} nLat: {1} nLong: {2} nAltitude: " +"{3} nAltitude Accuracy: {4} nAccuracy: {5} nHeading: {6} nSpeed: {7}", position.Timestamp, position.Latitude, position.Longitude, position.Altitude, position.AltitudeAccuracy, position.Accuracy, position.Heading, position.Speed); } protected override void OnDisappearing() { base.OnDisappearing(); try { CrossGeolocator.Current.PositionChanged -= CrossGeolocator_Current_PositionChanged; CrossGeolocator.Current.PositionError -= CrossGeolocator_Current_PositionError; } catch
  • 21. 21 { } } 4. Go to FirstApp.Droid , Right Click > Select Properties 5. Go to Android Manifest Enable Location Permission
  • 22. 22 For Windows Phone/Windows/UWP Go to “Package.appxmanifest” to Enable Location Services
  • 23. 23 SMS & Call Plugin 1. Go to Tools > Nuget Package Manager > Package Manager Console. 2. Enter the Command & Enter for installation of Library. Install-Package Xam.Plugins.Messaging
  • 24. 24 3. Go to HomePage.xaml create an event handler for Call & SMS Function 4. Go to HomePage.xaml.cs add the Backend Code. 5. Enable the CALL_PHONE and SEND_SMS in Android Manifest . For WindowsPhone/UWP enable ID_CAP_PHONEDAILER
  • 25. 25 CHAPTER 4: Integrate with HockeyApp 1. Go to https://hockeyapp.net/ 2. Sign Up with your Microsoft Account 3. Create a New App and Select “manually” 4. Fill in the Details & Save.
  • 26. 26 5. Go to Project > Manage NuGet Packages …. And Search HockeySDK.Xamarin
  • 27. 27 For Android Open MainActivity.cs Replace “$Your_App_Id” That you can get in Hockey App.
  • 28. 28 For iOS 1. Open AppDelegate.cs and add this new line of code. For UWP https://www.hockeyapp.net/blog/2016/10/18/the-latest-on-hockeysdk-for-uwp.html
  • 29. 29 References: Microsoft Virtual Academy https://mva.microsoft.com/en-US/training-courses/xamarin-for-absolute-beginners-16182 Xamarin Malaysia Developers https://www.facebook.com/groups/xamarinmydev/ HockeyApp https://hockeyapp.net/ Source Code