在文本到语音结束后,我怎样才能干杯说话.实际上我想做的不仅仅是Log.这是我的代码.
public class MainActivity extends AppCompatActivity implements TextToSpeech.OnInitListener, TextToSpeech.OnUtteranceCompletedListener {
private TextToSpeech mTts;
Button btnSpeak;
EditText editTextTTS;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mTts = new TextToSpeech(this,this);
editTextTTS =(EditText)findViewById(R.id.editText);
btnSpeak = (Button)findViewById(R.id.btnSpeakTest);
btnSpeak.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
speak(editTextTTS.getText().toString());
}
});
}
private void speak(String word){
if(word != null) {
HashMap<String, String> myHashAlarm = new HashMap<String, String>();
myHashAlarm.put(TextToSpeech.Engine.KEY_PARAM_STREAM, String.valueOf(AudioManager.STREAM_ALARM));
myHashAlarm.put(TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID, "Hello");
mTts.speak(word, TextToSpeech.QUEUE_FLUSH, myHashAlarm);
}
}
@Override
public void onInit(int status) {
if(status == TextToSpeech.SUCCESS) …Run Code Online (Sandbox Code Playgroud) 我在我的应用程序中使用 glide 加载图像。它在我的情况下工作正常
if(image_enabled==1){
Glide.with(getContext()).load(constant.SERVER_URL+"images/"+quoteData.get(KEY_PICTURE).apply(myOptions).into(mImageView);
}
else if(image_enabled==0){
Glide.with(getContext()).load(constant.SERVER_URL+"images/"+quoteData.get(KEY_PICTURE)).apply(myOptions).into(mImageView);
}
Run Code Online (Sandbox Code Playgroud)
但如果上述任何一种情况无法加载图像,我想再加载一个 url。我不知道哪种方法用于滑行中的轨道加载失败。如果有人可以帮助我获得它,请告诉我。谢谢
每当我想运行我的项目时,都会出现以下错误
错误:任务':app:transformClassesWithDexForDebug'的执行失败。com.android.build.api.transform.TransformException:com.android.ide.common.process.ProcessException:java.util.concurrent.ExecutionException:com.android.dex.DexException:多个dex文件定义了Landroid / support / design / widget / CoordinatorLayout $ 1;
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
buildToolsVersion "27.0.2"
defaultConfig {
applicationId "com.example.invinciblesourav.flacom"
minSdkVersion 18
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets { main { assets.srcDirs = ['src/main/assets', 'src/main/assets/'] } }
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile ('com.android.support:appcompat-v7:27.+')
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.google.firebase:firebase-auth:11.0.4'
compile …Run Code Online (Sandbox Code Playgroud) 在我的应用程序中,我想从服务器获取数据并将其显示到中RecyclerView。
为了从服务器获取数据,我使用Retrofit2,并编写以下代码。
但一段时间后,运行应用程序时,告诉我E/priceResLog: Err : SSL handshake timed out在onFailure从Retrofit2!
我的代码:
public class ApiUtilsPrice {
private static final String BASE_URL = "https://core.arzws.com/";
private static Retrofit retrofit = null;
public static Retrofit getClient() {
OkHttpClient okHttpClient = new OkHttpClient.Builder()
.readTimeout(60, TimeUnit.SECONDS)
.writeTimeout(60, TimeUnit.SECONDS)
.connectTimeout(60, TimeUnit.SECONDS)
.build();
if (retrofit == null) {
retrofit = new Retrofit.Builder()
.client(okHttpClient)
.baseUrl(BASE_URL)
.addConverterFactory(GsonConverterFactory.create())
.build();
}
return retrofit;
}
}
Run Code Online (Sandbox Code Playgroud)
活动代码:
private void getCoinData() {
loaderLayout(true);
Call<GoldListResponse> call …Run Code Online (Sandbox Code Playgroud)