views:

152

answers:

3

Hello,

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 start 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

A: 

Since you're doing this in onCreate, did you call super.onCreate before (attempting to) starting this new Activity?

Adam
yes. but as I said the issue is not where I start the activity C. thank you
mnish
A: 

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).

Rich
agreed, if we could see the code for your B.onCreate and B.startC, you might be mission an initialization.
Adam
Thank you Rich, you were right.
mnish
A: 

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));
Moons