Merab.Ag
Merab.Ag

Reputation: 61

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.

Upvotes: 5

Views: 1051

Answers (1)

Ankur Aggarwal
Ankur Aggarwal

Reputation: 2220

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

Upvotes: 0

Related Questions