Window Support

  • Subscribe to our RSS feed.
  • Twitter
  • StumbleUpon
  • Reddit
  • Facebook
  • Digg

Saturday, 21 January 2012

Share Status and Link on Socials in Windows Phone

Posted on 05:43 by Unknown

 

Hope you all doing good.Sorry for the great delay here,I am almost working for all 7 days in week and that too on SQL Server – SSIS which is totally Alien to me but now I have good hands-on (In future you might get to see few post on that as well) for a critical project in my company. Due to this I couldn’t meet you here.

Today finally I got sometime to spend here and on Windows Phone and Silverlight, So I thought I can share something quickly with you before I get to other big topics.Our today’s topic is small but very unique and useful. Today I am going to talk about 2 set of Tasks and how to use them effectively available with new Windows Phone SDK as ShareStatusTask and ShareLinkTask  which comes under Microsoft.Phone.Tasks Namespace.So lets start with it.

So all we need is a simple Textbox and Button like this :

UITaskShare

XAML Code :

<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
            <TextBox x:Name="txtStatus" Height="100" />
            <Button x:Name="btnShare" Height="100" Width="200" Margin="0,358,0,149" Click="btnShare_Click">Share</Button>
</Grid>

Namespace :

using Microsoft.Phone.Tasks;

C# Code :

private void btnShare_Click(object sender, RoutedEventArgs e)
{
    ShareStatusTask mySocialTasks = new ShareStatusTask();

    mySocialTasks.Status = txtStatus.Text.ToString() + System.DateTime.Now.ToString();

    mySocialTasks.Show();
}

Above code is simple, We have a ShareStatusTask which comes with Property Status like this in ShareStatusTask which is Inherited from ShareTaskBase whose Show() method Causes the sharing dialog to be displayed to the user.

public string Status { get; set; }

public void Show();

So we are passing our/user defined Status message from Textbox txtStatus and appending DateTime with it (You can append anything or customize as per your need), Once you click on Share you will get Share Dialog like this :

WP_000005

Sorry for bit low screenshot, but you can see the list of Socials available on your device as

  • Windows Live
  • Facebook
  • Twitter
  • LinkedIn

If something new comes up tomorrow might get added to list, So all you need to do is pick the Socials and go ahead and share. Please note that this does not work on Windows Phone Emulator so you need to port this on actual Windows Phone Device.Also note that availability of Socials on your phone depends on your configuration and choice to have.So Don’t waste your time in emulator since it will not give any output or will not give any response.

On similar lines, we can implement ShareLinkTask Class like this :

private void btnShare_Click(object sender, RoutedEventArgs e)
      {
          ShareLinkTask mySocialLinks = new ShareLinkTask();

          mySocialLinks.Title = "Explore .NET with Vikram Pendse";
          mySocialLinks.LinkUri = new Uri("http://pendsevikram.blogspot.com", UriKind.Absolute);
          mySocialLinks.Message = txtStatus.Text.ToString() + System.DateTime.Now.ToString();

          mySocialLinks.Show();
      }

Choose “Windows Phone Device” and hit F5, you can see in Output window how it ports to Device and confirm the same like this it got displayed in my VS Output Window : (Observe lines in Bold)

------ Deploy started: Project: Demo_ShareStatus_Task, Configuration: Debug Any CPU ------
Deploying D:\Silverlight_On_Mobile\Demo_ShareStatus_Task\Demo_ShareStatus_Task\Bin\Debug\Demo_ShareStatus_Task.xap...
Connecting to Windows Phone Device...
The application is already installed on the device. Checking if an incremental deployment is possible...
Doing incremental deployment...
Updating information related to modified files...
Deployment of D:\Silverlight_On_Mobile\Demo_ShareStatus_Task\Demo_ShareStatus_Task\Bin\Debug\Demo_ShareStatus_Task.xap succeeded.
========== Deploy: 1 succeeded, 0 failed, 0 skipped ==========

Now your app is ready to test on your WP Device, But make note of 2 things before you deploy :

  • Phone is ON and at Home Screen is visible and not pin locked
  • Zune instance is up and running

Now start from App list like this : (Demo_ShareStatus Icon)

WP_000003

Type your Message :

WP_000004

Share Link and Select Social Networks like this :

WP_000006

Finally you can see this happening in real on your respective Social Networks, Like in my case this got posted on my Facebook,Twitter and LinkedIn in one shot and at same time at all place like this :

