Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4241154
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T03:15:58+00:00 2026-05-21T03:15:58+00:00

I am still newbie to android, please could someone help. I want to use

  • 0

I am still newbie to android, please could someone help.

I want to use methods from the Net class as follows:

package com.test;

import android.app.Activity;
import android.os.Bundle;
import android.view.Window;
import android.widget.TextView;

public class MyApp extends Activity {

  /** Called when the activity is first created. */
  private Net wifi;

  TextView textStatus;    

  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    requestWindowFeature(Window.FEATURE_NO_TITLE); 
    setContentView(R.layout.main);

    wifi=new Net(this);
    textStatus = (TextView) findViewById(R.id.text); 
    textStatus.append("Your online status is ");

    if (wifi.isOnline()) {
      textStatus.append("online "+wifi.getInfo());
    } else {
      textStatus.append("offline "+wifi.getInfo());
    }
  }
}

and my Net class:

import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.os.IBinder;

public class Net {
  WifiManager wifi;
  ConnectivityManager cm;
  NetworkInfo netInfo;

  public Net (Context ctx) {
    cm = (ConnectivityManager) ctx.getSystemService(ctx.CONNECTIVITY_SERVICE);
    netInfo = cm.getActiveNetworkInfo();
    wifi = (WifiManager) ctx.getSystemService(Context.WIFI_SERVICE);
  }

  public boolean isOnline() { 
    netInfo = cm.getActiveNetworkInfo();

    if (netInfo != null && netInfo.isConnectedOrConnecting()) {
      return true;
    } else {
      return false;
    }
  }

  public NetworkInfo[] getName() {
    NetworkInfo[] name=cm.getAllNetworkInfo();
    return name;    
  }

  public String getInfo() {
    // Get WiFi status
    WifiInfo info = wifi.getConnectionInfo();
    return info.getSSID().toString();
  }
}

I believe I should not be extending my Net class with Activity? I am getting source not found error when running the app.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T03:15:59+00:00Added an answer on May 21, 2026 at 3:15 am

    I believe I should not be extending my
    Net class with Activity?

    Correct!

    Your Net class is simply a helper so can be simply defined as:

    public class Net {
    
      public Net (Context ctx) {
        cm = (ConnectivityManager) ctx.getSystemService(Context.CONNECTIVITY_SERVICE);
        netInfo = cm.getActiveNetworkInfo();
      }
    
      // Your other methods here...
    }
    

    When you create your wifi object, use wifi = new Net(this);

    The Activity class in Android is used to provide a UI framework for visual/interactive elements such as buttons, textviews etc. etc. – basically anything the user needs to interact with. This isn’t appropriate for your Net class.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am still a newbie in regular expression, please help me out guys. I
Still an Android newbie , but hopefully someone can point me in the right
Im still a newbie in android, would appreciate your help as I couldnt find
I'm still a newbie in Android and I'm trying to work my way around
Still having issues with this problem. Please help if you can. So I am
perhaps it's a newbie question because I'm still new to java/android..sorry.. I'm getting this
I'm still a newbie in Python, so please tolerate my poor syntax and logic
i need help with this JQuery code i have.. i'm still a newbie when
I'm still a newbie to Android but have searched high and low for an
I'm still a newbie at this so please bear with me :) I just

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.