Android Community
Results 1 to 2 of 2

Thread: brightness change

  1. #1
    Join Date
    Sep 2010
    Posts
    18

    Post brightness change


    hi all...

    i did brightness change application for android device..it works correctly but the problem was when i run the application it will change in the brightness setting controller but i was not reflected to the screen display suddenly..when i open brightness setting it will apply..or when the screen timeout it is goin to apply...please do favour for me...

    and here is my code

    import android.app.Activity;
    import android.os.Bundle;
    import android.content.SharedPreferences;
    import android.os.IHardwareService;
    import android.os.ServiceManager;
    import android.widget.Toast;
    import static android.provider.Settings.System.SCREEN_BRIGHTNESS ;
    public class brighttest extends Activity
    {
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
    super.onCreate(savedInstanceState);
    try {
    SharedPreferences settings=
    getSharedPreferences("com.anand.brighttest", MODE_PRIVATE);

    int val=android.provider.Settings.System.getInt(
    getContentResolver(), SCREEN_BRIGHTNESS);
    IHardwareService hardware=
    IHardwareService.Stub.asInterface( ServiceManager.getService("hardware"));

    if(val==255) {
    int nval=settings.getInt("ScreenBrightness",128);
    if(nval<=0) nval=128;
    if(nval>255) nval=255;
    Toast.makeText(this,
    ""+(nval*100/255)+"% Brightness",
    Toast.LENGTH_LONG).show();
    android.provider.Settings.System.putInt(getContent Resolver(),
    SCREEN_BRIGHTNESS, nval);
    if(hardware!=null) hardware.setScreenBacklight(nval);
    } else {
    android.provider.Settings.System.putInt(getContent Resolver(),
    SCREEN_BRIGHTNESS, 255);
    Toast.makeText(this, "Maximum Brightness", Toast.LENGTH_LONG).show();
    SharedPreferences.Editor editor = settings.edit();
    editor.putInt("ScreenBrightness",val);
    editor.commit();
    if(hardware!=null) hardware.setScreenBacklight(255);
    }
    } catch(Throwable er) {
    Toast.makeText(this, "Error "+er.getMessage(), Toast.LENGTH_LONG).show();
    } finally {
    finish();
    }
    }
    }


    /*manifest code-----------*/

    <?
    xmlversion="1.0"encoding="utf-8"?>
    <
    manifestxmlns:android="http://schemas.android.com/apk/res/android"

    package="com.anand.brighttest"

    android:versionCode="1"

    android:versionName="1.0">

    <applicationandroid:icon="@drawable/icon"android:label="@string/app_name">

    <activityandroid:name=".brighttest"

    android:label="@string/app_name">

    <intent-filter>

    <actionandroid:name="android.intent.action.MAIN"/>

    <categoryandroid:name="android.intent.category.LAUNCHER"/>

    </intent-filter>

    </activity>


    </application>
    <
    uses-permissionandroid:name="android.permission.HARDWARE_TEST"></uses-permission>
    <
    uses-permissionandroid:name="android.permission.WRITE_SETTINGS"></uses-permission>

    </manifest>




    with regards
    anand

  2. #2
    Join Date
    Oct 2010
    Posts
    74

    Default Re: brightness change


    Wow, this problem is really bad. Maybe you need some professional check. It seems the problem is relateding the configuration.

Similar Threads

  1. Screen Brightness
    By moes in forum Developers Guild
    Replies: 2
    Last Post: 09-22-2010, 10:11 PM
  2. Brightness control
    By anandgowda in forum Developers Guild
    Replies: 0
    Last Post: 09-14-2010, 01:17 AM
  3. Auto Screen Brightness
    By Ninety-9 SE-L in forum General HTC Chat
    Replies: 6
    Last Post: 10-16-2009, 06:12 PM
  4. Screen brightness bug
    By rdt220 in forum General HTC Chat
    Replies: 0
    Last Post: 08-17-2009, 01:05 PM
  5. Brightness keeps dropping to 22%
    By mmace in forum General HTC Chat
    Replies: 1
    Last Post: 06-29-2009, 09:59 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •