I want to overwrite a view of RecognizerIntent in android. To do this, I try to extend the RecognizerIntent class in Android as follows:
package com.example.myapp;
import android.content.Context;
import android.speech.RecognizerIntent;
public class RecInt extends RecognizerIntent {
public RecInt(Context c) {
super(c);
//if I don't call super here, there is an error 'There is no default constructor available in RecognizerIntent'
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_recint);
}
}
But I am getting the error
RecognizerIntent() is not public in android.speech.RecognizerIntent, Cannot be accessed from outside package.
Is there any way I can still extend a non-public class?
I want to do this so that when RecInt is started
Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
startActivityForResult(intent,100);
the view in setContentView(R.layout.activity_recint) shows up, instead of the RecognizerIntent view.
The constructor is not public. The class is public
You can extend the class but you cant call
super. It is unclear why you are doing so, or giving a Context. It does not appear to provide that constructorPlus, that class is not an Activity , so all that onCreate code is just wrong