1
votes

in my project i am using voice recognition. i want to take the result of that class and pass it another class. But because this class is not an activity class, i cant use intent. the codes i use in voice recognition are like that:

protected void onActivityResult(int requestCode, int resultCode, Intent data) {

     if (requestCode == REQUEST_CODE && resultCode == RESULT_OK){
         ArrayList<String> matches = new ArrayList<String>();
    matches = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);


    if(matches.size()>0)  {
         result = matches.get(0);}}

I want to take that result and use another class which is not an activity class. So please help me

3

3 Answers

0
votes

You need to save the data. For this you can use SQlite, SharedPreference or static variable..

0
votes

you can define the setters/getters inside that normal class. Later on, retrieve the value by using that setter method of that class through object.

0
votes

You can declare you ArrayList as a static one like this,

public static ArrayList<String> array = new ArrayList<String>(); 

By doing this you can access your ArrayList from anywhere by

activity_name.array;

where activity_name is the activity or class in which you declare the static ArrayList