SafetyNet
Stay organized with collections
Save and categorize content based on your preferences.
Inherited Method Summary
From class java.lang.Object
Public Methods
Returns a SafetyNetClient
that is used to access all APIs that are called when the app has a foreground Activity
.
Use this method over getClient(Context)
if your app has a foreground Activity
and
you will be making multiple API calls to improve performance.
Returns a SafetyNetClient
that is used to access all APIs that are called without access to a foreground Activity
.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License
, and code samples are licensed under the Apache 2.0 License
. For details, see the Google Developers Site Policies
. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-10-31 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-10-31 UTC."],[[["\u003cp\u003eThe SafetyNet API helps assess the health and safety of an Android device by providing access to Google services.\u003c/p\u003e\n"],["\u003cp\u003eUse \u003ccode\u003egetClient(Context)\u003c/code\u003e or \u003ccode\u003egetClient(Activity)\u003c/code\u003e to access the SafetyNet API, rather than the deprecated \u003ccode\u003eAPI\u003c/code\u003e and \u003ccode\u003eSafetyNetApi\u003c/code\u003e fields.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003egetClient(Activity)\u003c/code\u003e is recommended for improved performance when making multiple API calls from an app with a foreground Activity.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003egetClient(Context)\u003c/code\u003e should be used when accessing the API without a foreground Activity.\u003c/p\u003e\n"]]],[],null,["# SafetyNet\n\npublic final class **SafetyNet** extends [Object](//developer.android.com/reference/java/lang/Object.html) \nThe SafetyNet API provides access to Google services that help you assess the health and\nsafety of an Android device.\n\nTo use SafetyNet, call [getClient(Context)](/android/reference/com/google/android/gms/safetynet/SafetyNet#getClient(android.content.Context)) or [getClient(Activity)](/android/reference/com/google/android/gms/safetynet/SafetyNet#getClient(android.app.Activity)). \n\n### Field Summary\n\n|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| public static final [Api](/android/reference/com/google/android/gms/common/api/Api)\\\u003c[Api.ApiOptions.NoOptions](/android/reference/com/google/android/gms/common/api/Api.ApiOptions.NoOptions)\\\u003e | [API](/android/reference/com/google/android/gms/safetynet/SafetyNet#API) | *This field was deprecated. use [getClient(Context)](/android/reference/com/google/android/gms/safetynet/SafetyNet#getClient(android.content.Context)) or [getClient(Activity)](/android/reference/com/google/android/gms/safetynet/SafetyNet#getClient(android.app.Activity)).* |\n| public static final [SafetyNetApi](/android/reference/com/google/android/gms/safetynet/SafetyNetApi) | [SafetyNetApi](/android/reference/com/google/android/gms/safetynet/SafetyNet#SafetyNetApi) | *This field was deprecated. use [getClient(Context)](/android/reference/com/google/android/gms/safetynet/SafetyNet#getClient(android.content.Context)) or [getClient(Activity)](/android/reference/com/google/android/gms/safetynet/SafetyNet#getClient(android.app.Activity)).* |\n\n### Public Method Summary\n\n|-----------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| static [SafetyNetClient](/android/reference/com/google/android/gms/safetynet/SafetyNetClient) | [getClient](/android/reference/com/google/android/gms/safetynet/SafetyNet#getClient(android.app.Activity))([Activity](//developer.android.com/reference/android/app/Activity.html) activity) Returns a [SafetyNetClient](/android/reference/com/google/android/gms/safetynet/SafetyNetClient) that is used to access all APIs that are called when the app has a foreground [Activity](//developer.android.com/reference/android/app/Activity.html). |\n| static [SafetyNetClient](/android/reference/com/google/android/gms/safetynet/SafetyNetClient) | [getClient](/android/reference/com/google/android/gms/safetynet/SafetyNet#getClient(android.content.Context))([Context](//developer.android.com/reference/android/content/Context.html) context) Returns a [SafetyNetClient](/android/reference/com/google/android/gms/safetynet/SafetyNetClient) that is used to access all APIs that are called without access to a foreground [Activity](//developer.android.com/reference/android/app/Activity.html). |\n\n### Inherited Method Summary\n\nFrom class java.lang.Object \n\n|----------------------------------------------------------------------------|--------------------------------------------------------------------------------|\n| [Object](//developer.android.com/reference/java/lang/Object.html) | clone() |\n| boolean | equals([Object](//developer.android.com/reference/java/lang/Object.html) arg0) |\n| void | finalize() |\n| final [Class](//developer.android.com/reference/java/lang/Class.html)\\\u003c?\\\u003e | getClass() |\n| int | hashCode() |\n| final void | notify() |\n| final void | notifyAll() |\n| [String](//developer.android.com/reference/java/lang/String.html) | toString() |\n| final void | wait(long arg0, int arg1) |\n| final void | wait(long arg0) |\n| final void | wait() |\n\nFields\n------\n\n#### public static final [Api](/android/reference/com/google/android/gms/common/api/Api)\\\u003c[Api.ApiOptions.NoOptions](/android/reference/com/google/android/gms/common/api/Api.ApiOptions.NoOptions)\\\u003e\n**API**\n\n**This field was deprecated.** \n\nuse [getClient(Context)](/android/reference/com/google/android/gms/safetynet/SafetyNet#getClient(android.content.Context)) or [getClient(Activity)](/android/reference/com/google/android/gms/safetynet/SafetyNet#getClient(android.app.Activity)). \nThe API necessary to use SafetyNet. \n\n#### public static final [SafetyNetApi](/android/reference/com/google/android/gms/safetynet/SafetyNetApi)\n**SafetyNetApi**\n\n**This field was deprecated.** \n\nuse [getClient(Context)](/android/reference/com/google/android/gms/safetynet/SafetyNet#getClient(android.content.Context)) or [getClient(Activity)](/android/reference/com/google/android/gms/safetynet/SafetyNet#getClient(android.app.Activity)). \nThe entry point for interacting with the SafetyNet APIs which help assess the health\nand safety of an Android device.\n\nPublic Methods\n--------------\n\n#### public static [SafetyNetClient](/android/reference/com/google/android/gms/safetynet/SafetyNetClient)\n**getClient** ([Activity](//developer.android.com/reference/android/app/Activity.html) activity)\n\nReturns a [SafetyNetClient](/android/reference/com/google/android/gms/safetynet/SafetyNetClient)\nthat is used to access all APIs that are called when the app has a foreground\n[Activity](//developer.android.com/reference/android/app/Activity.html).\n\nUse this method over [getClient(Context)](/android/reference/com/google/android/gms/safetynet/SafetyNet#getClient(android.content.Context)) if your app has a foreground [Activity](//developer.android.com/reference/android/app/Activity.html) and\nyou will be making multiple API calls to improve performance. \n\n#### public static [SafetyNetClient](/android/reference/com/google/android/gms/safetynet/SafetyNetClient)\n**getClient** ([Context](//developer.android.com/reference/android/content/Context.html) context)\n\nReturns a [SafetyNetClient](/android/reference/com/google/android/gms/safetynet/SafetyNetClient)\nthat is used to access all APIs that are called without access to a foreground\n[Activity](//developer.android.com/reference/android/app/Activity.html)."]]