Android: Two actvities as launchers

80 views Asked by At

I'm developing locker application. I created service and receiver to hide default android locker. But for few days I have problem with settings activity. I'm looking for a solution, how to make two activites as launchers. I want to make something like that: Locker activity is only launched when phone is locked. And Settings activity only when I press app icon in menu. Is it possible to programme? Thanks for help.

2

There are 2 answers

0
leandrocastelli On

You can use just one activity as launcher and use Fragments to load what you want. Something like this:

public class LauncherActivity extends FragmentActivity {
super.onCreate(savedInstanceState);

Fragment fragment;
if (isLocked()) {
    fragment = new LockerFragment();
}   
else {
    fragment = new SettingsFragmentFragment();
}
getFragmentManager().beginTransaction().add(R.id.container_id,fragment).commit();

}

1
Diego Bezerra On

You can try to launch the same activity but changing the content view (into onCreate) for each situation. Something like:

if (isLocked()) {
    setContentView(R.layout.locker_activity);
} else {
    setContentView(R.layout.settings_activity);
}