문제

I have a Bus timetable app with a lot of activity (around 120). It is working smoothly, but after opening several activities, it gets slower. So I have buttons that opens an other activity. I want to kill the former activity after the other is opened. How can I make it? Thanks in advance.

My button click action:

addListenerOnButton();
}


public void addListenerOnButton() {

final Context context = this;

button101 = (Button) findViewById(R.id.button101);

button101.setOnClickListener(new OnClickListener() {

    @Override
    public void onClick(View arg0) {

        Intent intent = new Intent(context, B10oda.class);
        startActivity(intent);   
    }
});
도움이 되었습니까?

해결책

Call finish()

Intent intent = new Intent(context, B10oda.class);
startActivity(intent);
finish();

But think again if you really want to finish the Activity. You could do some profiling and find out why your app is running slow.

Also 120 Activities seems too much. See if you could change your design and reduce the number of Activities.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top