Posts Tagged ‘ WP7 ’

The VibrateController Class

I am currently working on another Windows Phone Application, where I needed a way to show the user that they had successfully performed a task and therefore unlocked another feature inside the application.

First idea was adding some sound, but somehow I was not happy with that. So I thought, why not let the phone vibrate?

It’s actually not that hard. The Windows Phone 7 SDK allows me to control the vibrate function easily.

In the namespace Microsoft.Devices there is a class defined with the name ‘VibrateController’.

The only code I need for that function is:

When the user clicks the particular button, the phone vibrates.

A few thoughts to keep in mind:

1. the shortest vibration / pause is 0.1 seconds.

2. the longest is 5 seconds, but that is not recommended.

3. 3 vibrations in one sequence are enough.

4. 0.2 / 0.3 are good choices for an alert.

 

Here you can find more information about the VibrateController Class.

 

To be continued…

Advertisement

Creating an Alarm Application

I don’t have a kitchen timer, but who cares? I have a Windows Phone, right? So I just created a little Alarm application to compensate for missing kitchen equipment.

It is a very simple application that has a TextBlock (for instructions), a TextBox, where I can set the alarm (I chose to set that in seconds), and two buttons. One for setting the alarm, the other one for resetting it:

By clicking the ‘Set Alarm’ Button I set the alarm. A method called ‘CreateAlarm’ will be created. This method will create the instance of the alarm by passing a name to the constructor. I am also going to add a little alarm message:

“ScheduledActionService.Add(alarm)” will let the alarm go off when the application has been closed. It will execute in the background.

Works as expected. I just have to make sure to press the ‘Reset Alarm’ Button after an alarm went off, to prevent it from crashing. I am sure there is room for improvement, but for now, I am happy with that.

 

To be continued…

 

Add Ads to your App

Why ads to begin with?

I have a few apps in the Marketplace that can be purchased. The average end user though is not going to purchase anything that they haven’t tested. Therefore it makes sense to have a trial version of the app. The trial version usually has some limitations. Either you limit the functionality of the app, or, like I am doing in my apps, the trial version is ad-driven.

To add ads to your Windows Phone App you just need to follow a few steps.

1. Make sure you have the latest tools. You can find them here.

Although that ships with the Advertising SDK, it is recommended to download the latest version of the Advertising SDK as well.

2. Add a Reference:

Since I am developing my apps in Silverlight, this is the one I need.

3. In the root element of my XAML file I need to add this:

In the Layout root of my XAML file I create my AdControl:

Of all the properties of the AdControl, ApplicationId and AdUnitId are the most critical. The example uses special values intended for testing. Let’s see how that looks:

Even though the SDK lists several different sizes for supported ads, only two have test images, that you specify through the AdUnitId property. For a 480×80 image, I use Image480_80 and for a 300×50 image, I use Image300_50. For a Windows Phone application it is recommended to use a 480×80 image.

One more property that is important to know is the RotationEnabled property, which by default is set to true. This means that a new ad will periodically and automatically be shown.

4. Get ApplicationId and AdUnitId at the Microsoft Advertising pubCenter. For every application you have ads for, you need to get an application ID. Each application can have multiple ad Units. If you are visiting the pubCenter for the first time, click the ‘Get Started’ button, otherwise sign in.

At the top there are two rows of tabs. First click the ‘Setup’ tab in the first row, and then ‘Sites and Apps’ in the second row. Click ‘Create a new application’:

Now you need to specify a name for your application. With clicking “add”, the Application ID will be assigned.

Once you have that, you can click on ‘Ad Units’ in the second tabs row. Click on ‘Create a new Application Ad Unit’. Now you need to select up to three categories per Ad Unit. This specifies the kinds of ads you want to be shown in your application

5. Now you need to set the assigned values to the ApplicationId and AdUnitId properties of your AdControl.

In order to get real ads, you need to set the static TestMode property to false in the constructor:

Here you can find more information.

 

To be continued…

 

 

 

%d bloggers like this: