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 9127551
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T07:18:28+00:00 2026-06-17T07:18:28+00:00

in order to refactor my code, I’m moving some methods I’m using in every

  • 0

in order to refactor my code, I’m moving some methods I’m using in every project to an Android library.

Eg. I’ve created a simple library project with the following class:

public class HttpUtils {

    public boolean isNetworkAvailable(Context context) {
        ConnectivityManager cm = (ConnectivityManager) 
          context.getSystemService(Context.CONNECTIVITY_SERVICE);
        NetworkInfo networkInfo = cm.getActiveNetworkInfo();
        if (networkInfo != null && networkInfo.isConnected()) {
            return true;
        }
        return false;
    } 
}

and the following (default) manifest file:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.xxx.utils"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="17" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
    </application>

</manifest>

I can import it in another Android project using

import com.xxx.utils.http.HttpUtils;

but if I try using HttpUtils.isNetworkAvailable, I get HttpUtils.isNetworkAvailable cannot be resolved to a type.

I read that, for a library activity, it should be added to the manifest file, but how can I add a simple class, like my HttpUtils, in the library manifest to be able to access its method from another project?

  • 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-06-17T07:18:29+00:00Added an answer on June 17, 2026 at 7:18 am

    Why would you like to add this class like a library. Add it just in your package, then you can call it from any Activity like that :

    boolean isNetworkAvailable = new HttpUtils().isNetworkAvailable(this);
    

    Or make isNetworkAvailable static :

    public static boolean isNetworkAvailable(Context context) {....}
    

    Then you could call it simply:

    boolean isNetworkAvailable = HttpUtils.isNetworkAvailable(this);
    

    In this way, there is nothing to declare in the manifest file.

    EDIT :
    ok, I understand. You have several projects. So for this, you have 2 choices :

    1)you can create from eclipse new project and in the second window select “Mark this project as a library”. Then in all your project add this library project in the build path

    2)create a jar file

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

Sidebar

Related Questions

I have some code that I want to refactor. I have lots of methods
In order to do not duplicate code, I've decided some time ago, to refactor
In order to refactor my MATLAB code, I thought I'd pass around functions as
I refactor my code in order to respect the view model pattern. I also
I'm working with Dynamics CRM 2011 Online and trying to refactor some code that
I'm trying to refactor some legacy code to use Spring to handle the jms
I have the following piece of code and I try to refactor this to
I am trying to refactor some code in an ASP.Net website and having a
Order by descending is not working on LINQ to Entity In the following Query
in order to recover data from server I use XMLHttpRequest and my code is

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.