Tuesday, October 30, 2012

Windows Phone 8.0 SDK Download


Today, Microsoft has been launched the Windows Phone 8 Software Development Kit (SDK), which allows developers to developed applications for Windows Phone 8, over the Win RT OS.



Here is dowanloads available.

1) Microsoft online installer for Windows Phopne 8

2) Microsoft offline installer for Windows Phopne 8 (ISO Format)

Cheer development with new Windows Phone 8 SDK :)

Thank you!

Saturday, September 1, 2012

Windows Phone Tasks - Launchers and Choosers

 
In this part we are going to discussed about the Windows Phone Tasks - Launchers and Choosers.
image
Windows Phone tasks API allows you to invoke native tasks (phone’s applications) form your application using managed API, such as PhoneCallTask, EmailComposeTask, SmsComposeTask and MarketplaceSearchTask and so on.
Launchers and Choosers are straightforward to associate with your application.
See the following code snippet for Launchers

  1:  private void btnEmailComposeTask_Click(object sender, RoutedEventArgs e)
  2:         {
  3:             EmailComposeTask oEct = new EmailComposeTask();
  4:             oEct.To = "pavan.pareta@gmail.com";
  5:             oEct.Show();
  6:         }
  7: 
  8:         private void btnMarketplaceDetailTask_Click(object sender, RoutedEventArgs e)
  9:         {
 10:             MarketplaceDetailTask oMdt = new MarketplaceDetailTask();
 11:             oMdt.ContentType = MarketplaceContentType.Applications;
 12:             oMdt.ContentIdentifier = "1fa6b3b1-11f0-4265-ab3d-ac70df5edabc";
 13:             oMdt.Show();
 14:         }
 15: 
 16:         private void btnMarketplaceHubTask_Click(object sender, RoutedEventArgs e)
 17:         {
 18:             MarketplaceHubTask oMht = new MarketplaceHubTask();
 19:             oMht.ContentType = MarketplaceContentType.Music;
 20:             oMht.Show();
 21:         }
 22: 
 23:         private void btnMarketplaceReviewTask_Click(object sender, RoutedEventArgs e)
 24:         {
 25:             MarketplaceReviewTask oMrt = new MarketplaceReviewTask();
 26:             oMrt.Show();
 27:         }
 28: 
 29:         private void btnMarketplaceSearchTask_Click(object sender, RoutedEventArgs e)
 30:         {
 31:             MarketplaceSearchTask oMst = new MarketplaceSearchTask();
 32:             oMst.ContentType = MarketplaceContentType.Applications;
 33:             oMst.SearchTerms = "Games";
 34:             oMst.Show();
 35:         }
 36: 
 37:         private void btnMediaPlayerLauncher_Click(object sender, RoutedEventArgs e)
 38:         {
 39:             MediaPlayerLauncher oMpl = new MediaPlayerLauncher();
 40:             oMpl.Controls = MediaPlaybackControls.All;
 41:             oMpl.Media = new Uri("http://ecn.channel9.msdn.com/o9/ch9/1be6/d5819645-cf1e-4542-bb9d-9e10015a1be6/day01part1_ch9.wmv");
 42:             oMpl.Show();
 43:         }
 44: 
 45:         private void btnPhoneCallTask_Click(object sender, RoutedEventArgs e)
 46:         {
 47:             PhoneCallTask oPct = new PhoneCallTask();
 48:             oPct.PhoneNumber = "1234567890";
 49:             oPct.Show();
 50:         }
 51: 
 52:         private void btnSearchTask_Click(object sender, RoutedEventArgs e)
 53:         {
 54:             SearchTask oSt = new SearchTask();
 55:             oSt.SearchQuery = "Game";
 56:             oSt.Show();
 57:         }
 58: 
 59:         private void btnSmsComposeTask_Click(object sender, RoutedEventArgs e)
 60:         {
 61:             SmsComposeTask oSct = new SmsComposeTask();
 62:             oSct.To = "12345";
 63:             oSct.Body = "Hi! This Windows Phone";
 64:             oSct.Show();
 65:         }
 66: 
 67:         private void btnWebBrowserTask_Click(object sender, RoutedEventArgs e)
 68:         {
 69:             WebBrowserTask oWbt = new WebBrowserTask();
 70:             oWbt.Uri = new Uri("http://www.http://windows-mobile-dev.blogspot.in/");
 71:             oWbt.Show();
 72:         }


