Humilton/IpApi


Android Library for Calling IP-API https://play.google.com/store/apps/details?id=com.androidfung.geoip

Download


Step 1. Add the JitPack repository to your build file

Add it in your root settings.gradle at the end of repositories:

	dependencyResolutionManagement {
		repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
		repositories {
			mavenCentral()
			maven { url 'https://jitpack.io' }
		}
	}

Add it in your settings.gradle.kts at the end of repositories:

	dependencyResolutionManagement {
		repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
		repositories {
			mavenCentral()
			maven { url = uri("https://jitpack.io") }
		}
	}

Add to pom.xml

	<repositories>
		<repository>
		    <id>jitpack.io</id>
		    <url>https://jitpack.io</url>
		</repository>
	</repositories>

Add it in your build.sbt at the end of resolvers:

 
    resolvers += "jitpack" at "https://jitpack.io"
        
    

Add it in your project.clj at the end of repositories:

 
    :repositories [["jitpack" "https://jitpack.io"]]
        
    

Step 2. Add the dependency

	dependencies {
		implementation 'com.github.Humilton:IpApi:v1.2'
	}
	dependencies {
		implementation("com.github.Humilton:IpApi:v1.2")
	}
	<dependency>
	    <groupId>com.github.Humilton</groupId>
	    <artifactId>IpApi</artifactId>
	    <version>v1.2</version>
	</dependency>

                            
    libraryDependencies += "com.github.Humilton" % "IpApi" % "v1.2"
        
        

                            
    :dependencies [[com.github.Humilton/IpApi "v1.2"]]
        
        

Readme


Welcome to GeoIp-android

This is a wrapper of IP-API for Android platform using Volley. In simple words, get your location information by IP address.

Sample Application

Sample Application is included in app

How to install

To get a Git project into your build:

Step 1. Add the JitPack repository to your build file

Add it in your root build.gradle at the end of repositories:

allprojects {
	repositories {
		...
		maven { url "https://jitpack.io" }
	}
}

Step 2. Add the dependency

dependencies {
        compile 'com.github.Humilton:IpApi:v1.2'
}

How to use

   ApiManager apiManager = new ApiManager(Volley.newRequestQueue(context));
   apiManager.getGeoIpInfo(new Response.Listener<GeoIpResponseModel>() {
        @Override
        public void onResponse(GeoIpResponseModel response) {
            //This is how you get the information.
            //not all attribute are listed
            String country = response.getCountry();
            String city = response.getCity();
            String countryCode = resopnse.getCountryCode();
            double latitude = response.getLatitude();
            double longtidue = response.getLongitude();
            String region = response.getRegion();
            String timezone = response.getTimezone();
            String isp = response.getIsp();
        }
    }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            String errorMessage = error.toString();
        }
    });

How to use with timeout time:

   int timeout = 30000;  // 30000ms, means 30s
   ApiManager apiManager = new ApiManager(Volley.newRequestQueue(context));
   apiManager.getGeoIpInfo(timeout, new Response.Listener<GeoIpResponseModel>() {
        @Override
        public void onResponse(GeoIpResponseModel response) {
            //This is how you get the information.
            //not all attribute are listed
            String country = response.getCountry();
            String city = response.getCity();
            String countryCode = resopnse.getCountryCode();
            double latitude = response.getLatitude();
            double longtidue = response.getLongitude();
            String region = response.getRegion();
            String timezone = response.getTimezone();
            String isp = response.getIsp();
        }
    }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            String errorMessage = error.toString();
        }
    });