Catch Hold of Device Capability

If you are developing Mobile Application and been through the different standards in Market.

If you are developing Mobile Application and been through the different standards in Market. Then you must have known that it's a very tedious job to take account of the capabilities of  all the devices.As a wml browser will be suppoting a .wbmp image (MIMETYPE :-image/vnd.wap.wbmp) while if you are using i-mode browser it is supporting .gif as well as .bmp(restricted with the size of the image).

Even sometimes there is a need to find out that whether the Device support Cookies,What is the Version
of Gateway been used.These all consideration should be there at the time of Mobile Programming. Now there are some easy ways to check that out in .NET Mobile.

Firstly, you can use mobiledevicecapabilities as something like:

<mobiledevicecapabilities>
<
add name="ColorDepth"
class="CapacityEval"
method="CheckColorDepth" />
</
mobiledevicecapabilities>
public class CapacityEval
{
public static bool CheckColorDepth(System.Mobile.MobileCapabilities
capabilities,String depthCheckingAgainst)
{
//Here u can do something like
//taking the Browser Capability if it's there in MobileCapabilities
//or using the HasCapability() to
//Defines properties of the device
//Extends capabilities of the device's dictionary
}
}

Secodly if you don't want to taste and want to give the Content to the user as per his device ContentType
then u can do something like:

<%@ Page Inherits="System.Mobile.UI.MobilePage" Language="cs" %>
<%@ Register TagPrefix="mobile"
Namespace
="System.Mobile.UI" %>
<mobile:Form runat="server" ID="Form1" NAME="Form1">
<
mobile:Image
runat="server"alternateText="JUST TO SHOW U" ID="Image1" NAME="Image1">
<
deviceSelect>
<
choice capability="isColor" argument="true"
value="Arrow.gif"/>
<
choice capability="mimeType" argument="image/vnd.wap.wbmp"
value="hi.wbmp"/>
</
deviceSelect>
</
mobile:Image>
</
mobile:Form>

Here the Device been checked for two properties "isColor" and "mimeType" and as per the output image been given to the device.

Now this is the final One here u can find out that what all properties been supported in the device on using something like Request.Browser

<%@ Page Inherits="System.Mobile.UI.MobilePage" Language="C#" %>
<%@ Register TagPrefix="Mobile"
Namespace
="System.Mobile.UI" %>
<%@ Import
Namespace
="System.ComponentModel" %>
<%@ Import
Namespace
="System.Mobile" %>
<script runat="server" language="c#">
protected void Page_Load(Object sender, EventArgs e)
{
if (!IsPostBack)
{
// Add all property names found in the device capabilities class.
PropertyDescriptorCollection properties = TypeDescriptor.GetProperties
Request.Browser);
if (properties != null)
{
CapabilityList.DataSource = properties;
CapabilityList.DataBind ();
}
}
}
protected void CapabilityList_OnClick(Object sender, ListCommandEventArgs e)
{
String propertyName = e.ListItem.Text;
CapabilityName.Text = propertyName;
CapabilityValue.Text = DataBinder.Eval (Request.Browser, propertyName, "{0}");
ActiveForm = SecondForm;
}
</script>
<
Mobile:Form runat="server" Wrapping="NoWrap" ID="Form1" NAME="Form1">
<
Mobile:Label runat="server" StyleReference="title" Text="Mobile Capabilities"
ID="Label1" NAME="Label1"/>
<
Mobile:List runat="server" id="CapabilityList" DataTextField="Name"
OnItemCommand
="CapabilityList_OnClick" AllowPaging="true" />
</
Mobile:Form>
<
Mobile:Form runat="server" id="SecondForm">
<
Mobile:Label runat="server" id="CapabilityName" StyleReference="title" />
<
Mobile:Label runat="server" id="CapabilityValue" />
</
Mobile:Form>

This will take all the Properties and check the Browser for the existence of that property Even there are some Properties like UniqueDeviceID(Globally Unique) and the DeviceVendor can be known through Request.Browser .So it's easy to design device specific application.