Monday, February 23, 2015

Disabling the Windows Phone frame rate numbers display while debugging

While debugging Windows Phone Apps, there will be some (weird looking) running numbers on the right side of the app's screen, as shown in the screen shot below.

These are actually frame rate counter numbers to aid in debugging. They can be easily switched off if you do not want them on the screen, especially if you want to capture the screen. To turn it off, just do the following:

  1. In Visual Studio, open up the project's App.xaml.cs file in the editor.


  2. Look for the following lines:

    if (System.Diagnostics.Debugger.IsAttached)
    {
    this.DebugSettings.EnableFrameRateCounter = true;
    }

  3. Change them to the following:

    if (System.Diagnostics.Debugger.IsAttached)
    {
    this.DebugSettings.EnableFrameRateCounter = false;
    }

  4. Run and debug the app again.

    The frame rate numbers are no longer displayed.


Monday, February 16, 2015

How to fix AdDuplex ad unit configuration error for Microsoft AdMediator

The following error message "Ad unit configuration error Please check the configuration" kept popping up in the Microsoft AdMediator control in an Windows Phone 8 app when it tried to display an ad from AdDuplex.

After troubleshooting the issue, I found that the AdDuplex configuration was indeed incorrect. To resolve the issue the following must be done.

  1. In the Visual Studio project, right click on the project with the AdMediator control. Choose Add | Connected Services.

    The Services Manager dialog box appears.

  2. Select AdDuplex. Click Configure.

    The Configure AdDuplex dialog box appears.
  3. Note that the dialog is asking for App ID.
  4. In a web browser, open up the AdDuplex app detail page that you want to show ads for https://manage.adduplex.com/#/apps.

  5. Important: Instead of using the App key as it says on the page, copy the Ad unit ID value at the bottom of the page, e.g. 123456.
  6. Now back to the desktop's Configure AdDuplex dialog box. In the App ID field, type in the value from the web page Ad unit ID, e.g. 123456. Click OK.
  7. In the Service Manager dialog box, click OK.
  8. Build and run the app.

    AdDuplex ads will start appearing correctly in the AdMediator control.

Monday, February 9, 2015

Calculating a rough estimate of the Earth's radius from the old definition of meter

I sometimes have a hard time remembering the radius of the Earth. This tip shows how to derive the rough value if you don't remember the actual number.

According to Wikipedia, the 'Metre' was previously defined as follows:
"The other approach suggested defining the metre as one ten-millionth of the length of the Earth's meridian along a quadrant; that is, the distance from the Equator to the North Pole."
If we approximate the Earth as a perfect Circle, then according to the definition above, the Circumference (C) of the Earth would be 4 times 10 Million meters i.e.
C =  40 Million meters.
Circumference C and Radius R of a circle
From the standard circle equation and the circumference of the Earth (C) above, we can quickly derive the approximate radius (R) of the Earth i.e.

Solving for R = 0.5 * C / Pi, we get the Earth's radius of roughly 6370 kilometers, which is not far from the more accurate 6371 Km value.

Friday, January 30, 2015

Using gdalwarp to mosaic adjacent geo-referenced images

I had to merge adjacent 1 km by 1 km GeoTiff ortho-rectified mosaic images into 2 km by 2 km tiles and I really did not want to run the ortho-rectification and mosaicking processes again just to resize the tiles. After some digging around I found that GDAL has a few tools to perform the merging. I chose to use the gdalwarp executable, as it allows me to define a list of images to merge and the destination image bounds.


The following example shows how to use gdalwarp to merge 2 adjacent GeoTiff images into one.
Two adjacent image tiles to merge
  1. Open up a Command Prompt. Type in the gdalwarp command to merge two files e.g. left.tif and right.tif and output to a new file mosaic.tif:

    C:< gdalwarp left.tif right.tif mosaic.tif
  2. Press Return.

    Processing messages appear and the files are merged.



    The resultant merged GeoTiff image

Wednesday, January 21, 2015

How to mirror or project an Android device screen to a Mac

