Blue Theme Orange Theme Green Theme Red Theme
 
Team Foundation Server Hosting
Home | Forums | ASP.NET 2.0 Tutorials | Web Services | How Do I...? | Class Browser | WPF Quick Starts | Advertise with Us
 | Consulting  
Submit an Article Submit a Blog 
 Jump to
Skip Navigation Links
TechnologyExpand Technology
WebsiteExpand Website
Team Foundation Server Hosting
Search :       Advanced Search »
Home » Mobile and Embedded » Catch Hold of Device Capability

Catch Hold of Device Capability

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

Author Rank :
Page Views : 1928
Downloads : 0
Rating :
 Rate it
Level : Intermediate
   Print Read/Post comments Post a comment  Similar Articles  
   Email to a friend  Bookmark  Author's other articles  
 
6 Months Free & No Setup Fees ASP.NET Hosting!
Become a Sponsor
 Tag Cloud
 Latest Jobs
More ... 
 Latest Interview Questions
More ... 

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.

Comment Request!
Thank you for reading this post. Please post your feedback, question, or comments about this post Here.
Login to add your contents and source code to this article
 [Top] Rate this article
 
 About the author
 
Shivani
Shivani is Electronics graduate from REC Bhopal, INDIA. After Electronics she jumped to software development and has been dealing with WAP and Java technologies. Currently she is working with C# and ASP.NET for a transaction Portal.
Looking for C# Consulting?
C# Consulting is founded in 2002 by the founders of C# Corner. Unlike a traditional consulting company, our consultants are well-known experts in .NET and many of them are MVPs, authors, and trainers. We specialize in Microsoft .NET development and utilize Agile Development and Extreme Programming practices to provide fast pace quick turnaround results. Our software development model is a mix of Agile Development, traditional SDLC, and Waterfall models.
Click here to learn more about C# Consulting.
 
Introducing MaxV - one click. infinite control. Hyper-V Hosting from MaximumASP.
Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
Dynamic PDF
ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications.
Nevron Chart for .NET 2010.1 Now Available
The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
ASP.NET 4 Hosting
Get 2 Months Free of ASP.NET Hosting for Only $4.95/month! Receive FREE MS SQL and MySQL Databases Including ASP.NET 4/3.5, MVC 3.0, Silverlight 4, Windows 2008/IIS 7.0 Plus FREE IIS 7 Modules. Host UNLIMITED ASP.NET Web Sites – Click Here!
 
 Post a Feedback, Comment, or Question about this article
Subject:
Comment:
Team Foundation Server Hosting
Become a Sponsor
 Comments
Team Foundation Server Hosting
 © 2012  contents copyright of their authors. Rest everything copyright Mindcracker. All rights reserved.