Launchers related to MarketPlace in Windows Phone

In this post we will discuss three important launchers related to Windows Phone Market Place

  • MarketPlaceHubTask launcher
  • MarketPlaceReviewTask launcher
  • MarketPlaceDetailTask launcher

MarketPlaceHubTask launcher

This is used to launch Windows Phone Market Place client application. You can launch market place client application along with music content as below,


MarketplaceHubTask marketplaceHubTask = new MarketplaceHubTask();
marketplaceHubTask.ContentType = MarketplaceContentType.Music;
marketplaceHubTask.Show();

You can set content type of the search either as Application or Music. MarketPlaceContentType is defined as below,

clip_image002

Market place client application will be launched as below,

clip_image003

MarketPlaceReviewTask launcher

This is used to launch market place client application with review page. Market place application review page can be launched as below,



MarketplaceReviewTask marketplaceReviewTask = new MarketplaceReviewTask();
marketplaceReviewTask.Show();

It will ask user confirmation for Submit or Cancel. It will ask user confirmation for Submit or Cancel. After selecting submit option user will be redirected to review page of market place application.

MarketPlaceDetailTask launcher

This is used to launch market place client application with details page of specified application. You need to pass unique content identifier of application to get detail page of the application from market place. If you don’t set unique content identifier then detail page of current application will be launched in windows phone market place client application.

You can launch detail page of current application as below,


MarketplaceDetailTask marketplaceDetailTask = new MarketplaceDetailTask();
marketplaceDetailTask.ContentType = MarketplaceContentType.Applications;
marketplaceDetailTask.Show();

You can launch detail page of a specific application by passing content identifier.

These are three important launchers for market place client application and you may use them frequently in your application. I hope this post is useful. Thanks for reading.

WebBrowserTask and MediaPlayerLauncher in Windows Phone

In this post, we will see WebBrowserTask launcher and MediaPlayer launcher.

WebBrowserTask launcher launches web browser application and display specified URL. This is defined as below,

image

You can set target URL either as string or as Uri. User will be asked for the confirmation. You can navigate to a URL as below,



WebBrowserTask webBrowserTask = new WebBrowserTask();
webBrowserTask.Uri = new Uri("http://debugmode.net", UriKind.Absolute);
webBrowserTask.Show();

On running you will be navigated to given URL as below,

image

MediaPlayerLauncher is used to launch media player application and play the video from specified URL. This class is defined as below,

image

You can set desired controls of media player to be shown to user. Available media player controls are as below.

image

If you want to show more than one control to the user then you need to append them using OR operator and set them as value of control property.

image

You can also specify location of the media file in MediaLocationType property. MediaLocationType takes one of three values.

 

image

 

Install represents application installation directory, Data represents isolated storage and None value need to be set for external media.

You can play media with file from isolated storage as below,



MediaPlayerLauncher mediaPlayerLauncher = new MediaPlayerLauncher();

mediaPlayerLauncher.Media = new Uri("SongVideo.wmv", UriKind.Relative);
mediaPlayerLauncher.Location = MediaLocationType.Data;
mediaPlayerLauncher.Controls = MediaPlaybackControls.Pause |
MediaPlaybackControls.Stop|
MediaPlaybackControls.FastForward;
mediaPlayerLauncher.Orientation = MediaPlayerOrientation.Landscape;

mediaPlayerLauncher.Show();

In this way you can work with MediaPlayerLauncher.

In this post we discussed on WebBrowserTask and MediaPlayerLauncher. You may need to call these native applications from your app. I hope this post is useful. Thanks for reading.

Code to Share Status or Links on Social Media sites in Windows Phone

While creating application for Windows Phone you may come across requirement to share certain message from your application on social media sites configured on user device. You can do it using ShareStaus Task. ShareStausTask class is defined as below. It is inherited from ShareTaskBase class.

image

 

ShareStatus Task Launcher allows an application to launch a dialog that allows user to share status message on social network site.

A status message can be shared as below,


ShareStatusTask shareStatusTask = new ShareStatusTask();
shareStatusTask.Status = "Hey I am Shared By DebugMode";
shareStatusTask.Show();


You may come across other scenario where you may need to share HyperLink across Social Media sites from your application. You can do that using launcher ShareLinkTask.

ShareLinkTask class is defined as below,

image

ShareLink Task Launcher allows an application to launch a dialog that allows user to share links on social network site.

A link can be shared as below,



ShareLinkTask shareLinkTask = new ShareLinkTask();
shareLinkTask.Title = "DebugMode";
shareLinkTask.LinkUri = new Uri("http://debugmode.net", UriKind.Absolute);
shareLinkTask.Message = "Post of DebugMode.";
shareLinkTask.Show();

These launchers will be launched only if user has configured social media sites on their device. I hope this post is useful. Thanks for reading.

How to Use the ConnectionSettings Task for Windows Phone

ConnectionSettings Task allows user to set and adjust device network settings. ConnectionSettings task is defined in Microsoft.Phone.Tasks namespace as below,

image

User can set device network setting to any of the following

image

If you want to set Network connection setting to WiFi, you can set it as below,


