Skip to content

Nalorokk/Aviasales-Android-SDK

 
 

Repository files navigation

Aviasales/JetRadar Android SDK 2.0

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:

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.

What's new

  • IdentificationData.java is renamed to SdkConfig.java
  • In IdentificationData added sdk-host parameter. See Installation instructions for more info

Installation

Add gradle dependencies

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.10-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.10'
}

Initialization of Aviasales SDK

Before any interaction with Aviasales SDK or Aviasales Template you should initialize it

  AviasalesSDK.getInstance().init(this, new SdkConfig(TRAVEL_PAYOUTS_MARKER, TRAVEL_PAYOUTS_TOKEN, SDK_HOST)); 

Change TRAVEL_PAYOUTS_MARKER and TRAVEL_PAYOUTS_TOKEN to your marker and token params. You can find them at Travelpayouts.com.

SDK_HOST is a main endpoint of Aviasales SDK. You can set www.travel-api.pwas your default endpoint, but we strongly recommend to change it to your WhiteLabel host.

Example of adding Aviasales Template to your project

Add AviasalesFragment to your activity

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 final static String SDK_HOST = "www.travel-api.pw";
  	private AviasalesFragment aviasalesFragment;
    ...
  
  	@Override
  	protected void onCreate(Bundle savedInstanceState) {
  		super.onCreate(savedInstanceState);
  
   		// Initialization of AviasalesSDK. 
		AviasalesSDK.getInstance().init(this, new SdkParams(TRAVEL_PAYOUTS_MARKER, TRAVEL_PAYOUTS_TOKEN,SDK_HOST));
  		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();
  	}
}

Specify permissions

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"/>

Adding onBackPressed

For proper back navigation between aviasales child fragments add fragment onBackPressed inside of activity onBackPressed

	@Override
	public void onBackPressed() {

    ...
		if (!aviasalesFragment.onBackPressed()) {
			super.onBackPressed();
		}
		...
		
	}

Customization

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

Appodeal ads

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.10'
}

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

About

Aviasales Android SDK and template project

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 100.0%