kobra zlobra
kobra zlobra

Reputation: 25

how to make brightness changing button for widget

how could i change brightness 1. click 50% second click 100% 3. click 0% via widget button? i am actuali stack on premission becouse it telling me This Premission is only gatanted to system apps, so is it possible to even do that ? enter image description here

my target is to add all this to my widget -

<LinearLayout
    android:id="@+id/widget_button_layout"
    android:layout_width="match_parent"
    android:layout_height="53dp"
    android:layout_alignParentBottom="true"
    android:background="@drawable/widget_buttons_background"
    android:orientation="horizontal"
    android:weightSum="1">
    <ImageButton
        android:id="@+id/widget_bluethooth"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="0.25"
        android:layout_marginEnd="1dp"
        android:scaleType="fitXY"
        android:background="@drawable/widget_bluethooth_btn" />
    <ImageButton
        android:id="@+id/widget_settings"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="0.25"
        android:layout_marginStart="1dp"
        android:layout_marginEnd="1dp"
        android:scaleType="fitXY"
        android:background="@drawable/widget_settings_btn" />
    <ImageButton
        android:id="@+id/widget_wifi"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="0.25"
        android:layout_marginStart="1dp"
        android:layout_marginEnd="1dp"
        android:scaleType="fitXY"
        android:background="@drawable/widget_wifi_btn" />
    <ImageButton
        android:id="@+id/widget_brightnes"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="0.25"
        android:layout_marginStart="1dp"
        android:scaleType="fitXY"
        android:background="@drawable/widget_brightnes1_btn" />

i would need to read brightness too, becouse it is wierd if that button will have drawable of 100% but someone will decrease brightness manualy to 0%... so can someone help me to get premission for reading and writing to brightness... ? if you will be way to kind you could help me with others staff

Upvotes: 0

Views: 95

Answers (1)

Alejandro M
Alejandro M

Reputation: 81

That's not a real error, just an error produced by your IDE. If you want to remove it, you just have to add to your Manifest:

uses-permission android:name="android.permission.WRITE_SETTINGS"
    tools:ignore="ProtectedPermissions"

Upvotes: 1

Related Questions