SplashScreen.java
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Handler;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
public class SplashScreen extends AppCompatActivity {
SharedPreferences sharedPreferences;
Boolean firstTime;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash_screen);
sharedPreferences = getSharedPreferences("MyPrefs",MODE_PRIVATE);
firstTime = sharedPreferences.getBoolean("firstTime",true);
if (firstTime){
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
SharedPreferences.Editor editor = sharedPreferences.edit();
firstTime = false;
editor.putBoolean("firstTime",firstTime);
editor.apply();
Intent i = new Intent(SplashScreen.this,MainActivity.class);
startActivity(i);
finish();
}
}, 5000);
}
else {
Intent i = new Intent(SplashScreen.this,MainActivity.class);
startActivity(i);
finish();
}
}
}
MainActivity.java
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.abhishekpanwar.splashscreentutorial">
<application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
</activity>
<activity android:name=".SplashScreen">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
</manifest>
thanks
ReplyDeleteThanks
ReplyDeleteFeedBurner
ReplyDeleteThe feed does not have subscriptions by email enabled
i can't fetch any data without making a class for each url and activity WTF?
ReplyDeletethanks
ReplyDeleteThe Borgata Hotel Casino & Spa Announces a $200 Million
ReplyDeleteThe Borgata 광양 출장마사지 Hotel Casino & Spa in 군산 출장안마 Atlantic City will open daily 24 hours, 충주 출장샵 with casino and bingo 전라북도 출장안마 sections available daily 24 hours a 제주 출장샵 week.