Archive for August, 2015

Detect in Xamarin.Forms if the app is running in simulator or on real device

Sometimes you need to detect if you are using simulator (emulator) or real device, typical example can be the situation when you are running the webservices used by your application on the same computer where you are running simulator and you would like quickly check how it is working altogether.

There are separate solutions for iOS here:
https://developer.xamarin.com/recipes/ios/general/projects/environment_checks
And for Android here:
http://forums.xamarin.com/discussion/34275/detect-if-simulator-or-device

I just gathered them altogether and created dependency service for Xamarin.Forms application

Read the rest of this entry »

, , , , ,

1 Comment

Change default console editor in Linux

I do not like default console editors in Linux, if you have the same issue and want to use another editor in your terminal by default, use the following command:

update-alternatives –config editor

This command will show you alternative editors as below, select the one you like more ( I personally like mcedit, it comes together with midnight commander) 🙂

There are 5 choices for the alternative editor (providing /usr/bin/editor).

 Selection Path Priority Status
------------------------------------------------------------
* 0 /bin/nano 40 auto mode
 1 /bin/ed -100 manual mode
 2 /bin/nano 40 manual mode
 3 /usr/bin/mcedit 25 manual mode
 4 /usr/bin/vim.basic 30 manual mode
 5 /usr/bin/vim.tiny 10 manual mode
Press enter to keep the current choice[*], or type selection number: 3

, , , , , ,

1 Comment

Creating cross-platform mobile map application with Xamarin in 10 minutes

Quick tutorial: how to create mobile app with maps using Xamarin just in 10 minutes.

Prerequisites

  • Mac computer with installed XCode and Xamarin Studio
  • Subscription to any Xamarin plan starting from Indie and above
  • Basic C# skills

1. Start new solution in Xamarin Studio, select Cross-platform App -> Blank Xamarin.Forms.App

screen01

2. Call the project MapDemo (or any other name you like), check both Android & iOS platforms and use Portable Class Library

Screen Shot 2015-08-19 at 23.53.08

Read the rest of this entry »

, , , , ,

Leave a comment

Compile Xamarin App for Android in release mode

I encountered multiple times the issue when the build of Xamarin app for Android simply didn’t work in release mode without any obvious reason. Finally looks like I got what should be the appropriate configuration.

So, make sure that you have “Options” for Android project as described below:

1. Build -> General

screen01

2. Build -> Android Build -> Linker -> Linker Options

screen02

3. Build -> Android Application (Minimum: 15+; Target: 21+)

screen03

Pay attention to the fact that “Target Framework” in the item 1 should be the same as “Target Android version” in the item 3, you can find the table with appropriate relations between Android name and APIs here: https://source.android.com/source/build-numbers.html

, , ,

1 Comment

Install applications on Mac from command line

If you have .dmg file

  1. Mount dmg file: hdiutil mount your_favorite_app.dmg
  2. Copy app to “/Applications” folder: sudo cp -R “/Volumes/your_favorite_app/your_app.app” /Applications
  3. Unmount dmg file: hdiutil unmount “/Volumes/your_favorite_app/”

If you have .pkg file:

installer -pkg your_app.pkg -target /

, ,

Leave a comment

MD5 in Linux command line

Getting MD5 sum from the string in Linux command line:

echo -n “Welcome” | md5sum

Leave a comment

Disk usage in command line for Linux & Mac

Quick way to get disk usage for current folder in command line for Linux:

du * -h –max-depth=0 | sort -h

For Mac:

du -hm -d 1 | sort -n

Free disk space can be checked in both systems the same way:

df -h

 

, , , ,

Leave a comment