Unity3d mobile power and WiFi signal acquisition

Source: Internet
Author: User

The inability to see power and WiFi signals in mobile games is a problem for gamers. There are different ways for Android and iOS to do this.Power AndroidThere are two ways to get power on Android, one is to read a file on an Android phone, and it's convenient to use Android to send messages to unity, but we don't guarantee that the vendor will change the file to another location and we won't be reading it.
    • Method One
Reference: Http://www.cnblogs.com/BobbyWeaver/p/5118118.html read the files in the Android phone, the code is as follows:
int Getbatterylevel ()      {          try          {              string capacitystring = System.IO.File.ReadAllText ("/sys/class/power _supply/battery/capacity ");              return int. Parse (capacitystring);          }          catch (Exception e)          {              Debug.Log ("Failed to read battery power;" + e.message);          }          return-1;      }  }  


    • Method Two
The way you interact with Android, it's not just about getting power, WiFi, controlling phone shake, restarting, calling third-party apps, and so on. Android features reference: http://www.cnblogs.com/wuzhang/p/wuzhang20170318.htmlIOSA workaround on the forum is to use a. mm file to write a method to get iOS power using the same way as iOS, and the pro-Test available reference: https://forum.unity3d.com/threads/ Display-battery-level-in-game.67804/the method for calling the iOS library can be consulted: http://blog.sina.com.cn/s/blog_923fdd9b0102v2a8.htmlWiFiMethod an Android and iOS both use the above platform to interact with Unity method method two clients and the server sends the heartbeat packet the way to simulate.by:wolf96 2017/7/8

Unity3d mobile power and WiFi signal acquisition

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.