WAP之家:为您提供最全最新的WAP技术,CP.SP.3G等行业资讯。 WAP之家交流论坛全新开放 点击进入>>
WAP资讯 | 3G动态 | SP动态 | 运营商动态 | 内容商动态 | 制造商动态 | 论坛讨论>> 每次自动访问
WAP技术 | WAP源码 | 手机编程 | 手机源码 | 无线技术 | J2ME技术 | 手机软件 添加到收藏夹
IVR技术 | SP资料 | SMS MMS技术 | 商业方案 | IVR下载 | 书籍教程 | 工具软件 语言:繁體中文

WAP之家技术文章J2ME技术程序开发识别访问手机的能力

识别访问手机的能力
作者:佚名  来源:本站整理  发布时间:2008-2-11 11:26:16

概念
    我们通过以下代码可以获取手机的能力,从而针对不同能力的手机做出显示彩色还是黑白色的图片,显示的字体是否可以为彩色等等。
 
还可以进一步通过System.Web.Mobile.MobileCapabilities 的成员函数

System.Boolean HasCapability ( System.String delegateName , System.String optionalParameter )来查询手机是否支持某一特性,代码如下:

bool bHasWBMP =                
   ((MobileCapabilities)Request.Browser).HasCapability("PreferredImageMime", "image/vnd.wap.wbmp");
log.Info("Has WBMP?" + bHasWBMP.ToString());

还可以进一步通过System.Web.Mobile.MobileCapabilities 的成员函数


System.Boolean HasCapability ( System.String delegateName , System.String optionalParameter )来查询手机是否支持某一特性,代码如下:

bool bHasWBMP =                
   ((MobileCapabilities)Request.Browser).HasCapability("PreferredImageMime", "image/vnd.wap.wbmp");
log.Info("Has WBMP?" + bHasWBMP.ToString());
MobileCapabilities Codes
在asp.net页面中安排如下代码即可通过log4net打印出手机的MobileCapabilities:
代码: 
private void Page_Load(object sender, System.EventArgs e)
{  
    if(!IsPostBack)
    {
       log.Info("-============ 输出MobileCapabilities Begin ==============-");
       Type myType =(typeof(System.Web.Mobile.MobileCapabilities));
       System.Reflection.PropertyInfo[] myPropertyInfo =
       myType.GetProperties(System.Reflection.BindingFlags.Public|System.Reflection.BindingFlags.Instance);
       DisplayPropertyInfo(myType, myPropertyInfo);
       log.Info("-============ 输出MobileCapabilities End ==============-");
    }
。。。}

void DisplayPropertyInfo(Type t,System.Reflection.PropertyInfo[] myPropertyInfo)
{
    // Display information for all properties.

   System.Web.Mobile.MobileCapabilities m=( System.Web.Mobile.MobileCapabilities)Request.Browser;
   for(int i=0;i<myPropertyInfo.Length;i++)
  {
      Object result=new Object();
      System.Reflection.PropertyInfo myPropInfo = (System.Reflection.PropertyInfo)myPropertyInfo[i];
      try
      {
           result = t.InvokeMember (myPropInfo.Name,         System.Reflection.BindingFlags.GetProperty|System.Reflection.BindingFlags.GetField, null, m, new object [] {});
      }
      catch (System.MissingMethodException e)
     {
          result =e.Message;
     }
     log.Info ("[" + myPropInfo.Name+ " ]:<" + result+">");
  }
}

下面日志对应的手机型号是

Nokia7610/2.0 (4.0424.4ch) SymbianOS/7.0s Series60/2.1 Profile/MIDP-2.0 Configuration/CLDC-1.0
 输出的日志如下:
 
