SecurityException: Permission Denial: not allowed to send broadcast android.intent.action.BATTERY_CHANGED -


i trying develop widget showing battery temperature. when registering broadcast receiver android.intent.action.battery_changed

it shows error this.

java.lang.securityexception: permission denial: not allowed send broadcast android.intent.action.battery_changed pid=-1, uid=10058 

as far know there no need of permission broadcast . if in case of activity. working properly.

    intent intent = new intent();     intent.setaction("android.intent.action.battery");     return pendingintent.getbroadcast(context, 0, intent, pendingintent.flag_update_current); 

as far know there no need of permission broadcast

yes, there is. sending broadcast. and, quoting the documentation action_battery_changed:

this protected intent can sent system.

you not system; cannot send broadcast.

i have no idea why creating pendingintent trying send broadcast, need else instead. if objective trigger broadcastreceiver tap on app widget, receiver also happens listen action_battery_changed, use explicit intent identifying receiver when creating pendingintent:

pendingintent.getbroadcast(context, 0, new intent(this, yourreceiver.class), pendingintent.flag_update_current); 

Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -