Developer

MAFAddressFormatter

The MAFAddressFormatter formats phone numbers and addresses, and translates the names of the address fields.

Phone number formatting is handled as part of address formatting, as the metadata for both types of formatting is in one common XML descriptor file. To get a reference and initialize the MAFAddressFormatter, use this code:
	private MAFAddressFormatter formatter = null;
	formatter = MAFAddressFormatter.getInstance(this);
	formatter.initWithSAPXML();
This is a code snippet from country_formats.xml. Use this format to add your country to the XML configuration file, if it does not contain your country:
	<!-- United States -->
	<format country="us">

		<addresses>
			<address format="HOUSE_NO STREET\nLOCATION\nCITY REGION POSTL_COD1\nCOUNTRY" />
		</addresses>

		<addressfields>
			<line>
				<field id="HOUSE_NO" keyboard="NUMERIC" width="35%" label="{No.}" />
				<field id="STREET" width="65%" label="{STREET}" />
			</line>
			<line>
				<field id="LOCATION" label="{STREET} 4" />
			</line>
			<line>
				<field id="CITY" label="{CITY}" />
				<field id="REGION" keyboard="ALLCAPS" label="{State}" />
			</line>
			<line>
				<field id="POSTL_COD1" keyboard="NUMERIC" label="{ZIP}" />
				<field id="COUNTRY" label="{COUNTRY}" />
			</line>
		</addressfields>

		<phonenumbers internationalprefix="1" outboundcode="011">
			<phonenumber format="(xxx) xxx-xxxx" />
			<phonenumber format="(415) xxx-xxxx" />
			<phonenumber format="(xxx) xxx-xx8x" />
		</phonenumbers>

	</format>
You can also use your own country_formats.xml. To set it, use:
InputStream iStream = activity.getResources().openRawResource(
					R.raw.countryformats_patch);
	formatter.initWithCustomXML(iStream);
For the method details of the MAFAdressFormatter, see its API documentation.