Code snippet for.Choosers
  1: private void btnCameraCaptureTask_Click(object sender, RoutedEventArgs e)
  2:         {
  3:             CameraCaptureTask oCct = new CameraCaptureTask();
  4:             oCct.Completed += (s, evnt) =>
  5:             {
  6:                 if (evnt.Error == null && evnt.TaskResult == TaskResult.OK)
  7:                 {
  8:                     BitmapImage bmpImage = new BitmapImage();
  9:                     bmpImage.SetSource(evnt.ChosenPhoto);
 10:                     ImageBrush imb = new ImageBrush();
 11:                     imb.ImageSource = bmpImage;
 12:                     LayoutRoot.Background = imb;
 13:                 }
 14:             };
 15:             oCct.Show();
 16:         }
 17: 
 18:         private void btnEmailId_Click(object sender, RoutedEventArgs e)
 19:         {
 20:             EmailAddressChooserTask oEact = new EmailAddressChooserTask();
 21:             oEact.Completed += (s, evnt) =>
 22:                 {
 23:                     if (evnt.Error == null && evnt.TaskResult == TaskResult.OK)
 24:                     {
 25:                         MessageBox.Show("Name:" + evnt.DisplayName + "\nEmail Id:" + evnt.Email);
 26:                     }
 27: 
 28:                 };
 29:             oEact.Show();
 30:         }
 31: 
 32:         private void btnPhoneNumberChooserTask_Click(object sender, RoutedEventArgs e)
 33:         {
 34:             PhoneNumberChooserTask oPnct = new PhoneNumberChooserTask();
 35:             oPnct.Completed += (s, evnt) =>
 36:             {
 37:                 if (evnt.Error == null && evnt.TaskResult == TaskResult.OK)
 38:                 {
 39:                     MessageBox.Show("Name:" + evnt.DisplayName + "\nPhone Number:" + evnt.PhoneNumber);
 40:                 }
 41: 
 42:             };
 43:             oPnct.Show();
 44:         }
 45: 
 46:         private void btnPhotoChooserTask_Click(object sender, RoutedEventArgs e)
 47:         {
 48:             PhotoChooserTask oPct = new PhotoChooserTask();
 49:             oPct.Completed += (s, evnt) =>
 50:             {
 51:                 if (evnt.Error == null && evnt.TaskResult == TaskResult.OK)
 52:                 {
 53:                     BitmapImage bmpImage = new BitmapImage();
 54:                     bmpImage.SetSource(evnt.ChosenPhoto);
 55:                     ImageBrush imb = new ImageBrush();
 56:                     imb.ImageSource = bmpImage;
 57:                     LayoutRoot.Background = imb;
 58:                 }
 59:             };
 60:             oPct.Show();
 61:         }
 62: 
 63:         private void btnSaveEmailAddressTask_Click(object sender, RoutedEventArgs e)
 64:         {
 65:             SaveEmailAddressTask oSeat = new SaveEmailAddressTask();
 66:             oSeat.Completed += (s, evnt) =>
 67:             {
 68:                 if (evnt.Error == null && evnt.TaskResult == TaskResult.OK)
 69:                 {
 70:                     MessageBox.Show("TaskResult is:" + evnt.TaskResult);
 71:                 }
 72:             };
 73:             oSeat.Show();
 74:         }
 75: 
 76:         private void btnSavePhoneNumberTask_Click(object sender, RoutedEventArgs e)
 77:         {
 78:             SavePhoneNumberTask oSeat = new SavePhoneNumberTask();
 79:             oSeat.Completed += (s, evnt) =>
 80:             {
 81:                 if (evnt.Error == null && evnt.TaskResult == TaskResult.OK)
 82:                 {
 83:                     MessageBox.Show("TaskResult is:" + evnt.TaskResult);
 84:                 }
 85:             };
 86:             oSeat.Show();
 87:         }



