我正在尝试将我的文件保存到以下位置,
FileOutputStream fos = new FileOutputStream("/sdcard/Wallpaper/"+fileName);
但是我得到了异常java.io.FileNotFoundException
但是,当我把路径保存"/sdcard/"起来的时候.
现在我假设我无法以这种方式自动创建目录.
有人可以建议如何创建directory and sub-directory使用代码吗?
我正在寻找一种可用于重启root设备的解决方案.我知道重新启动设备对于用户来说是非常差的设计,如此处所述,并且它不适用于应用程序.主要目的是在测试期间重启手机(我在视频聊天应用程序上工作,有时我需要在一切都向南时重启)
我观察到重新启动手机远比使用终端(adb shell或ConnectBot)中的重启要快得多,而不是通过使用ACTION_REBOOT重新启动,这无论如何都无法使用.
目前,我可以获得超级用户权限
Process root = Runtime.getRuntime().exec("su");
Run Code Online (Sandbox Code Playgroud)
但我不能做实际的重启.我尝试G1(HTC)和Galaxy S(三星)没有任何成功.我找到了重启可执行文件/system/bin/reboot
以下是我的一些尝试:
Process reboot = Runtime.getRuntime().exec("/system/bin/reboot");
Process reboot = Runtime.getRuntime().exec("reboot");
Process reboot = Runtime.getRuntime().exec("su reboot");
Run Code Online (Sandbox Code Playgroud)
我读过这篇关于Runtime.exec()陷阱的文章,但我想我不是这种情况.
由于使用ConnectBot使我能够做这样的动作,我很确定它是可能的.请不要告诉我去看看ConnectBot代码,这是一个庞大而复杂的项目:)
你能帮我解决这个问题吗?
谢谢.
我试过了 :
process = Runtime.getRuntime().exec("su -c cat /dev/graphics/fb0 > /sdcard/frame.raw");
process.waitFor();
Run Code Online (Sandbox Code Playgroud)
但它不起作用.我的设备扎根了.
我看到许多答案需要root访问,但没有实际的代码来获取帧缓冲.
我也试过glReadPixels()但没有运气.
public void TakeScreen() {
DisplayMetrics dm = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(dm);
int width = dm.widthPixels;
int height = dm.heightPixels;
int screenshotSize = width * height;
ByteBuffer bb = ByteBuffer.allocateDirect(screenshotSize * 4);
bb.order(ByteOrder.nativeOrder());
gl.glReadPixels(0, 0, width, height, GL10.GL_RGBA,
GL10.GL_UNSIGNED_BYTE, bb);
int pixelsBuffer[] = new int[screenshotSize];
bb.asIntBuffer().get(pixelsBuffer);
bb = null;
Bitmap bitmap = Bitmap.createBitmap(width, height,
Bitmap.Config.RGB_565);
bitmap.setPixels(pixelsBuffer, screenshotSize - width, -width, 0, 0,
width, height);
pixelsBuffer = null;
short …Run Code Online (Sandbox Code Playgroud) 问: 有没有人知道如何使用Tango Java(Jacobi)API onFrameAvailable()回调获取Tango的彩色相机图像缓冲区?
背景:
我有一个增强现实应用程序,在Tango的背景中显示视频.我在此示例后使用Java API(Jacobi)成功创建了视频叠加示例.我的应用程序工作正常,视频在后台正确呈现.
作为应用程序的一部分,我想在用户按下按钮时存储视频后备缓冲区的副本.因此,我需要访问相机的RGB数据.
根据Jacobi发行说明,任何希望访问相机RGB数据的类都应该实现新的onFrameAvailable()方法OnTangoUpdateListener.我做了这个,但我没有看到任何实际获取像素的句柄或参数:
Java API
@Override
public void onFrameAvailable(int cameraId) {
//Log.w(TAG, "Frame available!");
if (cameraId == TangoCameraIntrinsics.TANGO_CAMERA_COLOR) {
tangoCameraPreview.onFrameAvailable();
}
}
Run Code Online (Sandbox Code Playgroud)
如图所示,onFrameAvailable只有一个参数,整数表示生成视图的摄像机的id.将其与C库回调进行对比,后者提供对图像缓冲区的访问:
C API
TangoErrorType TangoService_connectOnFrameAvailable(
TangoCameraId id, void* context,
void (*onFrameAvailable)(void* context, TangoCameraId id,
const TangoImageBuffer* buffer));
Run Code Online (Sandbox Code Playgroud)
我期待Java方法在C API调用中有类似于缓冲区对象的东西.
我试过的
我尝试扩展TangoCameraPreview课程并将图像保存在那里,但我只获得黑色背景.
public class CameraSurfaceView extends TangoCameraPreview {
private boolean takeSnapShot = false;
public void takeSnapShot() {
takeSnapShot …Run Code Online (Sandbox Code Playgroud)