...
https://developer.android.com/training/basics/network-ops/data-saver.html
ConnectivityManager connMgr = (ConnectivityManager)
getSystemService(Context.CONNECTIVITY_SERVICE);
// Checks if the device is on a metered network
if (connMgr.isActiveNetworkMetered()) {
// Checks user’s Data Saver settings.
switch (connMgr.getRestrictBackgroundStatus()) {
case RESTRICT_BACKGROUND_STATUS_ENABLED:
// Background data usage is blocked for this app. Wherever possible,
// the app should also use less data in the foreground.
case RESTRICT_BACKGROUND_STATUS_WHITELISTED:
// The app is whitelisted. Wherever possible,
// the app should use less data in the foreground and background.
case RESTRICT_BACKGROUND_STATUS_DISABLED:
// Data Saver is disabled. Since the device is connected to a
// metered network, the app should use less data wherever possible.
}
} else {
// The device is not on a metered network.
// Use data as required to perform syncs, downloads, and updates.
}
データセーバー環境設定の変更を監視する Appsは、データセーバー環境設定の変更を監視するには、BroadcastReceiver ConnectivityManager.ACTION_RESTRICT_BACKGROUND_CHANGEDをリッスンし、Context.registerReceiver()で受信者を動的に登録します。アプリがこのブロードキャストを受信すると、新しいData Saver環境設定がConnectivityManager.getRestrictBackgroundStatus()を呼び出してそのアクセス許可に影響するかどうかを確認する必要があります。
注:このブロードキャストは、Context.registerReceiver()で動的に登録するアプリケーションにのみ送信されます。マニフェストでこのブロードキャストを受信するために登録するアプリは受信しません。
がこの解決策を見つけましたか? –
また、携帯電話全体または自分のアプリだけのバックグラウンドデータが無効になっているかどうかを確認するにはどうすればよいですか? – Zapnologica