Download source code here

Happy CodingThumbs up




Sunday, July 1, 2012

Awarded with Microsoft MVP Award: Second time in Row 2012

 

Once again It’s a fantastic day of my life, when I received a mail from Microsoft “Congratulations 2012 Microsoft MVP!”

I am happy to announce to all my readers that I have been awarded as Microsoft MVP 2nd Time in row. This time also I have been awarded in discipline Device Application Development.

 

MVP-Feature

 

I would like to give a special Thanks to Microsoft India MVP Lead Mr.Tanmay Kapoor for this recognition.

Thanks to Microsoft.

Saturday, June 23, 2012

How determine either location service is on or off?

 

In this post I am going to show how to determine programmatically location service, is on or off.

Why is it necessary in your application?

Let take an example while developing GPS based application for Windows Phone 7 and submitting app to market place, it is very important to get certified your application, user must know that your application going to use Windows Phone GPS service.

Here is the solution for the same case study.

Add the reference in your application.

0001

001

  1: using System.Device.Location; // for GPS Service 
  2: //And
  3: using Microsoft.Phone.Shell;  // for PhoneApplicationService  current status
  4: 

Initialization GeoCoordinateWatcher object for execute the GPS Service.

  1: void MainPage_Loaded(object sender, RoutedEventArgs e)
  2:         {
  3:             geoWatcher = new GeoCoordinateWatcher();
  4:             geoWatcher.StatusChanged += new EventHandler<GeoPositionStatusChangedEventArgs>(geoWatcher_StatusChanged);
  5:             geoWatcher.PositionChanged += new EventHandler<GeoPositionChangedEventArgs<GeoCoordinate>>(geoWatcher_PositionChanged);
  6: 
  7: 
  8:             if (DoChk())
  9:             {
 10:                 geoWatcher.Start();
 11:             }
 12:         }
 13: 
 14:         void geoWatcher_PositionChanged(object sender, GeoPositionChangedEventArgs<GeoCoordinate> e)
 15:         {
 16:             textBlock1.Text = string.Format("Latitude:{0}\nLongitude:{1}", e.Position.Location.Latitude, e.Position.Location.Longitude);
 17:         }
 18: 
 19:         void geoWatcher_StatusChanged(object sender, GeoPositionStatusChangedEventArgs e)
 20:         {
 21:             textBlock2.Text = string.Format("Status:{0}" , e.Status.ToString());
 22: 
 23:             if (DoChk())
 24:             {
 25:                 geoWatcher.Start();
 26:             }
 27:           
 28:         }
 29: 
 30:         public GeoCoordinateWatcher GeoWatcher
 31:         {
 32:             get
 33:             {
 34:                 return geoWatcher;
 35:             }
 36:             set
 37:             {
 38:                 if (geoWatcher != value)
 39:                 {
 40:                     geoWatcher = value;
 41:                 }
 42:                 if (geoWatcher.Status == GeoPositionStatus.Disabled)
 43:                 {
 44:                     geoWatcher.Stop();
 45:                 }
 46:             }
 47: 
 48:         }
 49: 
 50: 
 51:         private bool DoChk()
 52:         {
 53:             bool allow = false;
 54: 
 55: 
 56:             if (PhoneApplicationService.Current.State.ContainsKey("allow"))
 57:             {
 58:                 allow = (bool)PhoneApplicationService.Current.State["allow"];
 59:             }
 60: 
 61:             if (allow == false)
 62:             {            
 63:                 var result = MessageBox.Show(
 64:                                "Application uses your Phone location. Do you wish " +
 65:                                "to give it permission to use your location?",
 66:                                "User Location Data",
 67:                                MessageBoxButton.OKCancel);
 68: 
 69:                 // Save answer so you can access it on other pages 
 70:                 allow = (result == MessageBoxResult.OK);
 71:                 PhoneApplicationService.Current.State["allow"] = allow;
 72:             }
 73:             return allow;
 74:         }

002


003


Here is source code


thank you for your time.


Happy Coding

