NullPointerException when going back through activities(In TabGroupActivity)

N

A little elaboration.

There are Activity A, B and C

You start A with Id “A”
then you start B with Id “B”
then you start C with Id “C”
and from C you again start another instance of B with id “B” (it may happen, because B may be a ResultListScreen which may called for several time with Load More type button)

The problem is that in ArrayList idList when you finish from last B

manager.destroyActivity( idList.get( index ), true );

line is called which destroys Activity having id “B”, which are 2 in stack. both B are deleted and C is pushed. and when you finish C and there is no B in the stack but its Id is available is ArrayList idList and you get its Activity which is null if not found.

That’s all.

id+=System.currentTimeMillis();

in this line of code you assign a unique id every time you start new Activity by using System’s current time.

You Can use this to solve your problem.


public void startChildActivity(String id, Intent intent) {
id+=System.currentTimeMillis();
//rest of your code.
}

About the author

abhijit.kurlekar
By abhijit.kurlekar

Category