Julian Julian - 2 months ago 13
Android Question

Android Custom Listener

Today I meet with a question about custom listener. I have try to search and think for a long time, but I have not find answer. I'm come here for help. The question is that How to transfer data between Activities by Android Custom Listener?

Answer

Do not transfer data between activities through custom listener because only one activity is active. Android application shouldn't work like that.

Use Bundle to send data between activities instead.

Intent intent = new Intent(this, YourActivity.class);
intent.putExtra("key", yourValue);
startActivity(intent);

Inside YourActivity:

getIntent().getExtras().getString("key");