Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
237 views
in Technique[技术] by (71.8m points)

android - How to access device settings programmatically?

Is there any way to access device settings programmatically?

For Example: Settings > Developer Options > USB debugging > True/False

Thanks in advance.

Edit: USB debugging is just an example. Can I access every settings which is exist in Settings in device.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Settings.Secure.putInt(getActivity().getContentResolver(),Settings.Secure.ADB_ENABLED, 1);

But you need root access to do this. Only system apps have permission to change secure settings

Edit: Try this to Show all ANRs

Settings.Secure.putInt(ContentResolver,Settings.Secure.ANR_SHOW_BACKGROUND,0);

and for Don't keep activities

ActivityManagerNative.getDefault().setAlwaysFinish(true)

but ActivityManagerNative is hidden in standard api set. you will need to do either reflection or use this method to get android.jar. Again I guess this needs root access


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...