Tuesday, October 11, 2011

Android, Phonegap, Jquery Mobile and Eclipse

The following 2 references should get you started with Android, Phonegap, Jquery mobile.

  1.  phonegap-android-eclipse-quickstart gives all the steps needed to run a phonegap application with Android and Eclipse. After building the first sample project follow closely the steps given for new project.
  2. UI Development using jQueryMobile gives steps to integrate Jquery mobile to the mix.

The 2nd example uses Phonegap version 0.9. Updating to the recent version of phonegap is easy. However an extra XML folder in phonegap res (as mentioned in the first reference) should also be copied!

In reference 2 the download code and the listing in the blog are different. The blog source HTML works.

Thursday, October 6, 2011

Jquery mobile, Xampp, Android and WP7.1

Downloaded Jquery Mobile RC1. Looks great. The demo files are great to look at for examples. Unfortunately it is little bit more complicated to get it working locally so that you can look at the source code.

For this go to the  Github repo download the zip file. It is a daily build. For example the version I downloaded was jquery-jquery-mobile-1.0rc1-33-gda2352a.

I unzipped it and copied all the files  and copied them to

C:\jqm2\docs\docs_rc1 folder.

In XAMPP to avoid conflicts with IIS I did the following changes in the  httpd.conf file in  C:\xampp\apache\conf:

  1. #Listen 80 to
    Listen 8080
  2. #ServerName localhost:80
    ServerName localhost:8080
  3. #DocumentRoot "C:/xampp/htdocs"
    to DocumentRoot "C:\jqm2\docs"

The first 2 changes avoid a conflict with IIS which was in 80 port in my machine.

Then I am able to browse the demo files by staring XAMPP and looking at the following web page


Tested on both Windows Phone 7 with SDK7.1 and Android emulators. Works great.

Remember to press F8 in Android emulator to get web access and instead of localhost you have to use as given in references below.

  1. Ever tried ‘localhost’ with the android emulator ?
  2. Android - Emulator internet access

Friday, June 17, 2011

Windows phone 7 data visualization chart

I have made interesting charts on Windows Phone 7 based on various blog posts on this topic.

David Anson has a series of posts in his blogs

Delay's Blog

For basic charts use this:

Phone-y charts [Silverlight/WPF Data Visualization Development Release 4 and Windows Phone 7 Charting sample!]

The interesting portion in Windows Phone 7 is to load the exact assemblies from this code.

To modify colors  I used the following post

Chart tweaking made easy [How to: Make four simple color/ToolTip changes with Silverlight/WPF Charting]

Also I have been able to rotate the labels on column chart X axis by using this post

Turn your head and check out this post [How to: Easily rotate the axis labels of a Silverlight/WPF Toolkit chart]

Tuesday, June 14, 2011

Autocompletebox with long lists for windows phone 7

I recently was working with a list of American cities which has around 19000 cities in WP7 application. I wanted to use the autocompletebox which will be helpful to find a name fast. However, the autocompletebox was sluggish. Hence I created a list of lists. The lists where for each alphabet which reduced the list sizes to reasonable size. I also used LINQ to get the city name.

When I tested in WP7 I got all searches under 100 milliseconds and most of them around 2 to 30 milliseconds.

Another thing I found out is the autocompletebox does not like Pivot control. The selection list offsets to the top of the screen with the first selection completely masked!

See the reference below


The XAML and the code are given below. This also used the textbox substitution to make sure the initial display did not have the drop down of the autocompletebox as per this forum discussion which I initiated:

AutoCompleteBox initial value in Windows Phone 7

 <StackPanel Grid.Row="0" Orientation="Horizontal"   HorizontalAlignment="Stretch">
<toolkit:AutoCompleteBox ItemsSource="{Binding}" x:Name="City_Name_TextBox" ValueMemberPath="CityName"
Width="370" Visibility="Collapsed" MinimumPopulateDelay="200" <toolkit:AutoCompleteBox.ItemTemplate>
<DataTemplate >
<StackPanel VerticalAlignment="Stretch" >
<TextBlock Text="{Binding CityName}" />
<TextBox Width="300" x:Name="City_Name_TextBox_Init" Visibility="Visible" Text="Palo Alto" MouseLeftButtonDown="City_Name_TextBox_Init_MouseLeftButtonDown"></TextBox>
<Button x:Name="Go_Button" Width="100" Content="GO" Click="Go_Button_Click" ></Button>
 private void City_Name_TextBox_Init_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
City_Name_TextBox_Init.Visibility = System.Windows.Visibility.Collapsed;
City_Name_TextBox.Visibility = System.Windows.Visibility.Visible;
City_Name_TextBox.Text = "";
// City_Name_TextBox.Focus();
 public void Load_City_Alpha()
string[] abclist = new[] { "a", "b", "c","d","e","f","g","h","i","j",
int salphaselectormax=26;
DateTime dtstart = DateTime.Now ;

for ( int salphaselector = 0; salphaselector < salphaselectormax; salphaselector++)
string salpha = abclist[salphaselector];
city_list_abc.Add( (from n in citylist
where n.CityName.ToLower().StartsWith(salpha)
select n).ToList());

//List<string> testlistlength = new List<string>();
//for (int i = 0; i < 26; i++)
// testlistlength.Add(abclist[i]+"--" + city_list_abc[i].Count.ToString());
DateTime dtend = DateTime.Now;
int dtduration = (dtend - dtstart).Milliseconds;

  private void City_Name_TextBox_Populating(object sender, PopulatingEventArgs e)
// Allow us to wait for the response
DateTime dtstart = DateTime.Now;
e.Cancel = true;
//only query web service if more than 3 chars

if (City_Name_TextBox.Text.Length >= 3)
// Create a request for suggestion
int listindex = Array.IndexOf(abclist, City_Name_TextBox.Text.ToLower().Substring(0,1));
List<City> results = (from n in (Application.Current as App).city_list_abc[listindex]
where n.CityName.ToLower().StartsWith(City_Name_TextBox.Text.ToLower())
select n).ToList();
City_Name_TextBox.ItemsSource = results;
DateTime dtend = DateTime.Now;
int dtduration = (dtend - dtstart).Milliseconds;
Timer_TextBox.Text = dtduration.ToString();

Monday, April 18, 2011

JQuery Mobile file locations

Jquery Mobile is a fascinating technology. I really enjoy the ease with which you can design web sites with that. Now this also supports Windows Phone 7! Since this is a rapidly evolving technology, the file locations can be hard to find. Eddie Monge has simplified the job for us by this blog post

Nightly and Up-To-Date builds

This is a very useful link

http://code.jquery.com/mobile/latest/jquery.mobile.zip – The zipped up package of all the files necessary to deploy

The test area is located at:


Thursday, April 14, 2011

Bing mobile search for Windows Phone 7 and Javascript enable

Javascript is disabled by default in Windows Phone 7 browser. This caused me some problems when I tried to use mobile bing search in my application.

You have to do this to enable the Javascript.

Webbrowser1.IsScriptEnabled = true;

You can access Bing Mobile search by using http://m.bing.com/

For example to search for Alex Rodriguez you would use something like the following:


Sunday, March 27, 2011

Windows Phone 7 XNA Games advertising

My earlier post Windows Phone 7 Silverlight, Adcontrol step by step, tricks and issues was mainly about admanager on WP7 Silverlight.

To implement admanager in XNA games, especially when you use XNA Gamestatemanagement sample Game State Management

Insert the following code in the GameplayScreen.cs file LoadContent method.

Guide.SimulateTrialMode = true;
if (Guide.IsTrialMode)
// adManager = new AdManager(this.ScreenManager.Game, "test_client");
adManager = new AdManager(this.ScreenManager.Game, "applicationid");
adManager.TestMode = false;

// Create a banner ad for the game
// bannerAd = adManager.CreateAd("Image300_50", new Rectangle(0, 700, this.ScreenManager.GraphicsDevice.Viewport.Bounds.Width, 120), RotationMode.Manual, false);
bannerAd = adManager.CreateAd("unitid", new Rectangle(0, 700, this.ScreenManager.GraphicsDevice.Viewport.Bounds.Width, 120), RotationMode.Manual,false);



When you want to test it with the testad set adManager. TestMode true, uncomment the test_client admanager constructor and comment out the applicationid admanager contructor.

When you want to test with real ads, set adManager.TestMode false, comment out adManager test_client method and uncomment adManager applicationid constructor.

applicationid and unitid Identifies the application and is assigned to you during the publisher registration process.

Interesting discussion on this in this thread in which I participated!Where to insert the admanager in Gamestatemanagment sample

Friday, January 28, 2011

Windows Phone 7 Silverlight, Adcontrol step by step, tricks and issues

Went through interesting experience in implementing the adcontrol in Windows Phone 7 and I thought I will share it here.

First go and register your application in

Microsoft Pubcenter

This site gives you the following steps

  1. Register mobile application
  2. Create application ad unit
  3. Download the Microsoft Advertising SDK for Windows Phone 7
  4. Integrate the Microsoft Advertising SDK for Windows Phone 7 into your application.
  5. Manage your existing applications and ad units

In the XAML insert the ad control

<StackPanel Grid.Row="5"   x:Name="SP_ADControl" Visibility="Visible"   >

<ad:AdControl RotationEnabled="True" AdModel="Contextual" Width="450" Height="80"
AdUnitId="your adunit id" ApplicationId="your application id" />

<!--<ad:AdControl Width="450" Height="80"
AdUnitId="TextAd" ApplicationId="test_client" />-->


In my application Grid.Row=”5” is the bottom portion of the screen. Do not forget to pu your own ApplicationID and AdUnitId. The commented out portion is what you can use to test the app without getting an app id from the pub center.

In the Xaml.cs file put the following in the code right after InitializeComponent();

  if (!CheckIsTrial())
SP_ADControl.Visibility = Visibility.Collapsed;
// Show_Buy_Now_Page();
SP_ADControl.Visibility = Visibility.Visible;
AdControl.TestMode = false;

Add this method to the code

private bool CheckIsTrial()
MessageBoxResult result = MessageBox.Show
if (result == MessageBoxResult.OK)
return false;
return true;
return licenseInfo.IsTrial();

This would help to test the app in the debug mode by showing you a dialog to test the ap. Check reference 5 given below.

The most interesting line of code is  AdControl.TestMode = false;  This is required because the Adcontrol.TestMode default value is True! Check reference 1 and 2 on this.

Do not forget to submit the release version to the marketplace.


  1. Making the MS Adcontrol REALLY work on phone 7

  2. WP7 – Using the Microsoft AdControl

  3. Integrating the AdControl into an Application Programmatically (C#)

  4. Microsoft Advertising SDK for Windows Phone 7

  5. How to: Test and Debug your Trial Application

  6. Tips on Using the AdControl in Windows Phone 7

Saturday, January 22, 2011

Friday, January 21, 2011

Windows Phone 7 Ad Control Testing in Emulator

I did the following after checking several posts on the Microsoft Ad Control for Windows Phone 7.
The following should go in the Constructor of the page.

 if (!CheckIsTrial())
SP_ADControl.Visibility = Visibility.Collapsed;

// Show_Buy_Now_Page();
SP_ADControl.Visibility = Visibility.Visible;

the following is the CheckisTrial Method

private bool CheckIsTrial()
MessageBoxResult result = MessageBox.Show("CLICK OK TO SIMULATE FULL LICENSE", "BUY NOW!", MessageBoxButton.OKCancel);

if (result == MessageBoxResult.OK)
return false;
return true;
Return licenseInfo.IsTrial();