Closed GoogleCodeExporter closed 8 years ago
Solved it! Found out that to call an activity from a non-activity context had
to create the construtor of the setup to get the Context, use that to call the
startActivity and also pass a FLAG_ACTIVITY_NEW_TASK on the intent. Here's and
example if anyone wants to do it and doesn't know how:
public GameSetup(Context context) {
this.context = context;
}
and then wherever you want to do it:
Intent newActivity=new Intent(getActivity(),exampleActivity.class);
newActivity.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(newActivity);
My best regards,
Dourado
Original comment by dourado...@gmail.com
on 6 Feb 2012 at 5:19
From anywhere in the setup you should be able to call
getActivity().startActivity(new Intent(getActivity(), MyOtherActivity.class));
i think if you call startActivity via an activity and not a context object the
flag is not necessary. Can you try this? For me it always worked but maybe you
have a scenario which I never had.
You might also want to read the javadoc of the system/ActivityConnector.java
class (and maybe take a look into the code), I created this class to make it a
little easier to pass objects between activities without storing them in any
static fields.
Original comment by simon.heinen
on 6 Feb 2012 at 11:23
Hi there Simon, sorry for the delay in responding but I only had the chance to
test your way a few moments ago and it also works great! And yes you are right,
the flag is not needed if the context object isn't used. I will read the
javadoc and also check that class ;).
Thank you for your quick response and for providing such a nicely built
framework :)!
My best regards,
Dourado
Original comment by dourado...@gmail.com
on 7 Feb 2012 at 4:44
No problem :)
Original comment by simon.heinen
on 7 Feb 2012 at 2:08
Original issue reported on code.google.com by
dourado...@gmail.com
on 6 Feb 2012 at 3:24