Facebook :

Facebook

Twitter :

Twitter

LinkedIn :

LinkedIn

So this is how you can share Status or Link in very short piece of Code by making use of ShareStatusTask and ShareLinkTask given by Windows Phone Development Environment. Now how to make use of these tasks in your app,I leave this for you to decide,Let me know if you need any help using this and also let me know your feedback.I hope you will enjoy this small post after a long time here. Now since I am bit relax from work schedule so I will be back soon with some more interesting posts on Windows Phone, WinRT and Silverlight soon.So keep visiting this place now.

Vikram.

Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Posted in | No comments
Newer Post Older Post Home

0 comments:

Post a Comment

Subscribe to: Post Comments (Atom)

Popular Posts

  • First Windows Phone 7 update February 2011 - Small update but Big start
    After tons of rumors and set of predictions on Windows Phone 7 all over Internet, Microsoft came up with first Windows Phone 7 minor update ...
  • The little Story of “I Unlock Joy” event by Microsoft and Pune User Group
      This post is about recent “I Unlock Joy” event happened in Pune which was conducted by Microsoft and Pune User Group. Little History : ...
  • Silverlight On Mobile : Windows Phone 7 Splash Screen and Customization
    After talking about 3D capabilities on Windows Phone 7 using Silverlight in last article , Now I am moving ahead with small but equally impo...
  • Silverlight 5 : Platform Invoke (PInvoke) in Silverlight
      Two days back Microsoft announced availability of Silverlight 5 RC,I encourage you to download bits from here , My friend Pete Brown alr...
  • Introduction to Speech Capabilities in Windows Phone 8 – Part 1
    After a long..I am writing blog, I hope and I wish I will resume blogging like I use to in past. Lots of things happened in past few months....
  • MCTS : Microsoft Silverlight 4 Development Exam Guide (70-506) by Packt Publishing
      Hello, After a long time I got chance to come back here.I will soon resume blogging in month of August. Last 4-5 months were horrible due...
  • Introduction to Speech Capabilities in Windows Phone 8 – Part 2
    Hope you enjoyed my last article on Speech Capability in Windows Phone 8, Today I am posting another part or you can say little extension t...
  • Silverlight 3 : Insert & Update Data using WCF Service with DataForm and DataGrid
    In my Lap around Silverlight 3 series, I have written a separate article on DataForm in Silverlight 3, This article is a basic extension to ...
  • Mango : Using DeviceStatus in Windows Phone 7.1
    First of all “Thank You” for your wonderful response and comments on my last article on Silverlight Vs HTML5 ,I hope you like the points I ...
  • Silverlight, HTML5 & Windows 8 : Where we are heading to ?
    This is not the post or yet another post on most happening debate of Silverlight and HTML5, This is just a visit to all of them to realize t...

Blog Archive

  • ►  2013 (4)
    • ►  August (1)
    • ►  April (3)
  • ▼  2012 (4)
    • ►  July (1)
    • ►  March (2)
    • ▼  January (1)
      • Share Status and Link on Socials in Windows Phone
  • ►  2011 (24)
    • ►  December (1)
    • ►  September (4)
    • ►  August (2)
    • ►  July (1)
    • ►  June (4)
    • ►  May (3)
    • ►  April (3)
    • ►  March (1)
    • ►  February (4)
    • ►  January (1)
  • ►  2010 (21)
    • ►  December (1)
    • ►  November (2)
    • ►  October (3)
    • ►  September (2)
    • ►  August (4)
    • ►  July (5)
    • ►  May (1)
    • ►  April (1)
    • ►  March (1)
    • ►  January (1)
  • ►  2009 (49)
    • ►  December (1)
    • ►  November (5)
    • ►  October (2)
    • ►  September (1)
    • ►  August (5)
    • ►  July (5)
    • ►  June (1)
    • ►  May (5)
    • ►  April (5)
    • ►  March (9)
    • ►  February (4)
    • ►  January (6)
  • ►  2008 (43)
    • ►  December (3)
    • ►  November (9)
    • ►  October (7)
    • ►  September (4)
    • ►  August (2)
    • ►  July (3)
    • ►  June (4)
    • ►  May (3)
    • ►  March (3)
    • ►  February (5)
Powered by Blogger.

About Me

Unknown
View my complete profile