android startactivity
I have an application that contains 3 activities A, B and C. The activity A is the one that gets started when I start my app. From A I start B using mIntent.setClass(A.this, B.class);
, then startActivity(mIntent);
this goes well. What goes wrong is when I want to star开发者_如何转开发t the activity C from B.
this how the manifestfile looks like:
<activity android:name=".B"/>
<activity android:name=".C"/>
I know that I can do the follwoings: start B from A and then from B go back to A and then start C
or let B has its own manifestfile thus a stand lone app, and let C be an activity within this app.
Any suggestion is welcome. My apoligies for my bad english.
thank you
The error you posted in the comments is a NullPointerException which means some variable you're calling a method on (or attempting to access a property of, etc) has not yet been instantiated. Is it possible that you're declaring mIntent but not setting it to a new Intent before calling setClass? Post the code for class B, and it should be pretty easy to figure out (NullPointerExceptions usually are).
mIntent goes null if you don't get it in your B activity. So inside B, you shloud initialize mIntent.
You can do this for instance
startActivity(new Intent(this, C.class));
Since you're doing this in onCreate, did you call super.onCreate before (attempting to) starting this new Activity?
精彩评论