package com.buratinoapps.imusictv;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.Toast;
import com.google.android.gms.ads.AdListener;
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdView;
import com.google.android.gms.ads.InterstitialAd;
import com.google.android.gms.ads.MobileAds;
import com.google.android.gms.ads.initialization.InitializationStatus;
import com.google.android.gms.ads.initialization.OnInitializationCompleteListener;
public class MainActivity extends AppCompatActivity {
private long backPressedTime;
private Toast backToast;
AdView adView;
private InterstitialAd mInterstitialAd;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button buttonMusicBox = findViewById(R.id.btn_music_box);
buttonMusicBox.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(mInterstitialAd.isLoaded()){
mInterstitialAd.show();
}
else {
try {
Intent intent = new Intent(MainActivity.this, MusicBoxTv.class);
startActivity(intent);finish();
}
catch (Exception e){
}
}
}
});
Button buttonMusicTHT = findViewById(R.id.btn_tnt_music);
buttonMusicTHT.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(mInterstitialAd.isLoaded()){
mInterstitialAd.show();
}
else {
try {
Intent intent = new Intent(MainActivity.this, THTMusic.class);
startActivity(intent);finish();
}
catch (Exception e){
}
}
}
});
MobileAds.initialize(this, new OnInitializationCompleteListener() {
@Override
public void onInitializationComplete(InitializationStatus initializationStatus) {
}
});
adView = findViewById(R.id.adHomeBanner);
AdRequest adRequest = new AdRequest.Builder().build();
adView.loadAd(adRequest);
mInterstitialAd = new InterstitialAd(this);
mInterstitialAd.setAdUnitId("ca-app-pub-3940256099942544/1033173712");
AdRequest adRequest1 = new AdRequest.Builder().build();
mInterstitialAd.loadAd(adRequest1);
mInterstitialAd.setAdListener(new AdListener(){
@Override
public void onAdClosed(){
try{
Intent intent = new Intent(MainActivity.this, MusicBoxTv.class); startActivity(intent); finish();
} catch (Exception e){
e.printStackTrace();
}
}
});
mInterstitialAd.setAdListener(new AdListener(){
@Override
public void onAdClosed(){
try{
Intent intent = new Intent(MainActivity.this, THTMusic.class); startActivity(intent); finish();
} catch (Exception e){
e.printStackTrace();
}
}
});
Window w = getWindow();
w.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
//Системная кнопка начало
@Override
public void onBackPressed() {
if(backPressedTime + 2000 > System.currentTimeMillis()){
super.onBackPressed();
return;
} else{
backToast = Toast.makeText(this, "Click again to exit", Toast.LENGTH_SHORT);
backToast.show();
}
backPressedTime = System.currentTimeMillis();
}
//Системная кнопка конец
}
mInterstitialAd.setAdListener(new AdListener(){
@Override
public void onAdClosed(){
try{
Intent intent = new Intent(MainActivity.this, MusicBoxTv.class); startActivity(intent); finish();
} catch (Exception e){
e.printStackTrace();
}
}
});
mInterstitialAd.setAdListener(new AdListener(){
@Override
public void onAdClosed(){
try{
Intent intent = new Intent(MainActivity.this, THTMusic.class); startActivity(intent); finish();
} catch (Exception e){
e.printStackTrace();
}
}
});
package com.buratinoapps.imusictv;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.Toast;
import com.google.android.gms.ads.AdListener;
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdView;
import com.google.android.gms.ads.InterstitialAd;
import com.google.android.gms.ads.MobileAds;
import com.google.android.gms.ads.initialization.InitializationStatus;
import com.google.android.gms.ads.initialization.OnInitializationCompleteListener;
public class MainActivity extends AppCompatActivity {
private long backPressedTime;
private Toast backToast;
AdView adView;
private InterstitialAd mInterstitialAd;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button buttonMusicBox = findViewById(R.id.btn_music_box);
buttonMusicBox.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(mInterstitialAd.isLoaded()){
mInterstitialAd.show();
mInterstitialAd.setAdListener(new AdListener(){
@Override
public void onAdClosed(){
try{
Intent intent = new Intent(MainActivity.this, MusicBoxTv.class); startActivity(intent); finish();
} catch (Exception e){
e.printStackTrace();
}
}
});
}
else {
try {
Intent intent = new Intent(MainActivity.this, MusicBoxTv.class);
startActivity(intent);finish();
}
catch (Exception e){
}
}
}
});
Button buttonMusicTHT = findViewById(R.id.btn_tnt_music);
buttonMusicTHT.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(mInterstitialAd.isLoaded()){
mInterstitialAd.show();
mInterstitialAd.setAdListener(new AdListener(){
@Override
public void onAdClosed(){
try{
Intent intent = new Intent(MainActivity.this, THTMusic.class); startActivity(intent); finish();
} catch (Exception e){
e.printStackTrace();
}
}
});
}
else {
try {
Intent intent = new Intent(MainActivity.this, THTMusic.class);
startActivity(intent);finish();
}
catch (Exception e){
}
}
}
});
MobileAds.initialize(this, new OnInitializationCompleteListener() {
@Override
public void onInitializationComplete(InitializationStatus initializationStatus) {
}
});
adView = findViewById(R.id.adHomeBanner);
AdRequest adRequest = new AdRequest.Builder().build();
adView.loadAd(adRequest);
mInterstitialAd = new InterstitialAd(this);
mInterstitialAd.setAdUnitId("ca-app-pub-3940256099942544/1033173712");
AdRequest adRequest1 = new AdRequest.Builder().build();
mInterstitialAd.loadAd(adRequest1);
Window w = getWindow();
w.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
//Системная кнопка начало
@Override
public void onBackPressed() {
if(backPressedTime + 2000 > System.currentTimeMillis()){
super.onBackPressed();
return;
} else{
backToast = Toast.makeText(this, "Click again to exit", Toast.LENGTH_SHORT);
backToast.show();
}
backPressedTime = System.currentTimeMillis();
}
//Системная кнопка конец
}