First off, I did post this to the android google group first but its moderated and I'm not sure how long itll take to show up there so hoping someone here can help.
I created a simple app with a ListView following the ListActivity examples I found on the net.
The app has 2 activities with the first having a button to create the second. When i hit the close button on the second activity I would like it to release its memory (or at least allow it to be garbage collected). Currently it will never release.
I must be doing something wrong here because the MyListActivity never gets released. Can anyone tell me if I am doing something wrong with the way my activities are created/destroyed? or if my usage of the ListView is wrong?
Thanks.
My App as a zip - http://www.mediafire.com/?l26o5hz2bmbwk6j
Screen Shot of Eclipse MAT showing the list activity never releasing memory - www.mediafire.com/?qr6ga0k
public class MyListActivity extends ListActivity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.listlayout);
ListAdapter ada = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1, GENRES);
setListAdapter(ada);
}
@Override
public void onDestroy()
{
super.onDestroy();
System.gc();
}
public void ClickHandler(View target)
{
switch (target.getId())
{
case R.id.LL_Btn1:
finish();
break;
}
}
private static final String[] GENRES = new String[] {
"Action", "Adventure", "Animation", "Children", "Comedy", "Documentary", "Drama",
"Foreign", "History", "Independent", "Romance", "Sci-Fi", "Television", "Thriller"
};}
public class MainActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
public void ClickHandler(View target)
{
switch (target.getId())
{
case R.id.M_Button01:
Intent intent = new Intent();
intent.setClassName(MyListActivity.class.getPackage().getName(), MyListActivity.class.getName());
startActivity(intent);
break;
}
}}