Image available listener picks up an image of the fragment and onimageavailble()
is invoked continuously as soon as the image is available. An instance of the code is as below:
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(null);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED,
WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
setContentView(R.layout.activity_camera);
setFragment();
}
The setFragment()
code is:
protected void setFragment() {
final Fragment fragment =
CameraConnectionFragment.newInstance(
new CameraConnectionFragment.ConnectionCallback() {
@Override
public void onPreviewSizeChosen(final Size size, final int rotation) {
CameraActivity.this.onPreviewSizeChosen(size, rotation);
}
},
this,
getLayoutId(),
getDesiredPreviewFrameSize());
getFragmentManager()
.beginTransaction()
.replace(R.id.container, fragment)
.commit();
}
The code runs correctly on Android and so I wanted it to implement on Android Things device but I was getting a warning stating 'A TextureView or a subclass can only be used with hardware acceleration enabled' and the onimageavailble()
is never called. I made required changes in the code to resolve the warning but still, onimageavailble()
is never called.
On debugging the code in raspberry Pi3 for android things, I noticed that camera stream is not being displayed in the fragment because of which image listener is unable to pick one.
please provide me with the solution for this problem