0

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

Farya
  • 277
  • 3
  • 14
Shubham Shekhar
  • 316
  • 3
  • 17

1 Answers1

1

You are using WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED (with AndroidThings 0.3.0)

Hardware Acceleration for the R Pi was only introduced in AndroidThings 0.5.0

See the release notes here:

https://developer.android.com/things/preview/releases.html

With the update to Android O, OpenGL ES 2.0 is now supported. Platforms with a GPU (such as Raspberry Pi 3) also now support hardware acceleration.

Please update the version of AndroidThings you are using.

Blundell
  • 75,855
  • 30
  • 208
  • 233
  • I updated to Android version 0.5.0 but I am unable to get any display from the raspberry pi3 device onto my monitor which was not the case earlier. Not even the boot up screen is being displayed. All I can see now is a black screen. Resolution of my display screen is 1366*768 – Shubham Shekhar Sep 28 '17 at 06:31