Pages

Showing posts with label Windows Phone. Show all posts
Showing posts with label Windows Phone. Show all posts

Wednesday, October 19, 2011

Windows Phone Roadshow 2011 (Valladolid, Spain)

Yesterday I left my MacBook Pro and the new XCode 4.2 to refresh my .Net for Windows Phone 7, which I'm alternating with Objective-C now, for going to the event organized by Microsoft Innovation Center Mobility Solutions (AKA CIM): Windows Phone Mango Roadshow 2011.

The even took place at Boecillo (Valladolid) and there was more than a hundred people to hear about this new mobile operating system by Eduardo Ortega, Jose Antonio Gallego (our Five Flames blog mate expert in WP7) from CIM and Isabel Gomez from Microsoft Ibérica.

This event is oriented to developers (obviously) and UI/UX designers too, excepting the Key Note and the Introduction to Windows Phone session that was oriented for all publics.

The keynote was presented by Isabel and Eduardo and talks about Windows Phone, its evolution to Mango, and the main improvements that this new version of the OS bring us.

After key note, Eduardo and Jose Antonio gives an introduction about programming for Windows Phone 7 both Silverlight Applications and XNA Games technologies with a little demo for each one. The use of Microsoft Blend studio for designing a rich UI/UX interface like a Flash app and how it's integrated with Visual Studio was awesome for most of the people who saw that create rich visual experiences was easier in Windows Phone 7 than other platforms.

Next session, also by Eduardo and Jose Antonio, talks about data access with SQL Server CE, accesing to web services and the new feature of WP7: Live Tiles. A "widget" like tile attached to an application in which you can show updated content.

In the break after this session the event organizers give us a free brunch for our hungry stomach and afterwards Eduardo Ortega talk us about Windows Phone advanced capabilities included in Mango: gyroscope, compass, accelerometer, camera and augmented reality with GART which could be used or implemented in a Windows Phone app/game with only a few lines of code.

After lunch Eduardo's session talks about multitasking in Windows Phone and the features asociated to this functionality: Tombstoning, dormant, background Agents and Fast Application Switch and how to use it from code.

Next to a little break that prepared us to final sessions Jose Antonio developed from start to end a complete app named "ZombSquare" in which was included every features seem in this event: Silverlight, XNA, 3D Models, Sensors, Data Access and Augmented Reality. The code of this app will be uploaded to codeplex after the Roadshow in order that atendees could experiment by themselves.

The final session, by Jose Antonio and Isabel, talks about uploading apps to Microsoft Marketplace, ROI, promoting apps and everthing useful to obtain cash for publishing our apps and games.

At last, there was a little contest in which Microsoft gives 5 Silverlight books by Josué Yeray and 5 Windows Phone mobile devices.

Globaly this event was very dinamic and the speakers answer people's questions at every moment. I highly recommended you this event for every developer/designer but expecially if you have previous knowledge in .Net technologies there will be very easy that you could begin programming for mobile phones.

The next places and dates that Windows Phone Roadshow 2001 will take place are:

I hope there will be new devices by Nokia and other manufactures for this Chrismats so this technology could grow up.

Monday, October 17, 2011

[How To] Get Device Unique Id in Windows Phone

To Get the device unique ID you need to first declare in the WMAppManifest.xml file this capability ID_CAP_IDENTITY_DEVICE.

You can use this ID to indentify one device (count unique users, send custom notifications, etc)

In code to get this Id you only need to do this:

public static byte[] GetDeviceUniqueID()
{
byte[] res = null;
object uniqueId;
if (DeviceExtendedProperties.TryGetValue("DeviceUniqueId", out uniqueId))
{
res = (byte[])uniqueId;
}
return res;
}

Enjoy it!

Monday, October 10, 2011

[How to] Share links and status in Twitter, Facebook, linkedIN…

This post do not need any explanation :)

Microsoft.Phone.Tasks.ShareLinkTask shareLinks = new
Microsoft.Phone.Tasks.ShareLinkTask();
shareLinks.LinkUri = new Uri("http://www.fiveflamesmobile.com");
shareLinks.Message = "Try ShareLinkTask in Windows Phone";
shareLinks.Title = "Share Link Task Sample";
shareLinks.Show();


To update your status:
Microsoft.Phone.Task.ShareStatusTask status = Microsoft.Phone.Task.ShareStatusTask();
status.Status = Try ShareStatusTask in Windows Phone";
status.Show();

enjoy it!

Thursday, September 8, 2011

[iOS2WP7] From iOS to Windows Phone. Introduction

From now we're going to alternate the blog's updates between Code Snippets and iOS to Windows Phone migration tips for whose that want to migrate this iOS applications and games to this new mobile OS.

