1

In my android project, I have 2 Activities. How can I launch an Activity from an Activity. I know I can do 'startActivity', but my activity has NOT registered for any Intent, is there anyway I can still launch it from my activity?

Thank you.

2 Answers 2

5
startActivity(new Intent(this, MyOtherActivity.class));
2
  • 3
    Just as a follow-up, generally the "android way" is to implement anonymous inner classes for things such as button click handlers and other things of that nature. In those cases a simple "this" will cause an error. I forced myself to get in the habit of typing the name of the class I was currently in and then "this", so if I was starting an activity from "MyMainActivity" it would read like this: startActivity(new Intent(MyMainActivity.this, MyOtherActivity.class));
    – MattC
    Sep 1, 2009 at 1:44
  • 2
    Also note, you won't have to list an intent filter for it, but it'll still have to be listed in the manifest. Sep 1, 2009 at 6:48
1
startActivity(new Intent(this, MyOtherActivity.class));

or

startActivityForResult(intent, requestCode)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.