ConnectivityManager.getNetworkInfo() NullPointerException
디바이스 : 태블릿 Galaxy Tab S2 (SM-T813)
OS : Android
OS Version: 7.0
특징 : SM-T815N0 은 괜찮음.
ConnectivityManager connectivityManager = (ConnectivityManager) getActivity().getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo mobile = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);
NetworkInfo wifi = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
Error
Process: com.iofit.tablet, PID: 26117
java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.net.NetworkInfo.isConnected()' on a null object reference
at com.iofit.tablet.ui.fragment.SwingVideoFragment$ProSwingAdapter$2.onClick(SwingVideoFragment.java:952)
at android.view.View.performClick(View.java:6257)
at android.view.View$PerformClick.run(View.java:23705)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6780)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1496)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1386)
도움 블로그 : ababqq.tistory.com
참고 사이트 : https://developer.android.com/training/basics/network-ops/managing.html