0

I have a class that performs optical character recognition on images and extract out the text.

For example:

  1. ClassA: Performs OCR and sends extracted text to ClassB
  2. ClassB: Receive extracted text from ClassA and output the results in EditText

However, now I want to add another process to this system:

  1. ClassA: Performs OCR and sends extracted text to ClassC
  2. ClassC: Receive extracted text from ClassA and perform a 2nd process to extract out more specific text; then sends to ClassB
  3. ClassB: Receive extracted text from ClassC and output the results in EditText

However, I am unable to successfully send an intent from ClassA to ClassC.

The problem is not how ClassA send the intent, but how ClassC will receive the intent as the receiving method is quite complicated

Let's say the method in ClassC to do the 2nd process is "EmailValidator()", how do I edit the codes in ClassC so that is would receive the extracted text from ClassA?

Below is the codes in ClassB as of how it currently receive the extracted text from ClassA:

public class CreateContactActivityOCR1 extends Activity {

    private String recognizedText, textToUse;
    private EditText mEditText1;
    private String mFromLang, mCurrentLang;


    private void setupUI(){

        // Setting up the textbox

        mEditText1 = (EditText)findViewById(R.id.EmailET);
        mEditText1.setText(textToUse);

    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_createcontact);

        // Getting the path of the image to show
        Bundle extras = this.getIntent().getExtras();
        recognizedText = extras.getString("TEXT");
        textToUse = recognizedText;

        // Getting the language used for text recognition
        mFromLang = extras.getString("LANG");
        mCurrentLang = mFromLang;
        //Log.i(TAG, mFromLang);

        setupUI();


    }

    @Override
    public void onConfigurationChanged(Configuration newConfig) {
        textToUse = mEditText1.getText().toString();
        super.onConfigurationChanged(newConfig);
        setContentView(R.layout.usetext);
        setupUI();
        //Log.i(TAG, "onConfigChanged");
    }


}

Note that it is able to receive the text from ClassA and display in EditText. What I want to achieve now is to pass this extracted text(known as recognizedText in the codes) into the method "EmailValidator()" in ClassC.

So how should ClassC receive the extracted text from ClassA, by manipulating the receiving method from ClassB?

Daniel Louis
  • 63
  • 1
  • 1
  • 6
  • You already receiving text in the above code and that's what you need in the other class to receive text too. – Eslam El-Meniawy Jan 20 '16 at 09:45
  • @Eslam El-Meniawy What i want to know is how do I change the above codes to pass the results to the method "EmailValidator()" within ClassC, rather than displaying it in EditText as shown above. – Daniel Louis Jan 20 '16 at 09:53
  • Make `ClassC` an inner class of `ClassB` or make that function you want to call public and add `Constructor' to its class and from the other class make object and use it to call the function like in [this answer](http://stackoverflow.com/a/10787205/4983861). – Eslam El-Meniawy Jan 20 '16 at 09:59

0 Answers0