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

by Dikers » Fri, 14 Nov 2008 09:50:19 GMT


Sponsored Links
 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();

        intent = new Intent(Intent.ACTION_VIEW);
        intent.setType("vnd.android.cursor.item/vnd.dikers.test");
        intent.putExtra("data", "data");
        startActivity(intent);
--~--~---------~--~----~------------~-------~--~----~



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

by gsmd » Sun, 15 Mar 2009 22:18:04 GMT


 This is the IllegalStateException thrown from onCreate() that brings
the main activity of my app down upon restart (e.g. launch app -> hit
back -> launch again -> got it).
Could someone elaborate on what does this exception mean?
--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


Other Threads

1. Do not understand the Android contribution scheme

I'm working with pretty advanced stuff using XML schemas etc.
Such support is not to be found in the current docs.

But in the source rep I found this:
http://git.source.android.com/?p=platform/external/libxml2.git;a=tree

My question is:
- Has this been granted as a part of the future Android platform?
- Will this package offer Java bindings?

Anders
--~--~---------~--~----~------------~-------~--~----~

2. AACPlus - Decoding a Stream? - Anyone Shoutcast?

Hello Androids!

So lets get Radio Streaming working! First to those that are experts.
The G1 phone supports AAC file types... but not sure if AACPlus? or
are we talking about the same thing? Do we need decoder support? Is
there any decoder support on the MediaPlayer?

So I was looking into making an ACCPlus V1 or V2 radio stream readable
by the MediaPlayer but apparently it doesn't work...
if I store a few Kbytes of this stream into a file than try to play it
on my computer it works...  If I try playing that file on my G1
phone... no luck...

So at this point I know I'm getting the right data...

Now how do we decode this stream to be MediaPlayer readable on
android? I guess this will get us on the right path to Radio
Streaming...

Thanks
Jona

--~--~---------~--~----~------------~-------~--~----~

3. RingtoneManager URIs

4. What happened to ADC 2?

5. Need to resolve .APK not found error.

6. Best way to build multi page form

7. How to use oprofile on android?