我试图在我的应用程序关闭时关闭通知,因为当我从(最近的任务/滑动退出)关闭应用程序时,通知仍然出现,如果用户尝试单击通知,应用程序将崩溃。
@Override
protected void onDestroy() {
super.onDestroy();
notification.cancel(1);
try {
MApplication.sBus.unregister(this);
} catch (Exception e) {
e.printStackTrace();
}
}
Run Code Online (Sandbox Code Playgroud)
inonDestroy()但不起作用,因为onDestroy()不是每次都调用。
我正在尝试通过使用谷歌的新同意 SDK将GDPR 同意 添加dialog到我的应用程序中,(我不住在欧盟)但是当我运行它时我不能这是我的代码对话框不会打开,我尝试使用 VPN 但仍然没有出现相同的对话框
/*GDRP*/
ConsentInformation consentInformation = ConsentInformation.getInstance(this);
String[] publisherIds = {"pub-xxxxx...."};
consentInformation.requestConsentInfoUpdate(publisherIds, new ConsentInfoUpdateListener() {
@Override
public void onConsentInfoUpdated(ConsentStatus consentStatus) {
}
@Override
public void onFailedToUpdateConsentInfo(String errorDescription) {
}
});
URL privacyUrl = null;
try {
// TODO: Replace with your app's privacy policy URL.
privacyUrl = new URL("URL");
} catch (MalformedURLException e) {
e.printStackTrace();
// Handle error.
}
form = new ConsentForm.Builder(this, privacyUrl)
.withListener(new ConsentFormListener() {
@Override
public void onConsentFormLoaded(){
showForm();
} …Run Code Online (Sandbox Code Playgroud)