I have a UI-less MainActivity
, which holds certain logic to determine if the user is already logged in or not. If the user is logged in, I am starting HomeActivity
and if not, then LoginActivity
. Even though the logic is working fine, I am seeing that the MainActivity
does start for a brief while before switching to desired activity. Is there any way to avoid bringing up MainActivity
altogether as it causes an annoying flicker ?
Here is my code (omitting the logic) -
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (condition) {
intent = new Intent(this, HomeActivity.class);
} else {
intent = new Intent(this, LoginActivity.class);
}
startActivity(intent);
finish();
}
}
Thanks in advance.
Edit
This is what I have in my android manifest -
<activity
android:name="org.step.main.MainActivity"
android:label="@string/app_name"
android:launchMode="singleInstance" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>