正在查看: St.John's v1.0.9 应用的 FetchAddressIntentService.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: St.John's v1.0.9 应用的 FetchAddressIntentService.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.mcb.stjohnsemschool.utils;
import android.app.IntentService;
import android.content.Intent;
import android.location.Address;
import android.location.Geocoder;
import android.os.Bundle;
import android.os.ResultReceiver;
import android.util.Log;
import java.io.IOException;
import java.util.List;
import java.util.Locale;
public class FetchAddressIntentService extends IntentService {
public static final String TAG = "FetchAddressIntentService";
protected ResultReceiver receiver;
public FetchAddressIntentService() {
super(TAG);
}
@Override
protected void onHandleIntent(Intent intent) {
String string;
List<Address> list;
if (intent == null) {
return;
}
this.receiver = (ResultReceiver) intent.getParcelableExtra(SimplePlacePicker.RECEIVER);
try {
list = new Geocoder(this, new Locale(intent.getStringExtra(SimplePlacePicker.LANGUAGE))).getFromLocation(intent.getDoubleExtra(SimplePlacePicker.LOCATION_LAT_EXTRA, -1.0d), intent.getDoubleExtra(SimplePlacePicker.LOCATION_LNG_EXTRA, -1.0d), 1);
string = "";
} catch (IOException e) {
string = getString(2131886481);
Log.e(TAG, string, e);
list = null;
}
if (list == null || list.size() == 0) {
if (string.isEmpty()) {
string = getString(2131886412);
Log.e(TAG, string);
}
deliverResultToReceiver(1, string);
return;
}
StringBuilder sb = new StringBuilder();
Address address = list.get(0);
for (int i = 0; i <= address.getMaxAddressLineIndex(); i++) {
if (i == address.getMaxAddressLineIndex()) {
sb.append(address.getAddressLine(i));
} else {
sb.append(address.getAddressLine(i) + ",");
}
}
String str = TAG;
Log.i(str, getString(2131886118));
Log.i(str, "address : " + ((Object) sb));
deliverResultToReceiver(0, sb.toString());
}
private void deliverResultToReceiver(int i, String str) {
Bundle bundle = new Bundle();
bundle.putString(SimplePlacePicker.RESULT_DATA_KEY, str);
this.receiver.send(i, bundle);
}
}