ConnectionSettingsTask connectionSettingsTask = new ConnectionSettingsTask();
connectionSettingsTask.ConnectionSettingsType = ConnectionSettingsType.WiFi;
connectionSettingsTask.Show();

image

If you want to set Network connection setting to Bluetooth, you can set it as below,


ConnectionSettingsTask connectionSettingsTask = new ConnectionSettingsTask();
connectionSettingsTask.ConnectionSettingsType = ConnectionSettingsType.Bluetooth;
connectionSettingsTask.Show();

image

If you want to set Network connection setting to Cellular, you can set it as below,


ConnectionSettingsTask connectionSettingsTask = new ConnectionSettingsTask();
connectionSettingsTask.ConnectionSettingsType = ConnectionSettingsType.Cellular;
connectionSettingsTask.Show();

image

If you want to set Network connection setting to Airplane mode, you can set it as below,


ConnectionSettingsTask connectionSettingsTask = new ConnectionSettingsTask();
connectionSettingsTask.ConnectionSettingsType = ConnectionSettingsType.AirplaneMode;
connectionSettingsTask.Show();


image

In this way you can set the network setting of device using ConnectionSettings task. I hope this post is useful. Thanks for reading

What are Launchers and Choosers in Windows Phone 7

Launcher and Choosers API allows application to interact with Native Applications of Windows Phone 7

clip_image002

Launchers

clip_image003

  • Launchers are collection of classes in Windows Phone 7.
  • They help to interact with inbuilt applications on native application of Windows Phone 7.
  • Launchers used to launch one of the inbuilt or native applications from your application.
  • Launchers do not return any data from the inbuilt or native application.

Different Launchers are as below,

  • EmailComposerTask
  • PhoneCallTask
  • SmsComposeTask
  • MarketPlaceHubTask
  • MarketPlaceSearchTask
  • MarketPlaceDetailsTask
  • MarketPlaceReviewTask
  • MediaPlayerLauncher
  • WebBrowserTask
  • SearchTask

Choosers

clip_image004

  • Choosers are collection of classes in Windows Phone 7.
  • They help to interact with inbuilt or native applications of Windows Phone 7.
  • Choosers launch and native application and returns data from the launched application for further manipulation also.
  • Choosers return data to the application using choosers.
  • It’s not necessary that all the Choosers return data. For example SaveEmailAddressTask chooser task does not return any data to the calling application.

Data return by the Choosers should be handled in the completed event of the Choosers.

Different choosers are as below,

  • CameraCaptureTask
  • PhotoChoosersTask
  • SaveEmailAddressTask
  • EmailAddressChoosersTask
  • SavePhoneNumberTask
  • PhoneNumberChooserTask

Using Choosers and Launchers in Code

You need to make instance of choosers or launcher to use them. You need to add below namespace to use various launchers or choosers.

clip_image005

After creating instance you need to call Show method () as below. There are many options also you can set with different launchers.

clip_image006

In case of Chooser you need to handle completed event to work with returned data.

Good Practice to use Choosers in the code

There are three points you need to keep in mind while working with choosers in Windows Phone 7. To explain you more I am using PhotoChooserTask

Three points are as below,

Point 1

You need to instantiate Choosers as the global variable on the page of the application

clip_image007

Point 2

You need to make sure that you are registering completed event in constructor of the page.

clip_image009

Point 3

In the completed event of Chooser, first you need to check for the TaskResult value. If it is ok then perform the task.

clip_image010

This is all about Launchers and Choosers. I hope this post is useful. Thanks for reading.

Code to make call in Windows Phone 7

Launchers are used to perform task provided by phone operating system. Making Call is feature of Windows phone operating system and can be used by Launcher API. PhoneCallTask launcher is used to call. This launcher class is defined as below,

image

 

To work with PhoneCallTask, first you need to add namespace of Microsoft.Phone.Task

image

Then create instance of PhoneCallTask.

image

Next you need to set values properties to make the call. To make the call you need to set below properties

  • PhoneNumber
  • DisplayName

So first set PhoneNumber property as below,

image

And DisplayName as below,

image

Last step you need to launch making call application provided by operating system. You can show that as below,

image

If you put all code together and want to make a call on click event of button then full code will be as below,

 


using System.Windows;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Tasks;

namespace Day6
{
public partial class MainPage : PhoneApplicationPage
{

public MainPage()
{
InitializeComponent();
}

private void btnCall_Click(object sender, RoutedEventArgs e)

{
PhoneCallTask callTask = new  PhoneCallTask();
callTask.PhoneNumber = "999999";
callTask.DisplayName = "debugMode";
callTask.Show();

}

}
}

 

When you run above code you will get application running as below,

image

When you click on Call button, you will next screen as below for confirmation to call.

image

After choosing Call you will get usual Windows Phone 7 Call screen as below,

image

If you want you can very much end call, turn on speaker, mute hold or add call. I hope this post was useful. Thanks for reading Smile

If you find my posts useful you may like to follow me on twitter http://twitter.com/debug_mode or may like Facebook page of my blog http://www.facebook.com/DebugMode.Net If you want to see post on a particular topic please do write on FB page or tweet me about that, I would love to help you.