Context.getFilesDir() 对应的 XML 是什么?
我当前的 XML:
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<files-path name="internal" path="." />
</paths>
Run Code Online (Sandbox Code Playgroud)
文件创建:
File video = new File(getFilesDir(), "movie.mp4");
videoUri = FileProvider.getUriForFile(this, "my.package.name.provider", video);
Run Code Online (Sandbox Code Playgroud) 我正在使用Camera2API构建相机活动,将拍摄的图像发送到另一个活动.在某些设备上它可以工作,但在其他设备(较慢的设备)上,我得到一个java.lang.IllegalStateException,其中显示"会话已关闭;进一步的更改是非法的".
我在这一行得到了这个异常(在updatePreview()中):
cameraCaptureSessions.setRepeatingRequest(captureRequestBuilder.build(), null, mBackgroundHandler);
Run Code Online (Sandbox Code Playgroud)
这是我的完整代码:
public class NewCamera extends CustomActivity implements TimingActivity {
private static final String TAG = "NewCamera";
private ImageView takePictureButton;
private TextureView textureView;
private static final SparseIntArray ORIENTATIONS = new SparseIntArray();
static {
ORIENTATIONS.append(Surface.ROTATION_0, 90);
ORIENTATIONS.append(Surface.ROTATION_90, 0);
ORIENTATIONS.append(Surface.ROTATION_180, 270);
ORIENTATIONS.append(Surface.ROTATION_270, 180);
}
private String cameraId;
protected CameraDevice cameraDevice;
protected CameraCaptureSession cameraCaptureSessions;
protected CaptureRequest.Builder captureRequestBuilder;
private Semaphore mCameraOpenCloseLock = new Semaphore(1);
private Size imageDimension;
private ImageReader imageReader;
private static final int REQUEST_CAMERA_PERMISSION = 200;
private …Run Code Online (Sandbox Code Playgroud) 我在完成/输入/下一个键时遇到问题.我正在制作android软键盘,每当我尝试搜索我无法做到的事情时,因为当我按DONE键时光标移动到下一行.这是我的代码:
XML
<Key android:keyLabel="DONE" android:keyWidth="11.11%" android:codes="-1"/>
Run Code Online (Sandbox Code Playgroud)
JAVA
@Override
public void onKey(int primaryCode, int[] keyCodes) {
InputConnection ic = getCurrentInputConnection();
switch(primaryCode){
case -1:
ic.sendKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_ENTER));
break;
default:
char code = (char)primaryCode;
if(Character.isLetter(code) && caps){
code = Character.toUpperCase(code);
}
ic.commitText(String.valueOf(code), 1);
}
}
Run Code Online (Sandbox Code Playgroud)
示例:如果我在Google上搜索某些内容并输入我想要的内容,当我单击"完成"键时,我希望它开始搜索.你能帮帮我吗?提前致谢.