Saturday, June 2, 2012

How to use isolated storage API in Windows 8 Application


While working on Windows 8 Application, I was under impression, is that we can use the Isolated storage API as it is like Windows Phone 7, but we can’t in Windows 8, Windows 8 introduce new API that is Windows.Storage. Storage API allows us to save data in Application level data. This is very simple and useful code snippet here.

  1: public void SaveInfo(string key, string value)
  2: {
  3:     if (Windows.Storage.ApplicationData.Current.LocalSettings.Values.ContainsKey(key))
  4:     {
  5:         if (Windows.Storage.ApplicationData.Current.LocalSettings.Values[key].ToString() != null)
  6:         {
  7:             // do update
  8:             Windows.Storage.ApplicationData.Current.LocalSettings.Values[key] = value;
  9:         }
 10:     }
 11:     else
 12:     {
 13:         // do create key and save value, first time only.
 14: 
 15:         Windows.Storage.ApplicationData.Current.LocalSettings.CreateContainer(key, ApplicationDataCreateDisposition.Always);
 16: 
 17:         if (Windows.Storage.ApplicationData.Current.LocalSettings.Values[key] == null)
 18:         {
 19:             Windows.Storage.ApplicationData.Current.LocalSettings.Values[key] = value;
 20:         }
 21:     }
 22: }



Cheer!!

Happy coding… :)

Tuesday, May 1, 2012

How to access Application Manifest (WMAppManifest.xml) file in WP7 App at runtime

 

Very long time and back to work, just for curiosity about how to access “WMAppManifest.xml”; using silverlight c# code in Windows Phone application. In this article we will discuss Application Manifest file called WMAppManifest.xml file and it is available in Properties folder of your project in the Solution Explorer. Manifest file contains details about the application, such as the App ID Title, RuntimeType, Version, Genre, Author, Description, Publisher and the application capabilities.

Here is a ways to read the WMAppManifest.xml file using XML Parse API.

Consider below mentioned code snippet.

private string ReadWMAppManifest()
        {
            string wmData = string.Empty;
            System.Xml.Linq.XElement appxml = System.Xml.Linq.XElement.Load("WMAppManifest.xml");
            var appElement = (from manifestData in appxml.Descendants("App") select manifestData).SingleOrDefault();
            if (appElement != null)
            {
                wmData = "ProductID = " + appElement.Attribute("ProductID").Value + Environment.NewLine;
                
                wmData += "Title = " + appElement.Attribute("Title").Value + Environment.NewLine;
                wmData += "RuntimeType = " + appElement.Attribute("RuntimeType").Value + Environment.NewLine;
                wmData += "Version = " + appElement.Attribute("Version").Value + Environment.NewLine;
                wmData += "Genre = " + appElement.Attribute("Genre").Value + Environment.NewLine;
                wmData += "Author = " + appElement.Attribute("Author").Value + Environment.NewLine;
                wmData += "Description = " + appElement.Attribute("Description").Value + Environment.NewLine;
                wmData += "Publisher = " + appElement.Attribute("Publisher").Value + Environment.NewLine;
            }
            appElement = (from manifestData in appxml.Descendants("PrimaryToken") select manifestData).SingleOrDefault();
            if (appElement != null)
            {
                wmData += "TokenID = " + appElement.Attribute("TokenID").Value + Environment.NewLine;
            }
            return wmData;
        }

 


Download source code here - ReadWMAppManifest


Happy Coding


Thanks for your time.

Saturday, February 11, 2012

How to use vibrate API the phone for Windows Phone




VibrateController API for Windows Phone, it’s basically allows you to Vibrate your phone programmatically. It’s really pretty straightforward to implement in your application.

Code snippet:

VibrateController.Default.Start ( TimeSpan.FromSeconds (1) )  ;


~~ Happy Coding ~~

Friday, January 13, 2012

How to Monetize Windows Phone 7 Application

 

This article explains how to Monetize Windows Phone 7 application using Microsoft Advertising Ad control.

Introduction

The market for Windows Phone 7 apps is wide open for developers wanting to monetize mobile apps. That means endless opportunities for any developer looking to monetize mobile apps.

