As the title stated above, I've had no idea what else to do. When I click the run button the app starts in a wrong activity, but when I clear the app data and cache and start manually on my phone it shows the intended activity I wanted. This is my manifest
<application
android:allowBackup="true"
android:icon="@drawable/icon_logo"
android:label="@string/app_name"
android:roundIcon="@drawable/icon_logo"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".SplashScreen"
android:theme="@style/MyThemeNoBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".MainActivity" />
<activity
android:name=".LoginActivity"
android:label="@string/title_activity_login" />
The app will directly go to MainActivity where it's based on Tabbed Activity from the template of Android Studio.
EDIT
Here is my SplashScreen code
public class SplashScreen extends AppCompatActivity {
SharedPreferences settings;
@Override
protected void onCreate(Bundle savedInstanceState) {
//Create SharedPreferences to store token
settings = getSharedPreferences("token", Context.MODE_PRIVATE);
//Check if user session is stored or not
if (settings.getBoolean("connected", true)) {
/* The user has already login, so start the dashboard */
Intent intent = new Intent(SplashScreen.this, MainActivity.class);
startActivity(intent);
finish();
}
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash_screen);
Thread myThread = new Thread(){
@Override
public void run() {
try {
sleep(3000);
Intent intent = new Intent(SplashScreen.this,MainActivity.class);
startActivity(intent);
finish();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
};
myThread.start();
}
}
EDIT
OK, the flow of my app should be like this SplashScreen -> MainActivity -> LoginActivity. Currently the app skip past SplashScreen and goes directly to MainActivity. Below are my build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "26.0.0"
defaultConfig {
applicationId "com.public.test"
minSdkVersion 19
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:26.+'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:design:26.+'
compile 'com.auth0.android:jwtdecode:1.1.1'
compile 'com.android.volley:volley:1.0.0'
compile 'com.google.android.gms:play-services-maps:11.0.2'
compile 'com.android.support:support-v4:26.+'
compile 'com.android.support:support-vector-drawable:26.+'
testCompile 'junit:junit:4.12'
}