MCPcopy Create free account
hub / github.com/grpc/grpc-java / isAndroid

Method isAndroid

api/src/main/java/io/grpc/ServiceProviders.java:97–106  ·  view source on GitHub ↗

Returns true if the ClassLoader is for android.

(ClassLoader cl)

Source from the content-addressed store, hash-verified

95 * Returns true if the {@link ClassLoader} is for android.
96 */
97 static boolean isAndroid(ClassLoader cl) {
98 try {
99 // Specify a class loader instead of null because we may be running under Robolectric
100 Class.forName("android.app.Application", /*initialize=*/ false, cl);
101 return true;
102 } catch (Exception e) {
103 // If Application isn't loaded, it might as well not be Android.
104 return false;
105 }
106 }
107
108 /**
109 * For testing only: Loads service providers for the {@code klass} service using {@link

Callers 2

loadAllMethod · 0.95
isAndroidMethod · 0.95

Calls 1

forNameMethod · 0.45

Tested by

no test coverage detected