Fix #3051
This commit is contained in:
parent
4f3b58da9b
commit
26703154b1
3 changed files with 27 additions and 15 deletions
|
@ -71,7 +71,8 @@ public class AndroidNetworkUtils {
|
||||||
}
|
}
|
||||||
params = sb.toString();
|
params = sb.toString();
|
||||||
}
|
}
|
||||||
connection = NetworkUtils.getHttpURLConnection(params == null || post ? url : url + "&" + params);
|
String paramsSeparator = url.indexOf('?') == -1 ? "?" : "&";
|
||||||
|
connection = NetworkUtils.getHttpURLConnection(params == null || post ? url : url + paramsSeparator + params);
|
||||||
connection.setRequestProperty("Accept-Charset", "UTF-8");
|
connection.setRequestProperty("Accept-Charset", "UTF-8");
|
||||||
connection.setRequestProperty("User-Agent", Version.getFullVersion(ctx));
|
connection.setRequestProperty("User-Agent", Version.getFullVersion(ctx));
|
||||||
connection.setConnectTimeout(15000);
|
connection.setConnectTimeout(15000);
|
||||||
|
|
|
@ -11,7 +11,6 @@ import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
import net.osmand.FloatMath;
|
|
||||||
import net.osmand.Location;
|
import net.osmand.Location;
|
||||||
import net.osmand.binary.BinaryMapRouteReaderAdapter.RouteRegion;
|
import net.osmand.binary.BinaryMapRouteReaderAdapter.RouteRegion;
|
||||||
import net.osmand.binary.BinaryMapRouteReaderAdapter.RouteTypeRule;
|
import net.osmand.binary.BinaryMapRouteReaderAdapter.RouteTypeRule;
|
||||||
|
|
|
@ -262,13 +262,13 @@ public class IabHelper {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
try {
|
||||||
Intent serviceIntent = new Intent("com.android.vending.billing.InAppBillingService.BIND");
|
Intent serviceIntent = new Intent("com.android.vending.billing.InAppBillingService.BIND");
|
||||||
serviceIntent.setPackage("com.android.vending");
|
serviceIntent.setPackage("com.android.vending");
|
||||||
if (!mContext.getPackageManager().queryIntentServices(serviceIntent, 0).isEmpty()) {
|
if (!mContext.getPackageManager().queryIntentServices(serviceIntent, 0).isEmpty()) {
|
||||||
// service available to handle that Intent
|
// service available to handle that Intent
|
||||||
mContext.bindService(serviceIntent, mServiceConn, Context.BIND_AUTO_CREATE);
|
mContext.bindService(serviceIntent, mServiceConn, Context.BIND_AUTO_CREATE);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
// no service available to handle that Intent
|
// no service available to handle that Intent
|
||||||
mServiceConn = null;
|
mServiceConn = null;
|
||||||
if (listener != null) {
|
if (listener != null) {
|
||||||
|
@ -277,6 +277,12 @@ public class IabHelper {
|
||||||
"Billing service unavailable on device."));
|
"Billing service unavailable on device."));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
if (listener != null) {
|
||||||
|
listener.onIabSetupFinished(new IabResult(IABHELPER_SUBSCRIPTIONS_NOT_AVAILABLE,
|
||||||
|
"InAppBillingService not available"));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -290,7 +296,13 @@ public class IabHelper {
|
||||||
mSetupDone = false;
|
mSetupDone = false;
|
||||||
if (mServiceConn != null) {
|
if (mServiceConn != null) {
|
||||||
logDebug("Unbinding from service.");
|
logDebug("Unbinding from service.");
|
||||||
if (mContext != null) mContext.unbindService(mServiceConn);
|
try {
|
||||||
|
if (mContext != null) {
|
||||||
|
mContext.unbindService(mServiceConn);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
logError("Unbinding failed.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
mDisposed = true;
|
mDisposed = true;
|
||||||
mContext = null;
|
mContext = null;
|
||||||
|
|
Loading…
Reference in a new issue