Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
138 views
in Technique[技术] by (71.8m points)

android - In-App Purchase remove ads

I have implemented ads in one of my apps and I want to make a in-app purchase feature to remove them. How would I do this.

I was thinking a simple way, was to hide the ads by making in invisible, after purchase. Could that work or is there an easier/better way?

I have no idea how to use the in-app feature for any purpose. Could anyone show me the way to code or something to read on this?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

It depends on how you inserted the ads in the first place. If you did it via code, then just put an if(removed ads == false) around the code that inserts ads.

If you did it via XML, then the best way to do it is to copy out your XML, without the adview, and in your code use if surrounding all of your setContentView(R.layout.example)

Here's an example of what I mean

if (adsDisabled == true){
    setContentView(R.layout.mainNoAds)
} else{
    setContentView(R.layout.main
}

In-app purchases -

http://developer.android.com/guide/google/play/billing/billing_overview.html

In this post I assumed you are using admob, but the same should be true for all companies

On last thing - using adView.View.GONE IS bad practice **DO NOT ** do that


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...