我正在尝试为Android创建一个只需向SSH服务器发送命令的应用程序.无需响应,我只需要能够发送命令.我想知道是否有任何我可以使用的java库?
不需要高级的东西,只需要一个纯粹的连接来发送命令.
我遇到过一种情况,我必须以幻灯片形式显示图像,以便快速切换图像.大量的图像使我想要将JPEG数据存储在内存中,并在我想要显示它们时解码它们.为了简化垃圾收集器,我使用BitmapFactory.Options.inBitmap来重用位图.
不幸的是,这导致相当严重的撕裂,我尝试了不同的解决方案,如同步,信号量,2-3个位图之间的交替,但是,似乎没有解决问题.
我已经建立了一个示例项目,在GitHub上演示了这个问题; https://github.com/Berglund/android-tearing-example
我有一个线程解码位图,在UI线程上设置它,并睡眠5毫秒:
Runnable runnable = new Runnable() {
@Override
public void run() {
while(true) {
BitmapFactory.Options options = new BitmapFactory.Options();
options.inSampleSize = 1;
if(bitmap != null) {
options.inBitmap = bitmap;
}
bitmap = BitmapFactory.decodeResource(getResources(), images.get(position), options);
runOnUiThread(new Runnable() {
@Override
public void run() {
imageView.setImageBitmap(bitmap);
}
});
try {
Thread.sleep(5);
} catch (InterruptedException e) {}
position++;
if(position >= images.size())
position = 0;
}
}
};
Thread t = new Thread(runnable);
t.start();
Run Code Online (Sandbox Code Playgroud)
我的想法是ImageView.setImageBitmap(Bitmap)在下一个vsync上绘制位图,但是,当发生这种情况时,我们可能已经解码了下一个位图,因此,我们已经开始修改位图像素.我在想正确的方向吗?
有谁有任何关于从哪里去的提示?
我试图用这种形状绘制一个形状:

使用以下内容时,这在1.6到2.3.5中正常工作:
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#cc6900"/>
<corners android:radius="0.1dp" android:bottomRightRadius="7dp" android:bottomLeftRadius="0dp"
android:topLeftRadius="0dp" android:topRightRadius="7dp"/>
Run Code Online (Sandbox Code Playgroud)
但是,当在Galaxy Nexus或4.0 Emulator上运行它时,我必须使用它来获得相同的布局:
...
<corners android:radius="0.1dp" android:bottomRightRadius="0dp" android:bottomLeftRadius="7dp"
android:topLeftRadius="0dp" android:topRightRadius="7dp"/>
...
Run Code Online (Sandbox Code Playgroud)
这给了我这个1.6:

所以基本上,以前的版本都以一种方式使用了bottomRight和bottomLeft,现在4.0在另一种方式中使用了它.
是否有任何简单的方法可以让它像4.0之前的版本一样,并为4.0用户提供更改后的值?如果可能的话,我更愿意,如果我可以将它保存在XML中,而不是在代码中.