I want to have an activity that can only be launched from certain other activites in my app, and not from others
At the moment, this works:
public abstract class Launcher extends Activity {
protected static boolean flag = true;
protected abstract void Launch();
public static class myPrivateActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if(flag)
finish();
setContentView(R.layout.main);
}
}
}
public class SpecialActivity extends Launcher {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.newlayout);
}
@Override
protected void Launch {
flag = false;
Intent i = new Intent(Intent.ACTION_VIEW);
String name = myPrivateActivity.class.getName();
i.setClassName(this, name );
startActivity(i);
//finish();
}
}
and in android manifest
<activity android:name=".Launcher$myPrivateActivity"
android:label="Private?">
However, I'd like to know if there is a better solution than just using a flag?