Wednesday, August 3, 2011

[android-developers] ERROR/AndroidRuntime(921): java.lang.StackOverflowError (if you have multiple activities)

Hi all!
I have
view plaincopy to clipboardprint?
public class SMK extends ActivityGroup implements OnClickListener {
...
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.praktisk:
Intent intent = new Intent(getApplicationContext(),
Praktisk.class);
replaceContentView("Praktisk", intent,
Intent.FLAG_ACTIVITY_CLEAR_TOP);
break;...

public void replaceContentView(String id, Intent newIntent) {
View view = getLocalActivityManager().startActivity(id,
newIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)).getDecorView();
this.setContentView(view);
}

and in my Praktisk activity
view plaincopy to clipboardprint?
tilbage.setOnClickListener(new View.OnClickListener() {

@Override
public void onClick(View v) {
Intent intent = new Intent(getApplicationContext(),
SMK.class);
SMK parentActivity = (SMK) getParent();
parentActivity.replaceContentView("SMK", intent,
Intent.FLAG_ACTIVITY_CLEAR_TOP );
}
});

But if I click 4 times I get java.lang.StackOverflowError.
Can anyone help me?
Thank you in advance!

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment