Is there any way to detect the battery percentage of a device?

Self explanatory.
If there isn’t a way, that’s okay.

I think the only way is using Javascript

yeah the other guy is right. only REAL code can access someones real Battery power.

(Snap*!* is real code too, but you digress.)

the battery status API can be used for fingerprinting, which reduces privacy. because of this, firefox has removed it.