I wanted to be able to project the screen of an Android handset on to a Macbook to demo an app to an audience. I found a post for a Windows PC on this site http://dmzilla.com/2014/07/21/how-to-display-or-mirror-an-android-device-screen-on-pc-no-root/ but not for a Mac. The post describes downloading and using the Android SDK platform tools along with a Jar file to do the projection to a PC. I thought that the same Jar file could be used on a Mac so I tried out the idea, and it turned out to be functional. So here are the steps to get it to work on a Mac. I am assuming that the following has been done:

  • The Java SE Runtime Environment (JRE) has been installed
  • The Android SDK has been installed to a folder on the Mac e.g. /home/users/admin/Application/sdk/


  1. Download the Jar file http://dmzilla.com/files/display-android-on-windows-pc/%5bDMZilla%5d-Android-Screen-Monitor-(ASM).jar. Put the Jar file to the same location as the Android SDK's adb executable e.g. /home/users/admin/Application/sdk/platform-tools/.

    Note: the actual souce code is available on https://code.google.com/p/android-screen-monitor/
  2. Connect an Android device to the Mac. If necessary, enable USB debugging on the device.
  3. Open up a Terminal.

  4. In the Terminal, type in the cd command to change to the location of the Jar file.

    $ cd /home/users/admin/Application/sdk/platform-tools
  5. Set the Path environment variable to include the Android SDK's platform-tools folder. In the Terminal, type in the export command.

    $ export PATH=$PATH:/home/users/admin/Application/sdk/platform-tools
  6. In the Terminal, run the Jar file.

    $ java -jar \[DMZilla\]-Android-Screen-Monitor-\(ASM\).jar
    The Select a Android Device prompt appears.
  7. In the Select a Android Device prompt, click the device label. Click OK.

    The Android Screen Monitor displays the screen contents of the Android device.
  8. Now on the Android device, run any app you want to present and project to the Mac screen.


Monday, January 5, 2015

Enabling ProGuard obfuscation in Android Studio

In Android Studio, it is possible to use ProGuard to minify and obfuscate the Java source code from decompilation. The settings are different from the Eclipse ADT as Android Studio uses the Gradle build system. But still as straightforward provide you know where and what to change. At the minimum, you only need to enable ProGuard but sometimes it may be necessary to define classes that you do not want ProGuard to obfuscate - this can be done in a ProGuard rules file. The following steps illustrate these two tasks.

Enable ProGuard

  1.  In Android Studio, open up an Android project.
  2. Change to Project View.


  3. Edit the app's build.gradle file.

    Note: make sure the correct build.gradle file is edited. Typically, it is [Android project]/app/build.gradle.
  4. Change the following line:

    minifyEnable false

    to

    minifyEnable true
Set ProGuard Rules(optional)
  1. In Project View, select the proguard-rules.pro file.

    Note: Typically it is [Android project]/app/proguard-rules.pro.


  2. Add in the following lines to tell ProGuard not to obfuscate certain classes. 

-keepclassmembers class com.dom925.xxxx {
   public *;
}


Now when a release build is generated using Android Studio, the app will be obfuscated. 

Monday, December 29, 2014

Trainsity Osaka Android App

Find your way around Osaka city's subway using the high resolution vector maps of the train network. The following metro rail lines are available:

  • Midosuji, 
  • Tanimachi, 
  • Yotsubashi, 
  • Chuo, 
  • Sennichimae, 
  • Sakaisuji, 
  • Nagahori-Tsurumi-ryokuchi, 
  • Imazatosuji, 
  • Newtram Nanko Port Town, 
  • Kita Osaka Kyuko, 
  • Kintetsu Keihanna, 
  • Hankyu Kyoto, 
  • Hankyu Senri, 
  • Osaka Monorail, and 
  • Kitakyu Namboku lines. 
The maps have small file size footprints but with many levels of zoom and can work offline without connecting to the Internet. Users can click the train station box labels to open Google Maps or Google StreetView, where they can use all the functions of the Google apps to visualize the surrounding area and/or perform routing for directions. There is also an offline function to calculate the best way to travel from a station to another station with a direction breakdown and timings (which may vary from the actual travelling time).

On a mobile handset, the app will display a list of train maps, which when tapped will open up a detail view of the subway transit map, as shown below.

Tapping the statin boxes will bring up an option menu where users can choose to display the station in Google Maps or Street View.

There is also an option to find the best direction to or from the tapped stations.

The app is also optimized for tablet sized devices. Both the list and the vector map are displayed at the same time, as shown below.

 The user can toggle the map to full screen mode by tapping the action bar icon at the top right corner.

The app can be downloaded from the Google Play Store. Just click the button below.
Get it on Google Play
Related Posts with Thumbnails