0

它是我的应用程序类 ==>

@Override
public void onCreate() {
    super.onCreate();
    mydRef = FirebaseDatabase.getInstance().getReference();
    tipDondur();
}

public static Context context() {
    return app.getApplicationContext();
}

public boolean internetAktif() {
    final ConnectivityManager connectivityManager = ((ConnectivityManager) app
            .getApplicationContext()
            .getSystemService(Context.CONNECTIVITY_SERVICE));
    return connectivityManager.getActiveNetworkInfo() != null &&
            connectivityManager.getActiveNetworkInfo().isConnected();
}

当从其他类调用 internetAktif 函数时 ==>

    App app = (App) getApplicationContext();
    Log.d("", "İnternet durum: " + app.internetAktif());

发送错误 ==>

引起:com.example.ercana.yemekevdefb.Splash.onCreate(Splash.java:31) 的 com.example.ercana.yemekevdefb.App.internetAktif(App.java:38) 的 java.lang.NullPointerException

这是什么意思?我如何解决这个问题?

4

0 回答 0