String urlString = "http://mysuperwebsite";
Intent intent = new Intent(Intent.ACTION_VIEW,Uri.parse(urlString));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setPackage("com.android.chrome");
try {
context.startActivity(intent);
} catch (ActivityNotFoundException ex) {
// Chrome browser presumably not installed and open Kindle Browser
intent.setPackage("com.amazon.cloud9");
context.startActivity(intent);
}
var cookieHandler = new CookieManager();
CookieHandler.setDefault(cookieHandler);
var executor = Executors.newWorkStealingPool(10);
var httpClient = HttpClient.newBuilder()
.executor(executor)
.connectTimeout(Duration.ofSeconds(15))
.version(HttpClient.Version.HTTP_2)
.followRedirects(HttpClient.Redirect.ALWAYS)
.cookieHandler(CookieHandler.getDefault())
.build();
final HttpRequest httpRequest = HttpRequest.newBuilder()
.GET().uri(URI.create(url))
.build();
return httpClient.sendAsync(httpRequest, RESPONSE_BODY_HANDLER)
.thenApply(response -> System.out.println(response.statusCode()));
Possible solutions:
# Reduce memory load on the system
# Increase physical memory or swap space
# Check if swap backing store is full
# Decrease Java heap size (-Xmx/-Xms)
# Decrease number of Java threads
# Decrease Java thread stack sizes (-Xss)
# Set larger code cache with -XX:ReservedCodeCacheSize=
# JVM is running with Zero Based Compressed Oops mode in which the Java heap is
# placed in the first 32GB address space. The Java Heap base address is the
# maximum limit for the native heap growth. Please use -XX:HeapBaseMinAddress
# to set the Java Heap base and to place the Java Heap above 32GB virtual address.