How to access device settings programmatically?

前端 未结 6 1686
礼貌的吻别
礼貌的吻别 2020-12-05 05:59

Is there any way to access device settings programmatically?

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

Thanks in advance.

<
6条回答
  •  没有蜡笔的小新
    2020-12-05 06:19

    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

提交回复
热议问题