Googl Shortener Library

A Simple Android Library to shorten urls with Goo.gl

License

License

GroupId

GroupId

com.andreabaccega
ArtifactId

ArtifactId

googlshortenerlib
Last Version

Last Version

1.0.0
Release Date

Release Date

Type

Type

aar
Description

Description

Googl Shortener Library
A Simple Android Library to shorten urls with Goo.gl
Project URL

Project URL

https://github.com/vekexasia/android-googl-shortener-lib
Source Code Management

Source Code Management

https://github.com/vekexasia/android-googl-shortener-lib

Download googlshortenerlib

How to add to project

<!-- https://jarcasting.com/artifacts/com.andreabaccega/googlshortenerlib/ -->
<dependency>
    <groupId>com.andreabaccega</groupId>
    <artifactId>googlshortenerlib</artifactId>
    <version>1.0.0</version>
    <type>aar</type>
</dependency>
// https://jarcasting.com/artifacts/com.andreabaccega/googlshortenerlib/
implementation 'com.andreabaccega:googlshortenerlib:1.0.0'
// https://jarcasting.com/artifacts/com.andreabaccega/googlshortenerlib/
implementation ("com.andreabaccega:googlshortenerlib:1.0.0")
'com.andreabaccega:googlshortenerlib:aar:1.0.0'
<dependency org="com.andreabaccega" name="googlshortenerlib" rev="1.0.0">
  <artifact name="googlshortenerlib" type="aar" />
</dependency>
@Grapes(
@Grab(group='com.andreabaccega', module='googlshortenerlib', version='1.0.0')
)
libraryDependencies += "com.andreabaccega" % "googlshortenerlib" % "1.0.0"
[com.andreabaccega/googlshortenerlib "1.0.0"]

Dependencies

compile (2)

Group / Artifact Type Version
com.squareup.okhttp : okhttp jar 2.0.0
com.google.code.gson : gson jar 2.3

Project Modules

There are no modules declared in this project.

Android Goo.gl Shortener Library

A simple tested Android library to shorten long urls in your app!

How to include it

This library can be found in maven central repo. If you're using Android studio you can include it by writing the following in the corresponding dependencies block

Gradle:

dependencies {
	// ...
	compile 'com.andreabaccega:googlshortenerlib:1.0.0'
	// ...
}

####Maven

		<dependency>
			<groupId>com.andreabaccega</groupId>
			<artifactId>googlshortenerlib</artifactId>
			<version>${version}</version>
			<type>aar</type>
			<scope>provided</scope>
		</dependency>

How to use

	GoogleShortenerPerformer shortener = new GoogleShortenerPerformer(new OkHttpClient());

	String longUrl = "http://www.andreabaccega.com/";

	GooglShortenerResult result = shortener.shortenUrl(
		new GooglShortenerRequestBuilder()
			.buildRequest(longUrl)
		);

	if ( Status.SUCCESS.equals(result.getStatus()) ) {
		// all ok result.getShortenedUrl() contains the shortened url!
	} else if ( Status.IO_EXCEPTION.equals(result.getStatus()) ) {
		// connectivity error. result.getException() returns the thrown exception while performing
		// the request to google servers!
	} else {
		// Status.RESPONSE_ERROR
		// this happens if google replies with an unexpected response or if there are some other issues processing
		// the result.

		// result.getException() contains a GooglShortenerException containing a message that can help resolve the issue!
	}

We do recommend to request an apiKey and use the following method instead of the above!

	new GooglShortenerRequestBuilder()
			.buildRequest(
				longUrl,
				apiKey)
		)

Dependencies

This library depends on the following artifacts:

  • com.squareup.okhttp:okhttp:2.0.0
  • com.google.code.gson:gson:2.3

They're automatically resolved by gradle but you can always exclude them (if you're using another compatible version) by doing so:

dependencies {
	// ...
	compile ('com.andreabaccega:googlshortenerlib:1.0.0') {
		exclude module: 'okhttp'
		exclude module: 'gson'
	}
	// ...
}

Author

Versions

Version
1.0.0