1. Update the "project level" gradle file.
allprojects {
repositories {
maven {
url 'https://maven.speedcheckerapi.com/artifactory/libs-release'
credentials {
username = "demo"
password = "AP85qiz6wYEsCttWU2ZckEWSwJKuA6mSYcizEY"
}
}
}
}
2. Update the "app level" gradle file.
implementation 'com.speedchecker:android-sdk:4.2.256'
3. Initialize SpeedcheckerSDK inside a main activity.
public void onCreate() {
super.onCreate();
SpeedcheckerSDK.init(this);
}
4. Ask Location permissions.
SpeedcheckerSDK.askPermissions(this);
5. Implement the "SpeedTestListener" interface and override methods (an example below shows a new class with overriding methods but you could implement the interface at "MainActivity" or somewhere else).
import com.speedchecker.android.sdk.Public.SpeedTestListener;
public class SpeedTestCallbacks implements SpeedTestListener {
@Override
public void onTestStarted() {
//your code here
}
@Override
public void onFetchServerFailed() {
//your code here
}
//… other methods here
}
6. Set implemented interface.
SpeedcheckerSDK.SpeedTest.setOnSpeedTestListener(new SpeedTestCallbacks()); OR SpeedcheckerSDK.SpeedTest.setOnSpeedTestListener(this);
7. Start Speed test.
SpeedcheckerSDK.SpeedTest.startTest(this);
8. License Key setup in main application class(optional)
class MainApplication : Application() {
override fun onCreate() {
super.onCreate()
SpeedcheckerSDK.setLicenseKey(this, "Insert your key here")
}
}
9. That's it. Enjoy!