Monetization in mobile app basically allows developer to display advertisement on your mobile application, in WP7 we achieving such kind of functionality using Microsoft Advertising Ad Rotator Control. Monetized utilizing unique capability to serve ads based on *where* the person is located, *what* they are searching for (ad unit categories), and *when* they are searching (active advertising campaigns)

What is mobile monetization?

In mobile app development the term monetization is used to mean the ability to generate revenue thorough your mobile app. It can be from affiliate programs, e- commerce, premium content and advertising.

Implementation

Basic steps follow to implementation in Windows Phone 7 app.

Step-1:

Download Microsoft Advertising SDK.

Download Microsoft Advertising SDK for Windows Phone.

After download Microsoft Advertising SDK, install it on your development machine.

Step-2:

Register mobile App at Microsoft pubCenter..

Register Your Mobile App: Sign up and register your Windows Phone apps using Microsoft pubCenter. Here you can use your live or pubCenter Id.

Ad_001

Register your first application and create an ad unit (optional)

 

Ad_002

Enter application name:

Device type:

Ad unit name:

Ad unit size:

Select Ad category:

Excluded Url:

 

 

Ad_003

Step-3:

Create the Windows Phone application

1- Create a Windows Phone 7 Application project

Wp_Ad_001

2- Right click on project in solution explorer panel and click on Add Reference dialog box, click the Browse tab. Navigate to the location where you installed the Microsoft.Advertising.Mobile.UI.dll previously. Click the Microsoft.Advertising.Mobile.UI.dll to select it, and click OK.

Wp_Ad_002

Wp_Ad_003

3- Now configure Application Id and Ad Unit Id properties in the Ad Control.

Here is two ways to add “Ad Control” in the application using XAML and C# code behind.

Using XAML

Drag and drop the Ad Control to Windows Phone 7 xaml page and configure Application Id and Ad Unit Id properties in xaml.

See below code snippet:

<my:AdControl Foreground="Red"
AdUnitId="10020750" 
ApplicationId="e1e3c23b-3a59-4119-852e-8ad0a7f78f11" 
Height="80" 
HorizontalAlignment="Left" 
Margin="0,6,0,0" 
Name="adControl1" 
VerticalAlignment="Top" 
Width="480" 
IsAutoRefreshEnabled="True" />
Wp_Ad_004

Using (C#) code behind

Double click on the Windows Phone7 Page, it will automatically open the code behind of a page. And using the AdControl API which is a managed api. Include the Microsoft.Advertising.Mobile.UI namespace in the project. And create an instance of the AdControl Class and set the properties of the AdControl class instance or you can directly pass it to AdControl constructor.

See below code snippet:

private const string APPLICATION_ID = "";
       private const string AD_UNIT_ID = "";//
       private AdControl adControl;
        // Constructor
        public MainPage()
        {
            InitializeComponent();
            this.Loaded += new RoutedEventHandler(MainPage_Loaded);
            this.Unloaded += new RoutedEventHandler(MainPage_Unloaded);
        }
        void MainPage_Loaded(object sender, RoutedEventArgs e)
        {
            if (!string.IsNullOrEmpty(APPLICATION_ID) && !string.IsNullOrEmpty(AD_UNIT_ID))
            {
                adControl = new AdControl(
                    APPLICATION_ID,
                    AD_UNIT_ID,
                    true);
                // Make the AdControl size large enough that it can contain the image
                adControl.Width = 480;
                adControl.Height = 80;
                adControl.Keywords = "Windows Phone 7, Hotels, Travels, Gold";
                ContentPanel.Children.Add(adControl);
            }
            else
            {
                MessageBox.Show("To show ads in this application, insert the application ID and an ad unit ID into your code as explained..");
            }
        }
        void MainPage_Unloaded(object sender, RoutedEventArgs e)
        {
            ContentPanel.Children.Remove(adControl);
        }

Run the application by using F5 button, and you will see a sample of Monetization in Windows Phone 7 Application.

Wp_Ad_005

 

Thanks you!

 

Happy Coding Smile