iOS is a huge and very stable platform and iPhone is most sold device from all over the times, so there are thousands and thousand of applications and games in the AppStore. A lot of these games and applications are very useful or adictive (see Angry Birds for example) and Windows Phone users are waiting to have it in their phones so it's a good idea to migrate them, and now it could be a good moment to start.

Windows Phone is a very young OS for mobile devices, and being realistic there aren't so much available devices in the market so you could think "Why should I have to migrate my apps/games for that little potencial market?" Let's see a few good answers.

- Growing trend. Now there aren't a lot of devices running Windows Phone, but for Christmas campaign some manufacturers like Nokia (waiting for them...) HTC (Radar and Titan last ones) Samsung... are going to launch their last models including Windows Phone 7 Mango, so it seems that the potential number of users of your apps/games is going to growht.

- Positioning. Your app/games uploaded to Marketplace have less competence that another platforms like Android Market or AppStore so it's easier to have a better rating and visibility. If your app is the first to do something it will be a reference for Windows Phone users.

- Knowledgment: Maybe there are not much market to attack, but if you adquire the knowledment to migrate iOS apps/games to Windows Phone now, you will be one step beyond the competence if this platform begins to growth.

- Easy to develop: If you are a iOS developer, programming for windows phone is much easier than do it for iOS. I'm doing both things and believe me, it's easier.

- Facilities: Visual Studio for Mobile Development is free for developers, Microsoft developer license for one year has the same cost as iOS one...

- Lack of fragmentation. Like iOS, Windows Phone has fixed characteristics so you haven't to get crazy with differentes screen resolutions, different ROMs, different OS...

If after reading this article, you are convinced to migrate your apps, don't forgot this blog. We're going to publish coding tips, examples with both C# and Objective-C code for comparing, and a serie of articles to help you to accomplish this task.

For fist reading have a look to this guide published by Microsoft: Windows Phone 7 Guide for iPhone Application Developers

And the first link to have under Five Flames Mobile Blog ;) :Windows Phone Interoperability Bridges

Enjoy it!

Monday, September 5, 2011

[HOW TO] Intercept javascript events with Windows Phone WebBrower control

If you need intercept javascript events in Windows Phone web browser control, you must use the ScriptNotify event. This event is launched when the window.external.Notify() function is called from javascript code.

First you must enable IsScriptEnabled property.

IsScriptEnabled

Second, you must handle the ScriptNotify event, you could make this from xaml code or from code behind, as you prefer.

webBrowser1.ScriptNotify+=new EventHandler<NotifyEventArgs>(webBrowser1_ScriptNotify);

EventScript

HTML Example:

<html>
<head> 
    <title>Demo Windows Phone</title>
    <script type="text/javascript">
function SendNotify() { window.external.Notify(‘demo’); }
</script>
</head>
<body>
    <div>
        <input type="button" value="Notify" onClick="SendNotify()"/>
    </div>
</body>
</html>

You can load this html code with NavigateToString function from WebBrowser control.

private void webBrowser_ScriptNotify(object sender, NotifyEventArgs e)
{
    if (e.Value == "demo")
    {
        MessageBox.Show(e.Value);
    }
}

Note: You can call javascritp functions from c# code, using InvokeScript method.

Monday, August 29, 2011

[How To] Disable Pivot swipe gesture in Windows Phone

If you need to disable Pivot gestures in WP7 you only need use the IsHitTestVisible  property. This property gets or sets a value that declares whether this element can possibly be returned as a hit test result from some portion of its rendered content.

If you set to true the contained area of this control can be used for hit-testing,
If set this property to false the control will not report any event when the user manipulate it.

In code, you only need mark the IsHitTestVisible property to false.

pivotControl1.IsHitTestVisible = false;

Remember that this action is not a recomended practice in Windows Phone.

Tuesday, August 23, 2011

Windows Phone SDK 7.1 Release Candidate

The Windows Phone Software Development Kit (SDK) 7.1 provides you with all of the tools that you need to develop applications and games for both Windows Phone 7.0 and Windows Phone 7.5 devices. This download is the Release Candidate (RC) and provides a ‘Go Live’ license that enables you to develop and publish applications to the Windows Phone Marketplace.

The Windows Phone SDK includes the following

  • Windows Phone SDK 7.1 (RC)
  • Windows Phone Emulator (RC)
  • Windows Phone SDK 7.1 Assemblies (RC)
  • Silverlight 4 SDK and DRT
  • Windows Phone SDK 7.1 Extensions for XNA Game Studio 4.0
  • Microsoft Expression Blend SDK for Windows Phone 7
  • Microsoft Expression Blend SDK for Windows Phone OS 7.1
  • WCF Data Services Client for Window Phone
  • Microsoft Advertising SDK for Windows Phone

 

