I'm building a group of apps as a package similar to MS Office. Here each app has its own launcher as well as it can be launched from inside the home app. Each app has a login page. I need to display the login page when the app is launched from android launcher and not showing login page while launch from home app, How can i achieve this?
My scenario:
From Launcher----->(App)Login page--->(App)Home screen
From Home app----->(App)Home screen
You can do that by launching an empty activity
(with no UI) and in its OnCreate
method depending on some variable information (You can use SharedPreferences
perhaps for that purpose) you can decide which Activity
to start (Login or Home Screen app).
PS:
Btw if the login always leads to the same activity (Home Screen and is not used to login somewhere else) you don't even need the empty activity, you can check this in the Oncreate
method of the login activity
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
if (logged_in_check_is_true)
{
Intent intent = new Intent(this, HomeScreenActivity.class);
this.startActivity (intent);
this.finishActivity (0);
}
...
You should always start LoginPageActivity
. But if you start it from your "home app" just pass special extra to activtiy:
public class LoginPageActivity extends Activity {
onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
boolean needLogin = getIntent().getBooleanExtra("need login extra", true);
if (!needLogin)
{
// start your home screen
}
//setup login page
}
}
In home app just pass "need login extra" as false.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With