How to make intermover ads admob run only when you log into the application (that is, in one activation), and after returning to the same activation (initial) it did not start?
1 answer
@ alex11 , You need to read about Activity Life Cycle (link to Start Android), as well as about SharedPreferences (link to the same site).
I would do this:
1. Created a SharedPreferences file.
2. Created in it a variable isFirstVisit of type boolean, which would be responsible for the first visit of the application by the user.
3. The variable isFirstVisit would set the default value to true (i.e., initially, we first enter).
4. At the starting Activity I set the condition:
if (isFirstVisit == true) { // если верно // здесь указать нужно будет код для баннера adMob // в конце добавить следующее isFirstVisit = false; // т.е. мы посетили Activity и сохраняем это в переменной (говорим, что нет, это не первое посещение) } else { // иначе adView.setVisibility(View.GONE); // то есть скрываем рекламный баннер. } As a result, this will work for the case, if you specify the transition to the first Activity via intent, and do not register additional. Back button with onBackPressed method.
UPD 1: and would add the onDestroy () method for the first Activity, in which I would set the isFirstVisit variable to true. That is, when the application is closed, the activity is destroyed. As a result, at the new entrance there will again be a check on the first entrance and everything will be all around.
The idea is simple. You can implement it. If I made a mistake in some nuance, then it can be easily corrected when testing the application.