Chinaunix首页 | 论坛 | 博客
  • 博客访问: 5412232
  • 博文数量: 763
  • 博客积分: 12108
  • 博客等级: 上将
  • 技术积分: 15717
  • 用 户 组: 普通用户
  • 注册时间: 2007-09-28 21:21
个人简介

业精于勤,荒于嬉

文章分类

全部博文(763)

文章存档

2018年(6)

2017年(15)

2016年(2)

2015年(31)

2014年(14)

2013年(87)

2012年(75)

2011年(94)

2010年(190)

2009年(38)

2008年(183)

2007年(28)

分类: Java

2014-11-11 15:37:51


  1. //返回设备唯一的 id
  2.     public static String J_C_getIosDeviceId()
  3.     {
  4.         String android_id = Secure.getString(getContext().getContentResolver(), Secure.ANDROID_ID);
  5.         return android_id;
  6.     }
  7.     //判断当前是否有可用网络
  8.     public static boolean J_C_isNetworkOK()
  9.     {
  10.         //获取当前的网络连接服务
  11.         
  12.         try {
  13.             ConnectivityManager connectivity = (ConnectivityManager) getContext().getSystemService(Context.CONNECTIVITY_SERVICE);
  14.             if (connectivity != null) {

  15.                 NetworkInfo info = connectivity.getActiveNetworkInfo();
  16.                 if (info != null && info.isConnected()) {

  17.                     if (info.getState() == NetworkInfo.State.CONNECTED) {
  18.                         return true;
  19.                     }
  20.                 }
  21.             }
  22.         } catch (Exception e) {
  23.             return false;
  24.         }
  25.         return false;
  26.         
  27.     }
  28.     
  29.     //打开url
  30.     public static void J_C_toOpenNetworkURL(String url)
  31.     {
  32.          Uri uri = Uri.parse(url);
  33.           Intent it = new Intent(Intent.ACTION_VIEW, uri);
  34.           getContext().startActivity(it);
  35.     }


对应 ios DeviceId 代码参考:

//获得临时的UUID

std::string getIosDeviceId()

{

    std::string m_str;

    NSString* idStr = [OpenUDID value];  //

    m_str = [idStr UTF8String];

    return m_str;

    

}



阅读(13294) | 评论(0) | 转发(1) |
给主人留下些什么吧!~~