add activty record
This commit is contained in:
afiq3821 2018-10-09 09:13:18 +07:00 committed by GitHub
parent 3ec9f88f4b
commit e65dc75162
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

48
gaktau Normal file
View File

@ -0,0 +1,48 @@
package com.blogspot.blogsetyaaji.androidlanjutan;
import android.content.Intent;
import android.os.Bundle;
import android.speech.RecognizerIntent;
import android.support.v7.app.AppCompatActivity;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import java.util.Locale;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
public class SttActivity extends AppCompatActivity {
@BindView(R.id.edTs)
EditText edTs;
@BindView(R.id.btnStt)
Button btnStt;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_stt);
ButterKnife.bind(this);
}
@OnClick(R.id.btnStt)
public void onViewClicked() {
prosesSuara();
}
private void prosesSuara() {
Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE,new Locale("in","INA"));
intent.putExtra(RecognizerIntent.EXTRA_PROMPT,"Start Speak");
try {
startActivity(intent, );
}catch (Exception e){
Toast.makeText(this, getString(R.string.tts_error), Toast.LENGTH_LONG);
}
}
}