CountryPicker is a simple library that can be show a country picker. See the example to see more detail.
Integrating the project is simple a refined all you need to do is add this to your app level gradle file
compile 'com.mukesh:countrypicker:1.1.5'
Once the project has been added to gradle the user can implement this with easy.
CountryPicker picker = CountryPicker.newInstance("Select Country");
picker.show(getSupportFragmentManager(), "COUNTRY_PICKER");
picker.setListener(new CountryPickerListener() {
@Override
public void onSelectCountry(String name, String code, String dialCode, int flagDrawableResID) {
// Implement your code here
}
});
That's it your all done.
The following code will get the current users country details based on sim.
CountryPicker picker = CountryPicker.newInstance("Select Country");
Country country = picker.getUserCountryInfo(this);
//TODO use the country object