Tic Tac Toe Game Android App with source code : Simple & Minimal Game . Classic Tic Tac Toe Game. You can play alone or with another player.
Features
- Java native source code
- AdMob Banner integrated
- AdMob Interstitial integrated
- Clear graphics
- Optimized for tablets
- Background music and sounds
How to Setup and Reskin this Tic Tac Toe game
- Install latest Android SDK
- Open Gradle project in Android Studio
- Change Package ID, App Name, icons, graphics and sounds
- Set up AdMob ID
- Build an APK file
MainActivity.java
package com.tictoctoe26.tictactoe;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.Button;
import android.widget.ImageButton;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import androidx.core.app.ActivityOptionsCompat;
import com.google.android.gms.ads.AdListener;
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdSize;
import com.google.android.gms.ads.AdView;
import com.google.android.gms.ads.MobileAds;
import com.google.android.gms.ads.initialization.InitializationStatus;
import com.google.android.gms.ads.initialization.OnInitializationCompleteListener;
import com.google.firebase.analytics.FirebaseAnalytics;
public class MainActivity extends AppCompatActivity {
private boolean Vibration ;
private FirebaseAnalytics mFirebaseAnalytics;
private static final String PREFS_NAME = "vibration";
private static final String PREF_VIBRATION = "TicVib";
private AdView mAdView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
AdView adView = new AdView(this);
adView.setAdSize(AdSize.BANNER);
adView.setAdUnitId("ca-app-pub-5761188730544100/5552190917");
MobileAds.initialize(this, new OnInitializationCompleteListener() {
@Override
public void onInitializationComplete(InitializationStatus initializationStatus) {
}
});
mAdView = findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build();
mAdView.loadAd(adRequest);
mAdView.setAdListener(new AdListener() {
@Override
public void onAdLoaded() {
// Code to be executed when an ad finishes loading.
}
@Override
public void onAdFailedToLoad(int errorCode) {
// Code to be executed when an ad request fails.
}
@Override
public void onAdOpened() {
// Code to be executed when an ad opens an overlay that
// covers the screen.
}
@Override
public void onAdClicked() {
// Code to be executed when the user clicks on an ad.
}
@Override
public void onAdLeftApplication() {
// Code to be executed when the user has left the app.
}
@Override
public void onAdClosed() {
// Code to be executed when the user is about to return
// to the app after tapping on an ad.
}
});
mFirebaseAnalytics = FirebaseAnalytics.getInstance(this);
Bundle bundle = new Bundle();
bundle.putString(FirebaseAnalytics.Param.ITEM_ID, "das");
bundle.putString(FirebaseAnalytics.Param.ITEM_NAME, "Dfasf");
bundle.putString(FirebaseAnalytics.Param.CONTENT_TYPE, "image");
mFirebaseAnalytics.logEvent(FirebaseAnalytics.Event.SELECT_CONTENT, bundle);
mFirebaseAnalytics.setUserProperty("favor","Das");
mFirebaseAnalytics.setCurrentScreen(this, "MainActivity",null);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
Window w = getWindow(); // in Activity's onCreate() for instance
w.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
}
Button Ai = findViewById(R.id.bt1);
Ai.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(MainActivity.this, NameActivity.class);
startActivity(intent);
}
});
Button ds = findViewById(R.id.bt2);
ds.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(MainActivity.this, TwoNameActivity.class);
startActivity(intent);
}
});
final ImageButton imageButton = findViewById(R.id.imageButton2);
imageButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(final View v) {
final Animation myRotation = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.rotate);
myRotation.setRepeatCount(0);
imageButton.startAnimation(myRotation);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
presentActivity(v);
}
}, 900);
}
});
}
public void presentActivity(View view) {
ActivityOptionsCompat options = ActivityOptionsCompat.
makeSceneTransitionAnimation(this, view, "transition");
int revealX = (int) (view.getX() + view.getWidth() / 2);
int revealY = (int) (view.getY() + view.getHeight() / 2);
Intent intent =
new Intent(this, SettingsActivity.class);
intent.putExtra(SettingsActivity.
EXTRA_CIRCULAR_REVEAL_X, revealX);
intent.putExtra(SettingsActivity.
EXTRA_CIRCULAR_REVEAL_Y, revealY);
ActivityCompat.
startActivity(this, intent, options.toBundle());
}
@Override
public void onBackPressed(){
Intent a = new Intent(Intent.ACTION_MAIN);
a.addCategory(Intent.CATEGORY_HOME);
a.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(a);
}
}
YOUTUBE VIDEO
SOURCE CODE CLICK HERE
Conclusion
We have successfully created Tic Tac Game in android studio application using Android Studio.
READ MORE ANDROID APPS
Wallpaper Android App- CLICK HERE
All IN ONE Status Saver App – CLICK HERE
Photo Video Maker Android App – CLICK HERE
Video Downloader Android App – CLICK HERE
College Student Portal System App – CLICK HERE
Call Recorder Android App – CLICK HERE
PDF App with firebase – CLICK HERE
BarChart Graph App – CLICK HERE
PDF Reader App with firebase – CLICK HERE
ShareIt Clone App – CLICK HERE
Material Design SignUp Form – CLICK HERE
Ludo Game Android App – CLICK HERE
Text on Photo Android App – CLICK HERE
Fast Pro VPN APP – CLICK HERE
3D Text Maker APP- CLICK HERE
WhatsApp Status Cleaner Saver app – CLICK HERE
ShareTweetShare