- -============ 输出MobileCapabilities Begin ==============-
 - [MobileDeviceManufacturer ]:<Nokia>
 - [MobileDeviceModel ]:<Unknown>
 - [GatewayVersion ]:<Nokia WAP Gateway 4.0/CD3/4.0.04)>
 - [GatewayMajorVersion ]:<4>
 - [GatewayMinorVersion ]:<0>
 - [PreferredRenderingType ]:<wml11>
 - [PreferredRenderingMime ]:<text/vnd.wap.wml>
 - [PreferredImageMime ]:<image/vnd.wap.wbmp>
 - [ScreenCharactersWidth ]:<20>
 - [ScreenCharactersHeight ]:<4>
 - [ScreenPixelsWidth ]:<90>
 - [ScreenPixelsHeight ]:<40>
 - [ScreenBitDepth ]:<1>
 - [IsColor ]:<False>
 - [InputType ]:<telephoneKeypad>
 - [NumberOfSoftkeys ]:<2>
 - [MaximumSoftkeyLabelLength ]:<5>
 - [CanInitiateVoiceCall ]:<True>
 - [CanSendMail ]:<False>
 - [HasBackButton ]:<False>
 - [RendersWmlDoAcceptsInline ]:<False>
 - [RendersWmlSelectsAsMenuCards ]:<False>
 - [RendersBreaksAfterWmlAnchor ]:<True>
 - [RendersBreaksAfterWmlInput ]:<True>
 - [RendersBreakBeforeWmlSelectAndInput ]:<False>
 - [RequiresPhoneNumbersAsPlainText ]:<True>
 - [RequiresUrlEncodedPostfieldValues ]:<False>
 - [RequiredMetaTagNameValue ]:<>
 - [RendersBreaksAfterHtmlLists ]:<True>
 - [RequiresUniqueHtmlInputNames ]:<False>
 - [RequiresUniqueHtmlCheckboxNames ]:<False>
 - [SupportsCss ]:<False>
 - [HidesRightAlignedMultiselectScrollbars ]:<False>
 - [IsMobileDevice ]:<True>
 - [RequiresAttributeColonSubstitution ]:<False>
 - [CanRenderOneventAndPrevElementsTogether ]:<False>
 - [CanRenderInputAndSelectElementsTogether ]:<True>
 - [CanRenderAfterInputOrSelectElement ]:<True>
 - [CanRenderPostBackCards ]:<False>
 - [CanRenderMixedSelects ]:<True>
 - [CanCombineFormsInDeck ]:<True>
 - [CanRenderSetvarZeroWithMultiSelectionList ]:<True>
 - [SupportsImageSubmit ]:<False>
 - [RequiresUniqueFilePathSuffix ]:<True>
 - [RequiresNoBreakInFormatting ]:<False>
 - [RequiresLeadingPageBreak ]:<False>
 - [SupportsSelectMultiple ]:<True>
 - [SupportsBold ]:<False>
 - [SupportsItalic ]:<False>
 - [SupportsFontSize ]:<False>
 - [SupportsFontName ]:<False>
 - [SupportsFontColor ]:<True>
 - [SupportsBodyColor ]:<True>
 - [SupportsDivAlign ]:<True>
 - [SupportsDivNoWrap ]:<False>
 - [RequiresContentTypeMetaTag ]:<False>
 - [RequiresDBCSCharacter ]:<False>
 - [RequiresHtmlAdaptiveErrorReporting ]:<False>
 - [RequiresOutputOptimization ]:<False>
 - [SupportsAccesskeyAttribute ]:<False>
 - [SupportsInputIStyle ]:<False>
 - [SupportsInputMode ]:<False>
 - [SupportsIModeSymbols ]:<False>
 - [SupportsJPhoneSymbols ]:<False>
 - [SupportsJPhoneMultiMediaAttributes ]:<False>
 - [MaximumRenderedPageSize ]:<1397>
 - [RequiresSpecialViewStateEncoding ]:<False>
 - [SupportsQueryStringInFormAction ]:<True>
 - [SupportsCacheControlMetaTag ]:<True>
 - [SupportsUncheck ]:<True>
 - [CanRenderEmptySelects ]:<True>
 - [SupportsRedirectWithCookie ]:<True>
 - [SupportsEmpt

[1] [2]  下一页

[] [返回上一页] [打 印]
文章评论

用户名: 查看更多评论

分 值:100分 85分 70分 55分 40分 25分 10分 0分

内 容:

         (注“”为必填内容。) 验证码: 验证码,看不清楚?请点击刷新验证码