如果您將使用者的精確位置資料傳送給 Google,請參閱 Google 發布商政策,瞭解同意聲明規定和通知。
如果這項政策適用於您,請參考以下範例,設定標題、訊息和按鈕文字,告知使用者資料共用情形:
Kotlin
protected fun presentConsentOverlay(context: Context) { AlertDialog.Builder(context) .setTitle("TITLE") .setMessage("MESSAGE_TEXT") .setNeutralButton("BUTTON_TEXT") { dialog, which -> dialog.cancel() Log.d("APP_TAG", "CONSENT_RECEIVED_LOG_MESSAGE") } .show() } // To use the previous function, call: presentConsentOverlay(this)
Java
protected void presentConsentOverlay(Context context) { new AlertDialog.Builder(context) .setTitle("TITLE") .setMessage("MESSAGE_TEXT") .setNeutralButton("BUTTON_TEXT", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); Log.d("APP_TAG", "CONSENT_RECEIVED_LOG_MESSAGE"); } }) .show(); } // To use the previous method, call: presentConsentOverlay(this);
更改下列內容:
TITLE:同意聲明對話方塊的標題,例如Location data。MESSAGE_TEXT:同意聲明對話方塊的文字,例如:We may use your location and share with third parties for the purposes of personalized advertising, analytics, and attributions. To learn more, visit our privacy policy at example.com.BUTTON_TEXT:同意聲明對話方塊按鈕的文字,例如OK。APP_TAG:應用程式的記錄標記,例如MainActivity。CONSENT_RECEIVED_LOG_MESSAGE:使用者提供同意聲明時要記錄的訊息,例如Consent received。