如何阻止Adfree阻止我的应用中的广告?
  Adfree真的让我失望了作为Android开发者。我在市场上免费发布应用程序,我要求的是用户在使用我的应用程序时查看广告。我喜欢赚一点钱,而不是从我的用户口袋里取出来。我假设如果你在谷歌上发现这个,我认为这也困扰你。
我和我的一个伙伴写了一小段代码来测试用户是否在他们的手机上安装了Adfree。如果它恢复正面(安装了应用程序),它会通知用户他们的手机上已安装了adfree,并且为了使用该应用程序,他们必须将其卸载。然后它继续关闭应用程序,因此在Adfree消失之前用户无法使用该应用程序。
首先,将其放入OnCreate中:
adfreetest();
 现在,把这个代码放到你的应用程序的某个地方(它的模块化,所以它可以在任何应用程序中工作)
private void adfreetest() {
try{
ApplicationInfo info = getPackageManager()
.getApplicationInfo("com.bigtincan.android.adfree", 0 );
//-- application exists
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage("To Use this Application, You Must Uninstall Adfree.")
.setCancelable(false)
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
main.this.finish();
}
});
AlertDialog alert = builder.create();
alert.show();
} catch( PackageManager.NameNotFoundException e ){
//-- application doesn't exist
}
}
 确保在main.this.finish()中更改main;到你的活动名称。
如果您找到更好的方法,请发布!
没有找到相关结果
已邀请:
1 个回复
古擅坛犯