Aviasales/JetRadar Android SDK is a framework integrating flight search engine into your app. When your customer books a flight, we pay you a commission fee. Framework is based on leading flight search engines Aviasales and JetRadar.
SDK supports all Android devices with Android 2.3 (API 9) and higher.
The framework consists of:
- search API library for search server interaction;
- user interface template project;
- demo application based on template project.
Learn more and complete integration with Aviasales Android SDK Documentation.
To get your API key, track statistics and payments please sign up to Travelpayouts Travel Affiliate Network.
Learn more about earnings in Travelpayouts FAQ.
Video [instruction] (https://www.youtube.com/watch?v=dQw4w9WgXcQ)
More languages: [RUS] Документация Aviasaels Android SDK.
To add Aviasales SDK Library to your project use gradle:
repositories {
maven { url 'http://android.aviasales.ru/repositories/' }
}
dependencies {
compile 'ru.aviasales.template:aviasalesSdk:2.1.7-sdk'
}
If you want to use complete Aviasales SDK Template, you can add it like this :
repositories {
maven { url 'http://android.aviasales.ru/repositories/' }
}
dependencies {
compile 'ru.aviasales.template:aviasalesSdkTemplate:2.1.8'
}
Before any interaction with Aviasales SDK or Aviasales Template you should initialize it
AviasalesSDK.getInstance().init(this, new IdentificationData(TRAVEL_PAYOUTS_MARKER, TRAVEL_PAYOUTS_TOKEN));
Change TRAVEL_PAYOUTS_MARKER
and TRAVEL_PAYOUTS_TOKEN
to your marker and token params. You can get them at Travelpayouts.com.
Add to main activity layout activity_main.xml
the FrameLayout
for fragments
<FrameLayout
android:id="@+id/fragment_place"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
Add fragment to MainActivity
public class MainActivity extends AppCompatActivity {
//Replace these variables on your TravelPayouts marker and token
private final static String TRAVEL_PAYOUTS_MARKER = "your_travel_payouts_marker";
private final static String TRAVEL_PAYOUTS_TOKEN = "your_travel_payouts_token";
private AviasalesFragment aviasalesFragment;
...
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Initialization of AviasalesSDK.
AviasalesSDK.getInstance().init(this, new IdentificationData(TRAVEL_PAYOUTS_MARKER, TRAVEL_PAYOUTS_TOKEN));
setContentView(R.layout.activity_main);
initFragment();
}
...
private void initFragment() {
FragmentManager fm = getSupportFragmentManager();
aviasalesFragment = (AviasalesFragment) fm.findFragmentByTag(AviasalesFragment.TAG); // finding fragment by tag
if (aviasalesFragment == null) {
aviasalesFragment = (AviasalesFragment) AviasalesFragment.newInstance();
}
FragmentTransaction fragmentTransaction = fm.beginTransaction(); // adding fragment to fragment manager
fragmentTransaction.replace(R.id.fragment_place, aviasalesFragment, AviasalesFragment.TAG);
fragmentTransaction.commit();
}
}
Don't forget to specify permissions INTERNET
and ACCESS_NETWORK_STATE
by adding <uses-permission>
elements as children of the <manifest>
element.
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
For proper back navigation between aviasales child fragments add fragment onBackPressed
inside of activity onBackPressed
@Override
public void onBackPressed() {
...
if (!aviasalesFragment.onBackPressed()) {
super.onBackPressed();
}
...
}
For proper customization of Aviasales Template use AviasalesTemplateTheme
or extend your theme from it. For example, in AndroidManifest.xml
specify your theme
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
...
and in styles.xml
extend your theme from AviasalesTemplateTheme
<style name="AppTheme" parent="AviasalesTemplateTheme">
...
</style>
To change colors of your app override colorAsPrimary
, colorAsPrimaryDark
and colorAviasalesMain
in colors.xml
. This is main Aviasales Template colors
<color name="colorAsPrimary">#3F51B5</color>
<color name="colorAsPrimaryDark">#3F51B5</color>
<color name="colorAviasalesMain">#3F51B5</color>
Also you can change background and price tag colors
<color name="aviasales_results_background">@color/grey_background</color>
<color name="aviasales_search_form_background">@color/white</color>
<color name="aviasales_filters_background">@color/white</color>
<color name="aviasales_select_airport_background">@color/white</color>
<color name="aviasales_ticket_background">@color/grey_background</color>
<color name="aviasales_results_card_color">@color/white</color>
<color name="aviasales_price_color">@color/yellow_FDCC50</color>
For more information see the demo project
You can implement Appodeal ads in your app and and get revenue from them (available from Aviasales SDK v.2.1.3)
To add Appodeal Ads to your project just add additional maven dependency:
dependencies {
compile 'ru.aviasales.template:appodeallib:2.1.8'
}
And then initialize it
AppodealAds ads = new AppodealAds();
ads.setStartAdsEnabled(SHOW_ADS_ON_START); // ads on start (true/false)
ads.setWaitingScreenAdsEnabled(SHOW_ADS_ON_WAITING_SCREEN); // ads on waiting screen (true/false)
ads.setResultsAdsEnabled(SHOW_ADS_ON_SEARCH_RESULTS); // ads on results (true/false)
ads.init(this, APPODEAL_APP_KEY); // your appodeal key
AdsImplKeeper.getInstance().setCustomAdsInterfaceImpl(ads); // assign your appodeal
For more information about appodal ads see the ads demo project