Reputation:
I have an app with a sign-up/sign-in and a home activity. If user is new or logged out, I want to open the first activity otherwise the home activity. What I did was make Sign-in activity as launcher and checked if the user is logged in. If he is, the Home activity is started.
The problem is when the user is logged in, the app opens the launcher activity and then changes to the Home activity. The transition is easily visible.
Can I create a java class as a launcher to check which activity I should run first? Or any other solutions?
Upvotes: 0
Views: 276
Reputation: 986
You could have your launcher Activity be a delegate. For example:
public class LaunchDelegate extends Activity {
public void onCreate(Bundle args) {
//check SharedPreferences or whatever to
//determine which Activity to launch
}
}
Something like this in AndroidManifest.xml:
<activity
android:name=".LauncherDelegate"
android:noHistory="true"
android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
Upvotes: 0
Reputation: 5892
No, what you propose is not doable. A possible solution to your problem could be create a transparent activity using styles, put it as a launcher activity and make there the decision on which activity to open. With this behaviour the user will not notice that change. Be careful to make that decision synchronously to avoid the user being blocked.
Upvotes: 1