我正在开发一个功能,当按下按钮时,它将启动语音识别,同时记录用户说的内容.代码如下:
button_start.setOnTouchListener( new View.OnTouchListener()
{
@Override
public boolean onTouch(View arg0, MotionEvent event)
{
if (pressed == false)
{
Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
intent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE,"voice.recognition.test");
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, "zh-HK");
intent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS,1);
sr.startListening(intent);
Log.i("111111","11111111");
pressed = true;
}
recordAudio();
}
if((event.getAction()==MotionEvent.ACTION_UP || event.getAction()==MotionEvent.ACTION_CANCEL))
{
stopRecording();
}
return false;
}
});
}
public void recordAudio()
{
isRecording = true;
try
{
mediaRecorder = new MediaRecorder();
mediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
mediaRecorder.setOutputFile(audioFilePath);
mediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
mediaRecorder.prepare();
}
catch (Exception e)
{
e.printStackTrace();
}
mediaRecorder.start();
}
public void stopRecording()
{
if (isRecording) …Run Code Online (Sandbox Code Playgroud) 我想逐个上传多个图片,就像用户点击上传所有按钮一样,它必须从列表中可见的第一张图片开始,一旦第一张图片上传到服务器,然后自动必须开始第二张上传但是之后一个或两个第二个间隔,对于列表中的所有可用图像都相同.
这是我的代码,它允许我上传单个图片: -
用于上传单张图片的代码
// btnUpload
holder.uploadImageButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// Upload
startUpload(position);
}
});
Run Code Online (Sandbox Code Playgroud)
我使用下面的代码,但它同时上传/同步所有图像,我的意思在一起,就像我在列表中有500个图像所以它上传所有500在一起因此我得到错误当互联网连接断电和许多时间没有获得上传图像的准确状态!
private SparseBooleanArray flags = new SparseBooleanArray();
// At onClick, set all the flags to indicate that some data needs to be synced
ImageButton buttonUploadAll = (ImageButton) findViewById(R.id.sync_btn);
buttonUploadAll.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
for(int position=0; position<listView.getAdapter().getCount(); position++)
{
flags.put(position, true);
}
// Calling this would ensure a …Run Code Online (Sandbox Code Playgroud) 我想创建一个与我的6个按钮有距离的圆圈.在图像中,您可以看到我尝试的结果,但它看起来不像一个圆圈.我用红色圈出我的问题.您可以在下面查看我的HTML和CSS代码.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
.container {
margin-top: 360px;
margin-bottom: 16px;
padding-left: 30px;
padding-right: 30px;
}
.top-left {
margin-top: -260px;
margin-left: -20px;
border-radius: 40px / 100px;
border-top-right-radius: 0;
border-bottom-right-radius: 0;
border-bottom-left-radius: 0;
position: absolute;
}
.top-right {
margin-top: -260px;
margin-left: 155px;
border-radius: 40px / 100px;
border-bottom-left-radius: 0;
border-top-left-radius: 0;
border-bottom-right-radius: 0;
position: absolute;
}
.bottom-left {
margin-top: -160px;
margin-left: -20px;
border-radius: 40px / 100px;
border-top-right-radius: 0;
border-top-left-radius: 0;
border-bottom-right-radius: 0;
position: absolute;
}
.bottom-right { …Run Code Online (Sandbox Code Playgroud)我的应用使用基于PIN的登录.我连续有四个EditText视图,并在每个视图上设置以下TextWatcher的单独实例:
private class PinDigitWatcher implements TextWatcher {
private final EditText digit;
public PinDigitWatcher(EditText digit) {
this.digit = digit;
}
@Override
public void afterTextChanged(Editable s) {
if (s.length() <= 0)
return;
switch (digit.getId()) {
case R.id.pin_digit_a:
mPinDigitB.setFocusableInTouchMode(true);
mPinDigitB.requestFocus();
mPinDigitA.setFocusable(false);
break;
case R.id.pin_digit_b:
mPinDigitC.setFocusableInTouchMode(true);
mPinDigitC.requestFocus();
mPinDigitB.setFocusable(false);
break;
case R.id.pin_digit_c:
mPinDigitD.setFocusableInTouchMode(true);
mPinDigitD.requestFocus();
mPinDigitC.setFocusable(false);
break;
case R.id.pin_digit_d:
mPinDigitD.setFocusable(false);
onSubmitPin();
break;
}
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) { }
@Override
public void onTextChanged(CharSequence s, int start, int before, …Run Code Online (Sandbox Code Playgroud) android android-keypad android-edittext android-virtual-keyboard samsung-mobile
我正在尝试缩放LinearLayout包含DatePicker和TimePicker添加的水平
android:scaleX="0.6"
android:scaleY="0.6"
Run Code Online (Sandbox Code Playgroud)
问题是,这会缩放内容但同时增加边距,因此我无法正确使用空间.在图片中,标记的白色区域是通过缩放获得的空间,但我无法使用此空间(事实上,右侧的时钟被裁剪)

<LinearLayout
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:scaleX="0.6"
android:scaleY="0.6">
<DatePicker
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/datePicker"
android:layout_gravity="center_horizontal"
android:calendarViewShown="false"
android:spinnersShown="false"
android:layoutMode="opticalBounds"
android:measureAllChildren="true" />
<TimePicker
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/timePicker"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="5dp" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
没有此空白问题的任何缩放视图的解决方案?
背景:我正在运行一个后台服务(独立于应用程序打开与否)来保持与 Gear2 上基于 Tizen 的应用程序的连接(不是 Android,因此是手动维护)。
每当我的手机应用程序(多个应用程序)有数据要发送到服务时,我需要在服务中获取“连接”对象并调用“发送”。
所以我的问题是:我怎样才能运行服务对象?
如果我可以获得该服务,我的代码将是这样的:
MyConnection connection = runningService.getConnection()
connect.send(message);
Run Code Online (Sandbox Code Playgroud)
谢谢。
使用以下众所周知的代码,用户将进入设备帐户的整体Android设置页面:
startActivity(new Intent(Settings.ACTION_SYNC_SETTINGS));
Run Code Online (Sandbox Code Playgroud)

是否有相应的用户将用户直接转到特定帐户的设置(请参见下面的屏幕截图),前提是该帐户属于我的应用程序?

我不知道为什么虚拟SD卡不再工作了.有人得到任何线索或为什么会发生这种情况?
我正在使用带有API 26的Android模拟器(Android O)

我想在我的应用程序上播放 YouTube 视频,但使用自定义媒体播放器控件,如下所示:

如果我将这些按钮放在播放器下方的单独布局上,它就可以工作,但我需要覆盖 YouTube 不支持的布局(除了ActionBar)。如何修改 Android 播放器以满足我的需求?是否可以使用不同的媒体播放器(带有VideoView)来播放 YouTube 视频/播放列表?或者可以ActionBar用来包含那些媒体控件,包括SeekBar?请建议。
youtube android youtube-api media-player android-youtube-api
我将三星智能电视设置为开发模式并关联我的 PC 的 IP。两台设备都在同一网络上。但是,当我使用远程设备管理器在 Tizen Studio 中搜索电视时,我没有找到它。我尝试手动设置电视的 IP,但失败了: