Currently, it is faster to watch videos over a wired connection than to go through a vro and use wireless connection as a hotspot. However, after setting a hotspot in a wireless connection, you have to turn on the hotspot again after shutdown or restarting, Which is troublesome, it is more convenient to add a self-starting hot spot on startup. Other devices can access the Internet through the box even if the network speed is fast and the video is not card.
Development Tools
Android ADT
Implementation Method
1. Enable hotspot
2. boot
Code
1. Enable hotspot
WifiManager wifiManager; wifiManager = (WifiManager) getSystemService (Context. WIFI_SERVICE); Method method = wifiManager. getClass (). getMethod ("getWifiApState"); int state = (Integer) method. invoke (wifiManager); if (state = 13 | state = 12) // has been opened or is being opened {} else {Toast. makeText (MainActivity. this, "AndroidAP is being enabled... ", 1 ). show (); wifiManager. setWifiEnabled (false); WifiConfiguration apConfig = new WifiConfiguration (); apConfig. SSID = "AndroidAP"; apConfig. allowedKeyManagement. set (4); apConfig. preSharedKey = "5e8918f37260"; method = wifiManager. getClass (). getMethod ("setWifiApEnabled", WifiConfiguration. class, Boolean. TYPE); boolean open = (Boolean) method. invoke (wifiManager, apConfig, true );}
Add permissions to AndroidManifest. xml
<Uses-permissionandroid: name = "android. permission. CHANGE_WIFI_STATE"> </uses-permission>
<Uses-permissionandroid: name = "android. permission. ACCESS_WIFI_STATE"> </uses-permission>
2. boot
Used
<Actionandroid: name = "android. intent. action. BOOT_COMPLETED"/>
<Uses-permission android: name = "android. permission. RECEIVE_BOOT_COMPLETED"> </uses-permission>
I tried it on my TV box and found that sometimes the system will not run automatically when it is turned on.
Change your mind
Use
<Categoryandroid: name = "android. intent. category. HOME"/>
Replace the desktop that comes with the TV box
Enable the AP hotspot and then automatically run the desktop in the box
ComponentName componet = new ComponentName("com.duokan.duokantv","com.duokan.duokantv.MainActivity"); Intent i = new Intent(); i.setComponent(componet); startActivity(i);
Usage
1. cable networks connected to TV boxes
2. Configure the box for normal Internet access
3. install your own program
Source: http://blog.csdn.net/xiaoxiao108
About the author: cainiao. If you have any questions or suggestions, please kindly advise me!
You are welcome to repost the statement, but this statement must be retained without the author's consent, and the original article connection is clearly provided on the article page.