One of my recent projects had an interesting requirement. It was an Android application and it needed to be aware of any businesses that were near the user’s current location. If you have ever used Facebook’s or FourSquare’s “Check-In” feature, it’s very similar. The user had to tap a button, and bring up a list of all business that were near the user. The user would then choose a business (location), and then display the business’s Name, Address, City, State, Latitude, Longitude, etc.
When researching this functionality, I stumbled along the Google Places API. Upon examining the Google Places API, I noticed the PlacePicker widget. This is an out of the box widget that you can display programmatically and it will give you a beautiful Location Picker user interface similar to the Google Maps app for Android.
This meet my requirement, and then some. Not only did it give me a list of businesses that were near my user’s location, it also gave me a material design user interface that my users could interact with. That was an added bonus since I didn’t need to create a UI for this. I could just use the out of the box control and be done with it. To top it off, using the PlacePicker was easy! And on this post, I’m going to show you how to add it to your Xamarin.Android applications.
First Things First
The first thing you need to do before you start writing code is to acquire a Google Maps v2 API Key. If you already have one for your application, then great! Use that one! If not, you’ll have to acquire one. They are free, and there are a number of steps you have to perform in order to get one. Luckily, Xamarin has some detailed documentation on how to get one. So I recommend that you read that.
Next you want to download the latest Android SDK Tools and Google Play Services SDK from the Android Device Manager. I’m not quite sure what minimum versions you’ll need. But if you have a relatively recent version, then it should work. If not, just download the latest versions from the Android SDK Manager. If you need details on how to do that, I discuss this in the video below.
High Level Step By Step
I go into great detail in the video below, but as a reference here is what we’re going to do:
- Acquire a Google Maps v2 API Key.
- Download the latest, or have a relatively later version, of the Android SDK Tools and Google Play Services API.
- Create an instance of PlacePicker.IntentBuilder.
- Use StartActivityFromResult to launch an intent from your Place Picker Intent Builder.
- Override OnActivityResult so that the PlacePicker control can return data back to us.
- Get the Place that the user picked from the PlacePicker.
- Populate our UI from the Place object that the user chose.
That’s pretty much it at a high level. You can download the completed source code on my GitHub page here. Of course, a video is worth a million words! Watch the video and you can see the step by step details how to call the built-in PlacePicker control.
Feel free to leave a comment and let me know what you think!
Oh. My. God. Day 2 of Microsoft Build Conference had some incredible news. Scott Guthrie pulled an Oprah, and officially announced that ALL editions of Visual Studio will be able to use the Xamarin Platform (Xamarin.iOS, Xamarin.Android, Xamarin.Forms) at no extra charge! So that means if you have a license for ANY edition of Visual Studio, include the free Community Edition, you can build iOS, Android, and Windows Phone apps using Xamarin for free! It’s a great day to be a C# developer!
So it’s been almost 10 months since I’ve published an update. And like most people who attempt to blog, I’ve got the same excuses: Life got busy, writing articles where a chore, picked up a few personal projects, etc, etc.
Well now I have a renewed interested in keep up with this blog. But, I don’t want it to be just like any other blog out there. Most, if not all coding blogs tend to be article based. For me that took a lot of effort because I write code better than I write articles. 🙂 So I decided that I’m going to try and stand out and have most of my content video based. I’ll still be writing content, but the written portion of my future articles will be in support of hands on videos and semi-lectures.
I hope this stands out and is interesting to you, as I’ll be more excited to generate content this way. So enough reading, and more watching!
Some of the best ways to become a better software developer, in general, is to listen to other people’s experiences and learn from them. As a consultant, I’ve had the privilege of working with some of the brightest and talented software developers I have ever met. I enjoy working with people who are smarter than me for two reason. First, I learn how to approach problems in different ways I would have never have though of. Second, I can take other peoples experience and retrospectives and add them to my tool belt of knowledge.
So I’ve decided to start a series on this blog, and this is the first post in that series. I’m calling it “Sharing War Stories” and its intention is to take my experiences and share them with the rest of the community. These stories are going to be things that can’t necessarily be found in official documentation. It’s about solving certain issues or problems based on hands-on, real-world experience. In short, the theme for this series is about how things are done in the field that you can’t find anywhere else.
So without further adieu, here is the first article in this series.
In building Xamarin.iOS projects, the main problem is developing the user interfaces. My preferred IDE (most of the time) for developing mobile apps is Visual Studio. However, building user interfaces with Visual Studio has some limitations. Here were my main problems.
First, the Storyboard Designer in Visual Studio, though powerful, still has some limitations (compared to XCode). Bust most importantly, I don’t like to use Storyboards. 🙂 That is another discussion/debate that deserves it’s own blog post. But for the time being, let’s just say that Storyboards are not very cross-platform friendly. And since I’m in the mobile cross-platform business, I’m going to stay away from Storyboards. Instead, I still build user interfaces that are XIB based.
Second, the Xamarin Visual Studio plug-in does not support editing XIB files. Visual Studio will create XIB files, but in a sense if irony, you can’t edit those files using the built-in designer. Xamarin Studio on the Mac doesn’t support XIB files either, but Xamarin Studio will open XCode if you want to modify XIB files and automatically sync the changes back up with Xamarin Studio.
Third, I found it a real pain to copy source code from a Windows machine to a Mac, modify the files, and then copy the files back. And to top it off, nearly all of my clients use Microsoft Team Foundation Server for their source control system. This is the defacto standard for most enterprise environments, or at least the ones I’ve work with. Unfortunately, there is not a nice solution to connect to TFS from a Mac. Xamarin Studio does not support TFS natively on a Mac. One can use the TFS Eclipse Plug-in, which works sometimes. But most of the time, it crashes and is pretty painful to work with. In short, it sucks.
My Requirements For a Better Solution
So in my search for a better solution, I came up with the following requirements:
- I MUST natively support TFS for source control and work item tracking.
- I MUST have the ability to create and edit XIB files for Xamarin.iOS projects.
- I MUST have Resharper like capabilities for developer productivity.
Given those three major requirements, neither Xamarin Studio nor Visual Studio can meet all 3 of those requirements. So the solution I came up with was to use both. But swapping between the two can be painful, especially if your Mac Host and Windows Machine are two different physical machines.
My solution was to use a Mac as my main development machine, and then run a Windows virtual machine (VM) so that I can run Visual Studio. So here is my setup:
- Physical Machine: Macbook Pro w/ 16GB of RAM and Solid State Drive
- Virtual Machine Software: VMWare Fusion
- Windows VM: Windows 8.1 with Visual Studio 2013 installed
I first started typing this up and soon realized that I was about to write a lot of content. It would have made for a long blog post, and felt like I would probably lose your attention. So I decided to try something new and created a video tutorial showing you how to setup your Windows VM using VMWare Fusion, and how to properly host your source code from TFS. So here’s the video:
So in summary, here’s the gist:
- Install VMWare Fusion. You can download the 30-day Trial Version. A new license is only $69.99 USD, but well worth the price.
- Create a Windows 8 Virtual Machine using the VM Wizard. It’s really easy. Install Visual Studio 2013/2015.
- On your Mac File System (not on your Windows File System), choose a location to host your source code.
- In your Window VM Settings, Share the folder location with the Windows VM.
- Open Visual Studio, Create/Map your Workspace to the Shared Folder, and perform a Get Latest Version.
- Swap between Visual Studio and Xamarin Studio with ease while maintaining source control integration!
So that’s my war story! If you have any questions feel free to leave a comment below!
In today’s modern mobile apps it is very common for apps to require a user account in order to function. Apps like Twitter and Instagram require a user account in order to be used. So a very common User Experience is to show a Login Page when the app first starts up. The user should enter in their credentials, and then log into the app. If the user does not have any credentials, the app should offer them the ability to create an account, and then log them in.
Though this seems like a trivial task, it can be somewhat confusing if you are new to building iOS apps using Xamarin.iOS. In this article I’m going to show you an effective way to add a Login Page and a Signup Page to your Xamarin.iOS apps with a great user experience and a neat animation trick.
I learned something new last week that I felt I probably should have learned a long time ago. As I know from my previous experience in Android development, ListViews only scroll vertically. In the past, there was no out of the box support for horizontal ListViews in Android. Developers had to create them manually or use 3rd party libraries hosted on GitHub. If you examined a 3rd parties source code, you would see implementing a horizontal ListView is not an easy task. With the release of Android 4.4 KitKat (API Level 19), a new control was added to the Android SDK. This new control is called a RecyclerView, and is available via the Android Support Library v7.
Luckily for us Xamarin Developers, we have out of the box binding to this library, so we can use this just like native Java developers. In this post I’m going to show you how to implement a vertical ListView (just like a standard ListView), as well as a Horizontal ListView. But we are not going to use the old legacy ListView control or a 3rd party library. We are going to use the now out of the box RecyclerView to implement both. The good news is that the since this is available in the Android Support Library v7, this control can run on devices from the current version of Android, all the way down to API Level 7 (Android 2.1 Eclair). So this control remains backwards compatible with almost any device out there. So let’s get coding!
If you’re new to iOS development, whether you are using Xamarin, native, or another platform, you will want to debug and develop on an actual iOS device. In addition, you probably want to deploy alpha or beta versions of your app to testers running on various iOS devices in real world scenarios. If you’re developing for Android, this process is really easy as the Android operating system allows users to easily side load applications. However, the opposite is true for iOS devices. In fact, setting up an iPhone or iPad for development can be very frustrating and confusing, especially if you’re new to iOS development.
Debugging my app on an iPhone or iPad should be easy…right??
Xamarin and Apple both have excellent documentation on how to properly provision an iOS device for debugging, and testing. Though it is really easy to follow the step-by-step procedures on creating the proper provisioning profiles, what I find lacking in such documentation is how provisioning works. In this article, I’m not going to explain how to create provision profiles. There’s plenty of documentation out there. I’m going to explain how provisioning profiles work, and why the iOS operating system needs them. A solid understanding is necessary if you run into any issues or errors such as “No valid iOS code signing keys found in keychain”, or “Code Sign error: Provisioning Profile ‘xxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx’ can’t be found”.
In my first publish post I gave a very high level overview of what Xamarin is and what it isn’t. I then followed up with a post describing the nuts & bolts of Xamarin.iOS. In this article, I’ll be describing the nuts & bolts of Xamarin.Android. And as I started in my previous two posts, I think it is essential to understand what Xamarin.Android is, how it is compiled, and how it executes on your Android device. Though it is easy to jump right in and start coding, I believe it is essential to understand Xamarin.Android fundamentals, as well as the Android operating system fundamentals. In the long run, this will be beneficial when you have to start debugging your apps. It will also help you troubleshoot issues an understand what is happening between the Android operating system, Xamarin.Android, and your own code.
In the earlier days of Xamarin.iOS development (up to iOS 7), one of the more useful recipes from the Xamarin Documentation was the ActionSheet Date Picker. Adding a DatePicker as a subview of a
UIActionSheet was a very convenient way to display a DatePicker to the user. The Action Sheet would behave as it usually would, and you could modify it to slide from the bottom and only take up the bottom portion of the screen. After the user selects the date and taps on “Done”, the ActionSheet would then slide back down. Because of the behavior of the ActionSheet, this was a great way to provide a Modal Date Picker. However, this recipe no longer works on iOS 8 due to “misuse” of the
UIActionSheet. I created an alternative, with full source code and sample app that replaces the ActionSheet Date Picker that is free to use.
In my previous post I gave a very high level overview of what Xamarin is and what Xamarin is not. Though my post was more conversational and explained by example, I left out the technical details. In this post, I’m going to focus on the nuts & bolts of Xamarin.iOS. But before we start off coding a sample application, it is (in my opinion) essential to understand what Xamarin.iOS is, how it is compiled, and how it executes on your iOS device. Though it is easy to jump right in and start coding, I believe it is essential to understand the Xamarin.iOS fundamentals, as well as the iOS operating system fundamentals. In the long run, this will be beneficial when you have to start debugging your apps. It will also help you troubleshoot issues and understand what is happening between the iOS operating system, Xamarin.iOS, and your own code.