Commonly used set of ad technology providers use a custom dialog (GDPR) - nouhcc/GDPR_Example GitHub Wiki
Project Android for GDPR, implement The GDPR Admob dialog to ask EU users if they want to give their data to show relevant ads, (two choices are possible).
Yes, let Admob pick data to show the best and interesting ads for users.
No, show no relevant ads (low CPC & CPM).
Notice : This is a custom GDPR with all ADmob providers not only 12.
allprojects { repositories { ... maven { url 'https://jitpack.io' } } }
dependencies { implementation 'com.github.nouhcc:GDRPLib:1.0.2' }
`
private GDPRLib custom;
`
custom = new GDPRLib.Builder(this) .addCallBack(this) callBack to determine what to do after the dialog has ended .addLayoutInflater(getLayoutInflater()) // the layout that should be use for the dialog .addPrivacyPolicy("http://your.policy.com/Policy.html") //your own privacy policy .addPublisherId("pub-2307105849827608") // publisher id from Admob .build(); custom.checkConsentStatus(this);
5. for the callback you must either implement your class with Consent_callback and then use OnDialogClose() method
`
public class ActivitySplash extends AppCompatActivity implements Consent_callback {
private GDPRLib custom;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
custom = new GDPRLib.Builder(this)
.addCallBack(this) //callBack to determine what to do after the dialog has ended
.addLayoutInflater(getLayoutInflater()) // the layout that should be use for the dialog
.addPrivacyPolicy("http://your.policy.com/Policy.html") //your own privacy policy
.addPublisherId("pub-2307105849827608") // publisher id from Admob
.build();
custom.checkConsentStatus(this);
}
`
`
@Override public void OnDialogClose() { startNextActivity(); }
`
`
custom = new GDPRLib.Builder(this)
.addCallBack(new Consent_callback() {
@Override
public void OnDialogClose() {
// your code here
}
}) //callBack to determine what to do after the dialog has ended
.addLayoutInflater(getLayoutInflater()) // the layout that should be use for the dialog
.addPrivacyPolicy("http://your.policy.com/Policy.html") //your own privacy policy
.addPublisherId("pub-233333849827608") // publisher id from Admob
.build();
custom.checkConsentStatus(this);
`
`
// this colors are for your dialog #ff5b1d
<color name="lonodev_colorTextButton1">#ffffff</color>
<color name="lonodev_colorButton2">#644c43</color>
<color name="lonodev_colorTextButton2">#ffffff</color>
<color name="lonodev_colorHeader">#ff5b1d</color>
<color name="lonodev_colorText1">#042f51</color>
<color name="lonodev_colorText2">#0489f5</color>
<color name="lonodev_colorText3">#e9181c</color>
<color name="lonodev_colorText4">#0078d9</color>
`
`
<style name="AppTheme.Button" parent="Widget.AppCompat.Button.Colored">
<item name="colorButtonNormal">@color/lonodev_colorButton1</item>
<item name="android:textColor">@color/lonodev_colorTextButton1</item>
</style>
<style name="AppTheme.Button2" parent="Widget.AppCompat.Button.Colored">
<item name="colorButtonNormal">@color/lonodev_colorButton2</item>
<item name="android:textColor">@color/lonodev_colorTextButton2</item>
</style>
`
8. you can change the text or add a new translated ( the dialog is translated by default to only 3 languages Fr,Ar,Uk) by adding in your strings.xml :
`
<string name="eu_consent_text">Dear user!\n\nWe use Google Admob to show ads. Ads support our work, and enable further development of this app. In line with the new European Data Protection Regulation (GDPR), we need your consent to serve ads tailored for you.</string>
<string name="eu_consent_question">Can your data be used to show ads tailored for you?</string>
<string name="eu_learn_more">Learn how your data is used</string>
<string name="eu_google_partners">Google and its partners:</string>
<string name="eu_consent_yes">Yes, continue to show relevant ads</string>
<string name="eu_consent_no">No, show ads that are irrelevant</string>
<string name="eu_consent_change_setting">You can change this setting anytime in the \"About\" window.</string>
<string name="eu_thank_you">Thank you!</string>
<string name="eu_privacy_policy" >Privacy Policies </string>
<string name="eu_dialog_close" >close</string>
<string name="eu_Text2_learn_more">" Policies for"</string>
<string name="eu_Text3_learn_more">Terms and Policies of Providers</string>
`
- you can change the default logo in the dialog :
` custom = new GDPRLib.Builder(this) .addCallBack(this) .addLayoutInflater(getLayoutInflater()) .addPrivacyPolicy("http://your.policy.com/Policy.html") .addPublisherId("pub-23333339827608") .addDrowableId(R.drawable.ic_launcher_background) //change the drawable on top of the dialog .build();
` ##SCREENSHOTS