skip to Main Content

Exploring the EyeDropper API- Android 17

March 4, 20262 minute read

  

Header image

In this article, we will explore the new EyeDropper API, introduced in Android 17.

EyeDropper API, a powerful system-level API that lets Android applications grab a color from any pixel across the entire display — without needing risky screen capture permissions.

Before EyeDropper: Hacky Workarounds

❌ No native API existed — developers used screenshots with storage permissions, accessibility overlays, or third-party apps like Pixolor.

Android 17 Changes Everything

👁️ EyeDropper delivers clean, system-wide pixel picking with zero permissions. One intent call grabs any screen color 🎨

Implementation — 🧑‍💻

  • Intent:
     — Action-
    Intent.ACTION_OPEN_EYE_DROPPER
val intent = Intent(Intent.ACTION_OPEN_EYE_DROPPER)
  • Result Key: Intent.EXTRA_COLOR
  • Result Type: Int
@Composable
fun EyeDropperDemo() {

// stateholder for color - default set to black
var pickedColor by remember { mutableStateOf(Color.Black) }


// Launcher - Initiate the color picker
val launcher = rememberLauncherForActivityResult(
contract = ActivityResultContracts.StartActivityForResult()
) { result ->
if (result.resultCode == Activity.RESULT_OK) {
result.data?.getIntExtra(
Intent.EXTRA_COLOR,
Color.Black.value.toInt()
)?.let { colorInt ->
Log.d("EyeDropperDemo", "Picked color: $colorInt")
pickedColor = Color(colorInt)
}
}
}

// Content...!
Column(
modifier = Modifier.fillMaxSize(),
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.Center
) {
// .....

Button(
onClick = {
// Launch EyeDropper intent (Android 17+)
val intent = Intent(Intent.ACTION_OPEN_EYE_DROPPER)
launcher.launch(intent)
}
) {
Text("Pick Color 🎨 from Screen")
}

// Show picked color
Box(
modifier = Modifier
.size(100.dp)
.background(pickedColor)
)
}
}

Demo

Demo — EyeDropper API — Android17

Keep in touch 🤜🤛

https://www.linkedin.com/in/navczydev/

References

https://play.google.com/store/apps/details?id=com.embermitre.pixolor.app


Exploring the EyeDropper API- Android 17 was originally published in ProAndroidDev on Medium, where people are continuing the conversation by highlighting and responding to this story.

 

Web Developer, Web Design, Web Builder, Project Manager, Business Analyst, .Net Developer

No Comments

This Post Has 0 Comments

Leave a Reply

Back To Top