0

I found many tutorials on how to use VoiceInteractor I applied

VoiceInteractor.PickOptionRequest.Option[] options = {option1, option2};
            VoiceInteractor.Prompt prompt = new VoiceInteractor.Prompt("say cheese or you can say something else");
            VoiceInteractor voiceInteractor = getVoiceInteractor();
            boolean b = voiceInteractor.submitRequest(new PickOptionRequest(prompt, new PickOptionRequest.Option[]{option1, option2}, savedInstanceState) {
                @Override
                public void onPickOptionResult(boolean finished, Option[] selections, Bundle result) {
                    if (finished && selections.length == 1) {
                        Intent intent = new Intent(FullscreenActivity.this, ScrollingActivity.class);
                        startActivity(intent);

has given me enough delay, when I keep getting the exception

 E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.ai.asni_assistant, PID: 17454
    java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.app.VoiceInteractor.submitRequest(android.app.VoiceInteractor$Request)' on a null object reference
        at com.ai.asni_assistant.FullscreenActivity$2.onClick(FullscreenActivity.java:87)
        at android.view.View.performClick(View.java:6597)
        at android.view.View.performClickInternal(View.java:6574)
        at android.view.View.access$3100(View.java:778)
        at android.view.View$PerformClick.run(View.java:25885)
        at android.os.Handler.handleCallback(Handler.java:873)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:193)
        at android.app.ActivityThread.main(ActivityThread.java:6669)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
I/Process: Sending signal. PID: 17454 SIG: 9
Disconnected from the target VM, address: 'localhost:50320', transport: 'socket'

I am ready to share information on what i'm working on if someone has another solution to that exception or it's something within another part of the code

that is the part of the code for the permissions

if (ActivityCompat.checkSelfPermission(this, Manifest.permission.READ_CALENDAR) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.INTERNET) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.RECORD_AUDIO) != PackageManager.PERMISSION_GRANTED) {
        builder.show();
        requestPermissions(new String[]{Manifest.permission.RECORD_AUDIO, Manifest.permission.INTERNET, Manifest.permission.READ_CALENDAR}, 3);
        return;
    }

It did pop up once for audio recording permissions but it didn't do it for the internet and I know why and for the calendar but that was ambigious.

it is 3 hours until now since I got the crash with null pointer exception.

Jim Garrison
  • 85,615
  • 20
  • 155
  • 190
Adh Far
  • 41
  • 6
  • 1
    The error is your method `getVoiceInteractor()` returned `null`. – Jim Garrison Feb 17 '21 at 17:28
  • I added from the answer on the question at https://stackoverflow.com/questions/65106668/why-getvoiceinteractor-returns-null and it solved the problem. – Adh Far Feb 17 '21 at 17:36

0 Answers0