user3415221 user3415221 - 10 months ago 46
Android Question

when is countdown start push data into array java

I am use frequency detector and when frequency will high i want start countdown with 10 $ and collect high frequency into data array.

if(maxAmpFreq > 3000){

new CountDownTimer(10000, 1000) {
String test = String.valueOf(maxAmpFreq);
ArrayList<String> mylist = new ArrayList<String>();

public void onTick(long millisUntilFinished) {
Log.i("tag","A Kiss after 5 seconds");



public void onFinish() {
Log.i("tag","your test is......"+mylist);


but this not working correctly please guild me to solve this.


Problem is You declare your ArrayList Locally , That's why it have only one value at last. Every time its create new ArrayList .

Declare globally ....

private    ArrayList<String> mylist = new ArrayList<String>();

and use in the method for adding the value...


NOTE:- Try to declare variable globally, which is used in whole class methods.