1

I am getting a weird issue while testing on multiple devices. I am currently working on a application which uses internet connection for Api calls.

Application tested on 15 different devices & in 12 devices it works perfectly fine.

Only 3 devices its not working are the One plus devices. I tried to investigate the issue & found that it has some issues regarding internet connection. So basically its not allowing to access internet connection.

Efforts :

  • I have already tried to use lots of different solutions but didn't get any proper solution.
  • All permissions settings done perfectly
  • Only it sticks on the One plus devices as per the 15 device testing scenario
  • On that all One plus devices other apps works normally without any issues

Devices I tested on :

  • One plus
  • Moto G
  • Samsung s9
  • MI Note 4, 5
  • Gionee
  • Oppo

Can anyone kindly provide some guidance for resolving this issue.

Edit :

By getting more help from the @ninja I found that it was not actually an device specific issue. But it was an issue with OS 9.0 or above.

So by adding the below Line in manifest file did trick.

<application
....
android:usesCleartextTraffic="true"
...

Thanks in advance.

Phantômaxx
  • 37,352
  • 21
  • 80
  • 110
Mayur
  • 5,212
  • 7
  • 37
  • 65
  • 1
    List your phone models that you tested, it will helped. – nyconing Mar 18 '19 at 10:09
  • @nyconing thanks for suggestion I am editing my question now – Mayur Mar 18 '19 at 10:13
  • 1
    Your listed list isnt even have **model** except Samsung and Mi. For some informations, some apps that rely on device's serial number to identify devices. Might not worked on >=API26, because of [permission is needed](https://developer.android.com/reference/android/os/Build#getSerial()). – nyconing Mar 18 '19 at 10:18
  • 1
    Probably One Plus has a custom Internet permission and your app asks for wrong incorrect one – Matt Mar 18 '19 at 11:06
  • 1
    Hi! Your api is using http or https? And could you add in your device's list the Android version of each device? – Gianluca Benucci Mar 18 '19 at 11:11
  • @Matt but on same one plus if I download other apps it uses internet correctly. Is there any hack in side programming ? – Mayur Mar 18 '19 at 11:26
  • @GianlucaBenucci its HTTP only – Mayur Mar 18 '19 at 11:52
  • 2
    Please add the Android version for each device. The last version of Android (Pie/9) block all HTTP traffic. – Salvatore Cozzubo Mar 18 '19 at 12:39
  • Thank you guys for quick assistance. I got the solution eventually. – Mayur Mar 18 '19 at 12:55

3 Answers3

2

Please check if the device block your app for data usage, under Settings -> Data Usage Control and block check: https://www.quora.com/Can-I-restrict-the-data-access-to-a-particular-app-on-OnePlus-3

if so only work round is app launch check if it can access to Internet(Not just connectivity) if so ask user to allow permission with popup.

you can redirect to setting data usage with (not tested with one plus device actually)

 Intent intent = new Intent();
 intent.setComponent(new ComponentName("com.android.settings","com.android.settings.Settings$DataUsageSummaryActivity"));
 startActivity(intent);
UdayaLakmal
  • 3,775
  • 4
  • 27
  • 40
  • 1
    Appreciated your answer but I found the solution now. Thank you for providing quick support. – Mayur Mar 18 '19 at 12:43
1

By getting more help from the @ninja, I found that it was not actually an device specific issue. But it was an issue with OS 9.0 or above.

So by adding the below Line in manifest file did trick.

<application
....
android:usesCleartextTraffic="true"

Hope it will help everyone.

little
  • 2,857
  • 2
  • 25
  • 36
Mayur
  • 5,212
  • 7
  • 37
  • 65
1

If i am not wrong then that OnePlus mobile device is running on API level 28(Pie). There are so many updates in android Pie OS.

You can check that on developer site that how many changes or behavior changed in Pie. There is one update that in Pie cleartextTraffic is by default false so if you want to enable then you have to add this property in <application> tag.

You can add this one property as below.

<application
....
android:usesCleartextTraffic="true"
....>
....
</application>

For Information you can check this stack overflow question

Ninja
  • 640
  • 9
  • 24