私は無駄では、E164に電話番号をフォーマットしようとしています:PhoneNumberUtils.formatNumberToE164 indesired方法結果
//Detects outgoing call :
private class MyOutCallsReceiver extends BroadcastReceiver{
public MyOutCallsReceiver() {super();}
@Override
public void onReceive(Context context, Intent intent) {
String outgoingNumber = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER);
Log.v("OUTCALL-outgoing",outgoingNumber);
String phone = MyApplication.TryFormatPhoneNumberToE164(outgoingNumber);
Log.v("OUTCALL-phone",phone);
}
Logcat:11-11 14:23:19.836 495から495/ma.altaiir。アプリV /アウトコール出射: 0612345678 11-11 14:23:19.841 495から495/ma.altaiir.appのV /アウトコール電話:0612345678
フォーマット方法:
public static String TryFormatPhoneNumberToE164(String phone){
String result = PhoneNumberUtils.formatNumberToE164(phone,_CountryIsoCode);
if(result == null){result = PhoneNumberUtils.formatNumberToE164(PhoneNumberUtils.normalizeNumber(phone),_CountryIsoCode);}
Log.v("COUNTRYISOCODE/NUMB",_CountryIsoCode + "/" + phone + "/" + result);
if(result == null){return phone;}else{ return result;}
}
Logcat:
11-11 14:23:19.841 495から495/ma.altaiir.app V/COUNTRYISOCODE/NUMB: MA/0612345678 /ヌル
すべてこの手段メソッドは、これを避けるために何をしてもnullを返すだけです。これは既知の欠点ですか、それとも私が間違っていることですか?
と答えてください – marmor