0

I am making a battery saver application on Android. I have included features like set brightness from app, set screen time out from the app,enable/disable synchronization, etc. for these features I have to write the settings of system. i have used WRITE_SETTINGS,WRITE_SECURE_SETTINGS in the manifest and the code for main activity is written below. I am using a library to grant permissions. The problem is that if i add any other permission in the manifest it is successfully granted but it denies the write system apps permission automatically.I want write permissions to successfully change the screen brightness,screen time out and other features etc in Marshmallow and above. if anyone knows how to do it then please help me. basically i want these permissions which are stated in the link below Android launch app show "Can modify system settings" dialog

import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;
import android.widget.TextView;

import com.karan.churi.PermissionManager.PermissionManager;

import java.util.ArrayList;

public class MainActivity extends AppCompatActivity {
    PermissionManager permissionManager;
    TextView txtGranted, txtDenied;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        txtGranted = (TextView) findViewById(R.id.Granted);
        txtDenied = (TextView) findViewById(R.id.Denied);
        permissionManager = new PermissionManager() {};
        permissionManager.checkAndRequestPermissions(this);
    }

    @Override
    public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
        permissionManager.checkResult(requestCode,permissions,grantResults);
        ArrayList<String> granted=permissionManager.getStatus().get(0).granted;
        ArrayList<String> denied=permissionManager.getStatus().get(0).denied;
        for(String item:granted){
            txtGranted.setText(txtGranted.getText()+"\n"+item);
        }
        for(String item:denied){
            txtDenied.setText(txtDenied.getText()+"\n"+item);
        }
    }
}
Absar Ahmad
  • 52
  • 11

1 Answers1

0

You can't override system features (or) acquire system level access permissions unless and until your Application is signed with same keystore as system Image. For this you need to have your own SDK so that you can override system settings.

Rajan Kali
  • 12,627
  • 3
  • 25
  • 37