我有一个首选项xml文件,在某些时候它看起来像这样:
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
android:title="Hello there">
<!-- Profile ** -->
<PreferenceScreen
android:key="profile"
android:summary="Let app access my profile info such as name, picture and other account information."
android:title="User Profile">
<CheckBoxPreference
android:defaultValue="true"
android:key="pref_profile"
android:summary="Let app access my profile such as name, picture and other account information."
android:title="My Profile" />
Run Code Online (Sandbox Code Playgroud)
如您所见,我有2个preferenceScreen。我想获取CheckBoxPreference的preferenceScreen(所以带有key的profile屏幕:profile)。当我使用时:
PreferenceScreen prefScreen = getPreferenceScreen();
Run Code Online (Sandbox Code Playgroud)
我得到一个标题为:你好。我如何获得此checkBoxPreference的直接父(第一父)屏幕?我想要得到它,以便我可以禁用或启用其视图。
有什么想法吗?谢谢!!
android preference checkboxpreference preferencescreen android-settings
我添加SettingActivity了我的应用程序,并得到了这个自动生成的Java文件AppCompatPreferenceActivity.java和SettingsActivity.java。
两者有什么区别?我碰到了下面的链接,但没有讨论。
我不知道在哪里编码。
java android android-preferences android-studio android-settings
在Marshmallow之前"允许模拟位置"选项可以通过编程方式更改(需要root)
Settings.Secure.putInt(getContentResolver(),Settings.Secure.ALLOW_MOCK_LOCATION, 1);
Run Code Online (Sandbox Code Playgroud)
但现在这个选项是特定于应用程序的,意味着您必须在开发人员选项中选择模拟器应用程序.
有没有办法以编程方式更改此设置(将我的应用程序插入允许列表)?
我猜不小心按下了一个键或组合键更改了Android Studio中的设置,此后android studio表现得很怪异,无法让我正确选择代码。
看下面的图片。
我已经检查了Android Studio设置,但找不到与此相关的任何内容。
PS我正在使用Windows 10。
在Android Lollipop中,当您长按通知时,它可让您访问该通知的应用程序的设置,例如优先级,或者只是阻止它.我是否有意图访问这些设置?
notifications android android-notifications android-settings android-5.0-lollipop
minSdkVersion 18
targetSdkVersion 27
Run Code Online (Sandbox Code Playgroud)
使用以下代码,我可以打开Google设置页面.
private static final String GOOGLE_SETTINGS_COMPONENT = "com.google.android.gms";
private static final String GOOGLE_SETTINGS_ACTIVITY = ".app.settings.GoogleSettingsActivity";
Intent i = new Intent();
i.setClassName(GOOGLE_SETTINGS_COMPONENT,GOOGLE_SETTINGS_COMPONENT + GOOGLE_SETTINGS_ACTIVITY);
try {
startActivity(i);
} catch (android.content.ActivityNotFoundException ex) {
Toast.makeText(getApplicationContext(), "Activity Not Found", Toast.LENGTH_LONG).show();
}
Run Code Online (Sandbox Code Playgroud)
android android-intent google-play android-settings google-settings
Android 9 引入了一个限制应用程序电池使用的选项(有时称为限制应用程序后台活动)。可以在应用程序设置中设置此选项:
本页简要描述了其效果:可能不会在指定时间触发警报,作业也不会。对于用户体验来说并不总是很好,特别是如果用户不知道或忘记设置了此限制。
不过,我发现一些应用程序能够检测到此选项何时设置为“受限”,例如显示一条消息,指示某些功能可能因此而出现异常行为。哪个API可以用来检测这个?我试过了:
UsageStatsManager.getAppStandbyBucket():在更改电池限制之前和之后查询此方法并没有改变其值。似乎与应用程序的使用频率相关更多。
PowerManager.isIgnoringBatteryOptimizations(): 再说一遍,没有变化。
我有一个简单的问题,我们如何在我们的应用程序中启用或启动Google位置设置 - >访问位置.我正在谈论谷歌已更新的新设置.

编辑:
意图打开谷歌设置我发现只有这个:
Intent settings = new Intent();
settings.setPackage("com.google.android.gms");
settings.addCategory(Intent.CATEGORY_LAUNCHER);
starrtActivity(settings);
Run Code Online (Sandbox Code Playgroud)
但我想打开'Access Location',
我们可以直接启用位置访问或使用Intent打开位置访问权限.
我还检查了开发者网站,但是dint在下面找到了一个
ACTION_LOCATION_SOURCE_SETTINGS
如果可能,请告诉我,因为它可能使我们的应用程序能够获得最新的准确位置.
在我的应用程序中,有什么方法可以将用户重定向到特定的设置“页面”?我的应用程序用作锁定屏幕应用程序,因此我希望能够将用户直接重定向到Android设置的“锁定屏幕”部分。(最好通过按钮或类似方式)