Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Android

How to navigate to another activity without errors

Hi,

When i do something in empty activity and when i navigate from one empty activity to another through back sign , then the app crashes , but if i do the same thing using blank activity it works fine ?

Ben Deitch
Ben Deitch
Treehouse Teacher

Please post your error as it appears in the Android Monitor.

David Aryeetey
David Aryeetey
6,258 Points

Hmmn I would need to know more. Nevertheless, the safe and smart way to start an activity is to use this bit of logic that let's you only start an activity if the appropriate activity exists:

if( intent.resolveActivity(getPackageManager())!= null ){ startActivity(intent); } Now in regards to the back button I would need to know more. However one thing you could do is check your android manifest file and see if for your activity element the appropriate parent_activity attribute value has been set. That parent activity is the original screen that when you press the back button it would go back to.