我正在尝试从YUV_420_888图像获取Exif数据,但是它不起作用。我尝试了几种解决方案,例如将图像以jpeg格式保存到磁盘,将其转换为输入流,但似乎无济于事。
我使用Android camera2 API捕获YUV_420_888图像。然后在OnImageAvailableListener中获取图像,并尝试使用ExifInterface API读取其EXIF数据。但是它总是空的。我尝试了此链接中的所有方法以获得正确的字节数组。
这是我的代码:
@Override
public void onImageAvailable(ImageReader imageReader) {
if (!isRecording) {
return;
}
Image image = imageReader.acquireNextImage();
File file = Util.getImagePath(context);
OutputStream outputStream = null;
try {
outputStream = new FileOutputStream(file);
outputStream.write(data);
//// This byte array I am making using all the approaches given in this link
/sf/ask/3081544371/
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
outputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
try {
ExifInterface exifInterface = new …Run Code Online (Sandbox Code Playgroud) 我有一个按钮,就像 whatsapp 麦克风按钮一样,您可以长按并向左和向右移动它。
现在我需要为这个按钮编写一个测试用例。到目前为止,我所做的是,我可以拖动到特定位置。现在我需要左右拖动,但我找不到任何方法来做到这一点。
let app = XCUIApplication()
app.buttons["Launch Chat"].tap()
app.tables.staticTexts["shivam"].tap()
let chatbarElement = app.otherElements["chatBar"]
let button = chatbarElement.children(matching: .button).element(boundBy: 0)
let startPoint = button.coordinate(withNormalizedOffset: CGVector(dx: 0, dy: 0)) // center of element
var finishPoint = chatbarElement.coordinate(withNormalizedOffset: CGVector(dx: 0.7, dy: 0))
startPoint.press(forDuration: 3, thenDragTo: finishPoint)
Run Code Online (Sandbox Code Playgroud)
如您所见,此方法仅拖动到特定位置。但是我需要的是在特定的持续时间内向左和向右连续拖动它,我找不到任何方法来实现这一点。
PS:这不是swipeLeft和swipeRight,拖动是指长按后可以左右拖动按钮,而不是普通的点击。
以编程方式创建的按钮不遵循应用程序主题中定义的按钮样式,但在 xml 中创建的按钮遵循它。
下面是我的 style.xml
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="buttonStyle">@style/Button.Primary</item>
</style>
<style name="Button.Primary" parent="Widget.AppCompat.Button.Colored">
<item name="textAllCaps">true</item>
<item name="android:textColor">#fff</item>
<item name="backgroundTint">@color/btn_bck</item>
</style>
Run Code Online (Sandbox Code Playgroud)
这就是我以编程方式创建按钮的方法:
Button progBtn = new Button(this);
progBtn.setText("Programmatic button");
LinearLayout layout = findViewById(R.id.container);
layout.addView(progBtn);
Run Code Online (Sandbox Code Playgroud)
它显示为默认的灰色背景和黑色文本颜色。
但如果我在 xml 中使用按钮,例如:
<Button
android:id="@+id/btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!" />
Run Code Online (Sandbox Code Playgroud)
它工作正常,并以白色文本颜色和样式中指定的正确背景色调显示。
我想知道为什么上面两种创建按钮的方法,按钮样式不一致?
android button android-appcompat android-theme android-button
我正在使用 LeakCanary,但堆分析结果没有提供足够的信息来检测任何泄漏。它只提到活动正在泄漏。
\nD/LeakCanary: \xe2\x80\x8b\n ====================================\n HEAP ANALYSIS RESULT\n ====================================\n 1 APPLICATION LEAKS\n \n References underlined with "~~~" are likely causes.\n Learn more at https://squ.re/leaks.\n \n 298153 bytes retained by leaking objects\n Signature: a610bac3ef989ac5dc5a69244fc2882de5617\n \xe2\x94\xac\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\n \xe2\x94\x82 GC Root: System class\n \xe2\x94\x82\n \xe2\x94\x9c\xe2\x94\x80 android.provider.FontsContract class\n \xe2\x94\x82 Leaking: NO (MyApplication\xe2\x86\x93 is not leaking and a class is never leaking)\n \xe2\x94\x82 \xe2\x86\x93 static FontsContract.sContext\n \xe2\x94\x9c\xe2\x94\x80 com.example.MyApplication instance\n \xe2\x94\x82 Leaking: NO (Application is a singleton)\n \xe2\x94\x82 mBoundService instance of com.example.services.SessionService\n \xe2\x94\x82 mBase instance of …Run Code Online (Sandbox Code Playgroud) android memory-leaks memory-profiling android-activity java-memory-leaks