atom feed1 message in com.googlegroups.android-developers[android-developers] The specified ch...
FromSent OnAttachments
DikersNov 13, 2008 5:49 pm 
Subject:[android-developers] The specified child already has a parent. You must call removeView() on the child's parent first.
From:Dikers (dik@gmail.com)
Date:Nov 13, 2008 5:49:41 pm
List:com.googlegroups.android-developers

I want to start 'MultiActivity' from 'OtherActivity' that in another application, and when I back to homescreen (don't close 'MultiActivity' ), start 'MultiActivity' again, need to save the state of 'MultiActivity'.

but when running in backLayout.updateViewLayout(backgroundView, blp); setContentView(backLayout);

Something has gone wrong.

java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.

at android.view.ViewGroup.addViewInner(ViewGroup.java:1785 ) at android.view.ViewGroup.addView(ViewGroup.java:1680) ...... at com.android.internal.policy.impl.PhoneWindow.setContentView (PhoneWindow.java:261) at android.app.Activity.setContentView(Activity.java:1581)

Does anyone know what's wrong with this app, Thanks in advance!

----------------------- MultiActivity.class------------------------------------

private static AbsoluteLayout backLayout = null; private static ImageView backgroundView = null;

public void onCreate(Bundle icicle){

super.onCreate(icicle);

LayoutParams blp = new AbsoluteLayout.LayoutParams( 200, 300, 0, 0);

if(backLayout==null){

backgroundView = new ImageView(this); backgroundView.setImageResource(R.drawable.background);

backLayout = new AbsoluteLayout(this); backLayout.addView(backgroundView, blp); setContentView(backLayout);

}else {

backLayout.updateViewLayout(backgroundView, blp); setContentView(backLayout);// occur exception.

}

// Intent intent = getIntent(); if( intent.hasExtra("data")){ String data = intent.getStringExtra("data"); doSomething(data); }

}

-------------------------------------------------------------------------

------------------------ AndroidManifest.xml---------------------------------- <activity android:name=".MultiActivity" android:theme="@android:style/ Theme.Dialog" android:label="@string/app_name"> <intent-filter>

<action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <data android:mimeType="vnd.android.cursor.item/ vnd.dikers.test" />

</intent-filter> </activity>

---------------------OtherActivity.class in another application.--------------------- Intent intent = new Intent();