Skip to content

namitamo/network-kit-android

Repository files navigation

Examples with Fastah API

This repository provides sample code to build network-aware Android apps using Fastah Network Kit for Android.

Availabe examples are:

  • Media pre-loader: An implementation of network-aware audio or video pre-fetching, which can improve UX or views when network conditions are flaky. See DemoAudioVideoPreloadActivity.java

Quick Start Guide

Check out our official documentation for more in depth information on installing and using Fastah on Android.

Installation

Dependencies in app/build.gradle

Add Fastah's Maven repository to the repositories section in app/build.gradle

maven { url 'http://maven.getfastah.com/libs-release' }

Next, add Fastah to the dependencies section in app/build.gradle

compile 'com.getfastah.networkkit:networkkit-android-core:1.5.+'

Permissions in app/src/main/AndroidManifest.xml

These are also merged automatically via the library's own Manifest file via Android's manifest merging.

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />

Integration

Initialization

Initialize Fastah in your main activity. Usually this should be done in onCreate.

MeasureManager.getInstance().init(this);

Before the init() call above succeeds though, the app-specific key needs to be configured in the app's AndroidManifest.xml. Replace YOUR_APPLICATION_ID and YOUR_APPLICATION_KEY with the application ID (e.g the Play Store app identifier), and the key obtained from support@getfastah.com. Now, build your app.

<meta-data android:name="com.getfastah.networkkit.MeasureConfig.ApplicationName" android:value="YOUR_APPLICATION_ID" />
<meta-data android:name="com.getfastah.networkkit.MeasureConfig.ApplicationKey" android:value="YOUR_APPLICATION_KEY" />

Network sensing & Network watching

With the MeasureManager object created in the last step a call to measureOnce is all you need to start measuring network conditions using Fastah's geo-distributed server endpoints.

MeasureManager.MeasurementCompletedListener mListener;
mListener = new MeasureManager.MeasurementCompletedListener() {
    @Override
    public void onMeasurementComplete(MeasureSample sample) {
        // The sample object holds the measurement results.
    }
};

MeasureManager.getInstance().register(mListener);

// Call this as often as you like to get real-time network conditions
MeasureManager.getInstance().measureOnce(ctx);

I want to know more!

No worries, here are some links that you will find useful:

Have any questions? Reach out to support@getfastah.com to speak to someone smart, quickly.

Help

Please report any problems in this Github project's Issues section, or via email to support@getfastah.com. On Twitter, ping Siddharth Mathur at @s8mathur]

License

See LICENSE File for details.

About

Example code for Fastah Network Kit SDK for Android: Build network-aware UX with ease

Resources

License

Stars

0 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages