0

With my basic knowledge on Android, I'm trying to play with the Google voice APIs and followed the example here and to write an app, which would allow me to call a hardcoded number. Unfortunately i'm getting an error saying < identifier > expected, so i'm unable to check if my app even works. Can someone see what is missing here and also if i'm even going in the right direction with my thinking and code.

Java file:

public class MyVoiceActivity extends Activity {
class Confirm extends VoiceInteractor.ConfirmationRequest {
    public Confirm(String ttsPrompt, String visualPrompt) {
        VoiceInteractor.Prompt prompt = new VoiceInteractor.Prompt(
                new String[] {ttsPrompt}, visualPrompt);
        super(prompt, null);
    }

    @Override public void onConfirmationResult(boolean confirmed, Bundle null)    {
        if (confirmed) {
            call();
        }
        finish();
    }

};

@Override public void onResume() {
    if (isVoiceInteractionRoot()) {
        call();
    }

    Intent intent = new Intent(this, MyVoiceActivity.class);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    startActivity(intent);
    finish();
}

private void call () {
    try {

        final Intent callIntent = new Intent(Intent.ACTION_CALL);
        callIntent.setData(Uri.parse("tel:12345678"));
        startActivity(callIntent);
    } catch (ActivityNotFoundException activityException) {

    }
  }
}

AndroidManifest file:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.ccvoice.bt.examplevoice">

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">

    <activity
        android:name=".MyVoiceActivity" >
    <intent-filter>
        <action android:name="android.intent.action.CALL" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.VOICE" />
    </intent-filter>

    </activity>

</application>

</manifest>

The < identifier > required error i'm getting is in this line of the code:

public void onConfirmationResult(boolean confirmed, Bundle null) {

Thank you in advance.

Anish
  • 740
  • 4
  • 11
  • 27

1 Answers1

0

null is a reserved word and cannot be used as an identifier (eg. the name of a parameter). Use a different name for your Bundle parameter to that method.

public void onConfirmationResult(boolean confirmed, Bundle bundle) {
iagreen
  • 31,470
  • 8
  • 76
  • 90
  • Thanks that fixed that error but I got some more errors now. `Error:(16, 63) error: constructor ConfirmationRequest in class ConfirmationRequest cannot be applied to given types; required: Prompt,Bundle found: no arguments reason: actual and formal argument lists differ in length` `Error:(19, 18) error: call to super must be first statement in constructor` `Error:Execution failed for task ':app:compileDebugJavaWithJavac'. > Compilation failed; see the compiler error output for details.` – Anish Nov 27 '16 at 13:27