简体   繁体   中英

Android 7.1 turn on/off mobile data

I'm writing software that works with some data in internet over cellular data and prints invoice through the WiFi to HP printer using direct print. I'm not using routers or other network devices. so as i know new android 7.1 has a feature that doesn't connects to a network that has no access to the internet. when I disable cellular data it connects to wifi and prints it without any problem.

is there any solution for this situation. so when I connect to wifi without internet it will switch to a wifi no matter what.

I recently answered a similar question, which you can check here

To summarize, you need to implement these:

  1. Network callback for WiFi network.
  2. Request a network using ConnectivityManager.requestNetwork()
  3. Then when callback is received, use Network.openConnection() to make an HTTP request

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM