Search code examples
javakotlinnetwork-programmingconnection

How can I limit or disable data usage for only my Android app (Kotlin)?


I'm developing an application on Android (Kotlin), I was searching for some help with Network.

How can I limit or disable data usage for only my app, if it's possible, I don't want to make that seen to user.

I'm using the Retrofit library in my app to make network calls so maybe someone would tell me if I can disable retrofit and there won't be any calls?

I don't want to affect other apps for example by disabling wifi or mobile data, I just want to disable or limit for only my app.

I tried to enable/disable wifi or mobile data, but it's not what I wanted. Then I tried to redirect to the settings and let user disable it on its own but it's not still the same.


Solution

  • I just created a value in Shared Preferences and when i try to make a call , i'm checking for it's value and if it's true then i'm in offline mode , if it's false i'm in online mode and making a call .

    it maybe a solution for a first time , but i will appreciate any suggestions.