You can download this tools here: Windows Phone SDK 7.1 RC

Monday, August 22, 2011

[How To] Scroll a ListView from code

Scroll a ListView from code, sometimes could be a headache, but you only need do this in the next way.

public MainPage()
{
    InitializeComponent();
    miListBox.Loaded += new RoutedEventHandler(miListBox_Loaded);
}

void miListBox_Loaded(object sender, RoutedEventArgs e)
{
    miListBox.SelectedIndex = 14;

    miListBox.ScrollIntoView(miListBox.SelectedItem);
}

The key of this Tip is that you must call ScrollIntoView Metod after loading ListView control.

 

Regards!

Monday, August 15, 2011

[How to] Discover User Agent in Windows Phone

As you know, we can recover the UserAgent from web browser using javascript, specifically using the navigator object. With this object we can see the platform version, user agent and other properties of our browser, in this case we will use the navigator.userAgent property.

Windows Phone do not allow us exec javascript in native mode, but we can do this inside a WebBrowser control, for this, you can follow these setps:

1) Add a WebBrowser control to our PhoneApplication page.
2) Using the function NavigateToString to load the script,  you can see the script in the example showed below.
3) Finally we intercept the ScriptNotify event from WebBowser control and we will process and store the value in the IsolatedStorage for when we need.

Declare a WebBroser control.

private WebBrowser webBrowserControl;

In the constructor of our PhoneApplicationPage, instance and add the control.

        public ManiPage()
        { 
            (…) 
            control.Loaded += new RoutedEventHandler(webBrowserControl_Loaded);

            webBrowserControl = new WebBrowser();
            webBrowserControl.IsScriptEnabled = true;
            webBrowserControl.Visibility = System.Windows.Visibility.Collapsed;
            webBrowserControl.ScriptNotify += new EventHandler<NotifyEventArgs>(webBrowserControl_ScriptNotify);
            contentPanel.Children.Add(webBrowserControl);
        }

When the WebBrowser control is loaded completely, we will load the scritp using NavigateToString function.

        void webBrowserControl_Loaded(object sender, RoutedEventArgs e)
        {
            string html = @"<!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.01 Transitional//EN"">
                <html>
                <head>
                <script language=""JavaScript"" type=""text/JavaScript"">
                function getUserAgent() {
                    window.external.notify(navigator.userAgent);
                }
                </script>
                </head>
                <body onload=""getUserAgent();""></body>
                </html>";

            webBrowserControl.NavigateToString(html);
        }

Finally process the ScriptNotifi event and recover the UserAgent value. The format of UserAgent looks like this (in this case the User Agent of a Windows Phone Emulator)

Mozilla/4.0 (compatible; MSIE 7.0; Windows Phone OS 7.0; Trident/3.1; IEMobile/7.0; Microsoft; XDeviceEmulator)

void webBrowserControl_ScriptNotify(object sender, NotifyEventArgs e)
{ 
    _userAgent = e.Value;  
    System.IO.IsolatedStorage.IsolatedStorageSettings.ApplicationSettings["UserAgent"] = _userAgent;

    if (UserAgentChanged != null)
    {
        UserAgentChanged(e.Value, new EventArgs());
    }
}

NOTE: If you want to recover this value later, you can do this:

string userAgent;
System.IO.IsolatedStorage.IsolatedStorageSettings.ApplicationSettings.TryGetValue<string>("UserAgent", out userAgent);

Sunday, May 15, 2011

[WindowsPhone-Game] Race

Continuing with the retro games serie for Windows Phone, this game tries to recreate that old arcade machine in which you are a driver who has to avoid those kamikaze cars that comes against you (or maybe we are the kamikaze) moving to the left or to the right, and pick up the girl that appears near the road's border.
Developed with XNA Framework for Windows Phone 7 this game is only available at Microsoft Marketplace, and maybe will be available soon for iPhone at appStore.

Name: Race
Language: N/A
Category: Game
Cost: 0,99$ / 0,79 €

Wednesday, April 13, 2011

[WindowsPhone-Game] Oil Station

Do you remember pre-mobiles era? Do you remember that little retro arcade machines, with two buttons for left and right moves, select game mode and start? That was grandpa's modern mobile games and consoles, and why not use it in a modern device like Windows Phone?
This game is a replica of oldest one in which you are an gas station worker who has to keep the floor clean of oil. Pick up oil drops and carry them to the barrel to avoid spill them.

Available for free at Zune for Windows Phone, we expect you enjoy a great time remembering youngest time.

Name: OilStation
Language: N/A
Category: Games
Cost: FREE