หากคุณส่งข้อมูลตำแหน่งที่แน่นอนของผู้ใช้ไปยัง 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 dataMESSAGE_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: ข้อความของปุ่มกล่องโต้ตอบความยินยอม เช่นOKAPP_TAG: แท็กบันทึกของแอปพลิเคชัน เช่นMainActivityCONSENT_RECEIVED_LOG_MESSAGE: ข้อความในบันทึกที่จะบันทึกเมื่อผู้ใช้ให้ความยินยอม เช่นConsent received