Firstly, I published this in the google android group at first, but moderated it, and I'm not sure how long it will take to appear there, so I hope someone here can help.
I created a simple ListView application after ListActivity examples that I found on the net.
The application has 2 actions with the first, which has a button to create the second. When I press the close button of the second operation, I would like it frees up its memory (or at least allows it to garbage collected). Currently it will never be released.
I have to do something wrong here because MyListActivity is never freed. Can someone tell me if I am doing something wrong with how my actions are created / destroyed? or if my use of ListView is wrong?
Thank.
My zip application is http://www.mediafire.com/?l26o5hz2bmbwk6j
Eclipse MAT screen shot showing list activity never releasing memory - www.mediafire.com/?qr6ga0k
public class MyListActivity extends ListActivity {
@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 {
@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;
}
}}