这是怎么回事啊?
代码贴上
public class MainActivity extends Activity {
private static final String API_KEY="XN1--xr--LY";
private static final String SECRET_KEY="bf7--f00--ab";
private Button BtnStart;
private EditText InputBox;
private BaiduASRDigitalDialog mDialog=null;
private DialogRecognitionListener mDialogListener=null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
if (mDialog == null) {
if (mDialog != null) {
mDialog.dismiss();
}
Bundle params = new Bundle();
//????API_KEY, SECRET_KEY
params.putString(BaiduASRDigitalDialog.PARAM_API_KEY, API_KEY);
params.putString(BaiduASRDigitalDialog.PARAM_SECRET_KEY, SECRET_KEY);
params.putInt(BaiduASRDigitalDialog.PARAM_PROP,VoiceRecognitionConfig.PROP_INPUT);
params.putString(
BaiduASRDigitalDialog.PARAM_LANGUAGE,VoiceRecognitionConfig.LANGUAGE_CHINESE);
params.putBoolean( BaiduASRDigitalDialog.PARAM_NLU_ENABLE,true);
params.putInt(BaiduASRDigitalDialog.PARAM_DIALOG_THEME, BaiduASRDigitalDialog.THEME_BLUE_LIGHTBG);
mDialog = new BaiduASRDigitalDialog(this, params);
BtnStart=(Button)findViewById(R.id.btn);
InputBox=(EditText)findViewById(R.id.input);
mDialogListener=new DialogRecognitionListener()
{
public void onResults(Bundle mResults)
{
ArrayList rs = mResults != null ? mResults.getStringArrayList(RESULTS_RECOGNITION) : null;
if (rs != null && rs.size() > 0) {
InputBox.setText(rs.get(0));
}
}
};
mDialog.setDialogRecognitionListener(mDialogListener);
BtnStart.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v)
{
mDialog.show();
}
});
}
}
}
看看