Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

232
Views
How to draw using framebuffer on Android?

I would like to write an application for Android which displays stuff on screen using the framebuffer. This will run only on a specific rooted device, so permissions etc is not a problem. Same application (simple test version anyway) is already running okay on PC/Linux.

The questions:

  1. How to avoid the Android OS from accessing the framebuffer? I would like, while my application is running, to have the OS never touch the framebuffer, no writes and no ioctls. What do I need to do to get exclusive use of the framebuffer, and then (when my application quits) give it back to the OS?

  2. Are there any differences between Android framebuffer and Linux framebuffer to watch out for?

P.S. I would like to start my application as a regular Android application (with some native code), it just has no visible UI except for framebuffer draws which take over the whole screen. It would be nice to still be able to get events from the OS.

See also: http://www.kandroid.org/online-pdk/guide/display_drivers.html

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Hi Alex Not sure why / how to stop android OS from writing to framebuffer. As long as your android application is visible and on top you have the control as what you want to display.

Your application should have an activity with a SurfaceView ( you may want your application to hide notification bar call this function in oncreate of your activity) requestWindowFeature(Window.FEATURE_NO_TITLE); )

your activity should have SurfaceHolder.Callback implementation to handle callbacks as when the surface is ready to filled with framebuffer. Get the surface holder object as SurfaceView.getHolder() incase you want set pixel formats of the view etc.

Once "surfaceCreated" callback is called you can safely pass your surfaceview object(passing width and height maybe a good idea too) to the native so that you can fill it framebuffer using "ANativeWindow" class.

Check NDK sample code to see how to use the class NDK documentation

SurfaceHolder.Callback documentation

SurfaceHolder documentation

essentially you need to these (ON JB /Kitkat)

  1. get the native window (ANativeWindow) associated with the surfaceview by ANativeWindow_fromSurface.

  2. Acquire a lock on the ANativeWindow by ANativeWindow_acquire .

  3. Set geometry parameters(window,width,height,pf) for the nativewindow by ANativeWindow_setBuffersGeometry

  4. Load the nativewindow with the frambuffer stored (apply dirty rectangle if any here) by ANativeWindow_lock

  5. Final step to unlock and post the changes for rendering by ANativeWindow_unlockAndPost

Go through the ndk sample examples in case you need sample code.NDK documentation

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!