0

Android에 대한 기본적인 지식을 가지고 Google 음성 API를 사용하고 예제 here을 따르고 코드를 호출 할 수있는 앱을 작성하려고합니다. 불행히도 나는 < 식별자가 예상됨을 말하는 오류가 발생하므로 내 앱이 작동하는지 확인할 수 없습니다. 누군가가 여기에서 누락 된 것을 볼 수 있습니까? 그리고 또한 제 생각과 코드로 올바른 방향으로 가고있는 경우도 있습니다.Google Voice API 코드를 실행하는 중에 오류가 발생했습니다.

자바 파일 :

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를 파일 :

<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> 

내가 점점 해요 < 식별자> 필요한 오류 코드 줄에 있습니다

public void onConfirmationResult(boolean confirmed, Bundle null) { 

감사 사전에.

답변

0

null은 예약어로 식별자 (예 : 매개 변수 이름)로 사용할 수 없습니다. 해당 메서드에 대한 Bundle 매개 변수에 다른 이름을 사용하십시오.

public void onConfirmationResult(boolean confirmed, Bundle bundle) { 
+0

고마워요. 오류가 있지만 지금은 좀 더 오류가 있습니다. 오류 : (16, 63) 오류 : ConfirmationRequest 클래스의 생성자 ConfirmationRequest는 주어진 유형에 적용 할 수 없습니다. 이 필요하지 않습니다 : 프롬프트 발견 번들 을 : 인수를 이유 : 실제와 형식 인수 목록이 length'에서 차이가 '오류 : (19, 18) 오류 : 슈퍼에 전화하는 constructor' '오류에 첫 번째 문이어야합니다 : ': app : compileDebugJavaWithJavac'작업 실행에 실패했습니다. > 컴파일에 실패했습니다. 자세한 내용은 컴파일러 오류 출력을 참조하십시오 .' – Anish

관련 문제