GetSystemService does not exists in current context.

 private string getInternetConnection()
    {
    string sqldb_message="";
        try
        {
            var connectivityManager = (ConnectivityManager)GetSystemService(ConnectivityService);
            var activeConnection = connectivityManager.ActiveNetworkInfo;
            if ((activeConnection != null) && activeConnection.IsConnected)
            {
        sqldb_message="Network Available";
            }
    else
    {
        sqldb_message="Network Not Available";
    }
        }
        catch (SQLiteException ex)
        {
    sqldb_message="Network Not Available";
        }
        return sqldb_message;
    }

but System Give Error Message GetSystemService doesnot exists on current Context.
Tagged:

Answers

  • I m having the same issue. but so far no solutions.

  • kkarakkkkarakk Member

    sorry for resurrecting this zombie post but i have an answer - getSystemService uses the current context. pass the context to your function or access it as this.getSystemService.
    for eg in my case i passed the activity context to a function using this and then used ActivityObject.getSystemService.
    context is required

Sign In or Register to comment.