Parameters of Android configuration

Asked

Viewed 94 times

4

I wonder if you have any way to get the values straight from the settings of android example want to know if the "Unknown Sources" is enabled, "Developer Mode" is enabled,"Language" ,"Brightness level".....

2 answers

2

It is possible to obtain this information using the Settings.System

Some of the constants are therefore obsolete due to the target api that you intend to use, consider using, for the same purpose, the classes Settings.Global and Settings.Secure

For example to get the default "brightness level" value use:

try {
    float curBrightnessValue = android.provider.Settings.System.getInt(
    getContentResolver(), android.provider.Settings.System.SCREEN_BRIGHTNESS);
} catch (SettingNotFoundException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
}

Source of the code

0

You could call the Android settings, through a button, that way:

Button in XML:

<Button
        android:id="@+id/btn_config"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignTop="@+id/btn_prox"
        android:layout_toStartOf="@+id/btn_prox"
        android:text="@string/btn_config"
        style="?android:attr/buttonBarButtonStyle"
        android:onClick="config" />

See above that attribute android:onClick will call the method config in his MainActivity, as seen below:

package com.newthread;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.provider.Settings;
import android.view.View;

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_main);
    }

    public void config(View view) {

        Intent intent = new Intent(Settings.ACTION_SETTINGS);
        startActivity(intent);
    }
}

The call of the settings is made through the Intent and the class Settings.ACTION_SETTINGS.

See the Android Developers documentation: https://developer.android.com/reference/android/widget/Button.html

Browser other questions tagged

You are not signed in. Login or sign up in order to post.