-1
브로드 캐스트 리시버가 연결 변경을 위해 작동하지만 안드로이드 N에서 작동하지 않는 모든 장치에서 제대로 작동하지만 안드로이드 N에서 작동하지 않습니다. N에있는 것 또는 아닙니다. 왜 이런 일이 일어나는 지 아는 사람이 있습니까?Netwakeork 브로드 캐스트 리시버가 안드로이드 N에서 작동하지 않음 N
매니페스트 파일
다음<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.admin.movies">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:name=".MovieSingleton"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".SplashActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver
android:name=".NetworkBroadcastReceiver"
android:exported="false"
android:enabled="true">
<intent-filter>
<action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
</intent-filter>
</receiver>
</application>
내 방송 수신기
public class NetworkBroadcastReceiver extends BroadcastReceiver {
private static final String TAG = NetworkBroadcastReceiver.class.getSimpleName();
public NetworkBroadcastReceiver() {
}
@Override
public void onReceive(Context context, Intent intent) {
Log.d(TAG, "onReceive: network change");
if(isOnline(context)){
Log.d(TAG, "onReceive: connected");
} else {
Log.d(TAG, "onReceive: not connected");
}
}
public boolean isOnline(Context mContext) {
ConnectivityManager connMgr = (ConnectivityManager)
mContext.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo networkInfo = connMgr.getActiveNetworkInfo();
return (networkInfo != null && networkInfo.isConnected());
}
}
https://developer.android.com/topic/performance/background-optimization.html 및 https://developer.android.com/about/versions/nougat/android-7.0-changes.html#bg-opt – CommonsWare