Destroy View Objects

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

Destroy View Objects

Postby kokmok » Tue Jul 07, 2009 10:11 am

Hi all,
I'm totally new in android and java (I'm flash developper) and i have a problem with managing the views.
I tried to make a little game, the structure is
the Main class extends activity
a FrameLayout
a View
Thread
Multiples bitmaps

when the game is over, i want to destroy Objects.
I tried Bitmap objects = null;
MyThread = null;
the View = null;

It fails and the program shut down.
I can't use de eclipse DDMS because I use sensors and I developped in 1.5

does anybody can help me?
kokmok
Freshman
Freshman
 
Posts: 7
Joined: Thu Jul 02, 2009 11:57 am

Top

Postby Shone » Wed Jul 15, 2009 3:15 pm

Hi,

Why destroy objects? Java will take care of that.
Shone
Freshman
Freshman
 
Posts: 3
Joined: Tue Jul 14, 2009 10:59 am

Postby kokmok » Wed Jul 15, 2009 3:27 pm

Hi, thanks for answering,
the problem is that when I launch again my view,
several attributes of my paints are not resetted .
I instancied them again but for exemple their alpha stayed to 0.

i'm still searching a solution... :)
kokmok
Freshman
Freshman
 
Posts: 7
Joined: Thu Jul 02, 2009 11:57 am

Postby kokmok » Wed Jul 15, 2009 4:45 pm

Re,
I found my problem but not my solution :)
I don't kill any objects manually, i just change the setContentView
my friend google told me when that's done, java kills the obsolete objects.

But, a View object launched a thread, who is still alive,..
the Thread affects other view Objects and when i have to re put these view objects,..
the thread (that i wanted dead) is still affecting my new objects. can I kill manually this thread??
stop, interrupt and destroy are depreciated ..
I'm going tired of that.

please help,..







:cry:


:)
kokmok
Freshman
Freshman
 
Posts: 7
Joined: Thu Jul 02, 2009 11:57 am

Postby virtual » Thu Jul 16, 2009 11:06 am

If you want to kill a thread...

volatile boolean isRunning = true;

In thread's run

while(isRunning){
// do something
}

In Activity's onDestroy()

isRunning = false; // this will kill that thread

Enjoy :)
Regards,
Virtual
virtual
Developer
Developer
 
Posts: 26
Joined: Tue Mar 24, 2009 11:20 am

Postby kokmok » Thu Jul 16, 2009 11:21 am

Thanks a lot.. it works fine now.. 8)
kokmok
Freshman
Freshman
 
Posts: 7
Joined: Thu Jul 02, 2009 11:57 am

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 9 guests