导航:首页 > 操作系统 > androidsettings修改

androidsettings修改

发布时间:2023-05-15 01:37:31

android4.1源码中哪里修改 Settings中Font size的默认选项

frameworks/base/core/java/android/content/res/Configuration.java文件中
public void setToDefaults() 这个方法中进行修改,

把默认字体要改为大,把fontScale值改为1.15f,全清编译
public void setToDefaults() {
fontScale = 1.15f; //normal value is 1

⑵ 如何在系统settings里添加设置选项

目的:在通话设置菜单下,添加一dect设置菜单,里面再添加一checkBOxPreference

来使能硬件模块。

-------------------------

目前做的项目,需要在系统settings里面添加一选项来使能硬件模块,里面涉及到的preference知识,请网上了解,这里记录下方法。

1,settings 应用一般在 目录:\packages\apps\Settings,我们先找到通话设置的布局位置,看看它在那个包路径下,进入\packages\apps\Settings\res\xml,打开settings.xml文件:

Java代码

<com.android.settings.IconPreferenceScreen

android:key="call_settings"

settings:icon="@drawable/ic_settings_call"

android:title="@string/call_settings_title">

<intent

android:action="android.intent.action.MAIN"

android:targetPackage="com.android.phone"

android:targetClass="com.android.phone.CallFeaturesSetting" />

</com.android.settings.IconPreferenceScreen>

<com.android.settings.IconPreferenceScreen

android:key="call_settings"

settings:icon="@drawable/ic_settings_call"

android:title="@string/call_settings_title">

<intent

android:action="android.intent.action.MAIN"

android:targetPackage="com.android.phone"

android:targetClass="com.android.phone.CallFeaturesSetting" />

</com.android.settings.IconPreferenceScreen>

android:targetPackage="com.android.phone"

android:targetClass="com.android.phone.CallFeaturesSetting"

targetPackage:表示包名,根据此我们可以找到通话设置的路径。

targetClass:表示此布局文件被那个类所引用,根据此类,我们可以知道在那个文件里面管理我们的通话设置功能。 www.55zm.com

2.根据包名,我们可以看到在\packages\apps\Phone 目录下,进入\res\xml目录下

找到通话布局文件:call_feature_setting.xml,根据类名,很容易找到布局文件。

里面内容如下:

Java代码

<PreferenceCategory android:key="button_misc_category_key"

android:title="@string/other_settings"

android:persistent="false" />

<!-- Dect settings -->

<PreferenceScreen

android:key="dect_settings"

android:title="@string/dect_mole_title"

android:summary="@string/dect_mole_title" >

<intent

android:action="android.intent.action.MAIN"

android:targetPackage="com.android.phone"

android:targetClass="com.android.phone.DectSettings" />

</PreferenceScreen>

<CheckBoxPreference

android:key="button_auto_retry_key"

android:title="@string/auto_retry_mode_title"

android:persistent="false"

android:summary="@string/auto_retry_mode_summary"/>

<PreferenceCategory android:key="button_misc_category_key"

android:title="@string/other_settings"

android:persistent="false" />

<!-- Dect settings -->

<PreferenceScreen

android:key="dect_settings"

android:title="@string/dect_mole_title"

android:summary="@string/dect_mole_title" >

<intent

android:action="android.intent.action.MAIN"

android:targetPackage="com.android.phone"

android:targetClass="com.android.phone.DectSettings" />

</PreferenceScreen>

<CheckBoxPreference

android:key="button_auto_retry_key"

android:title="@string/auto_retry_mode_title"

android:persistent="false"

android:summary="@string/auto_retry_mode_summary"/>

Dect setting 就是新添加进入的设置菜单,我们的原则尽量不大量修改,所以添加一个PreferenceScreen,新增一个类文件来管理DECt菜单选项。

android:targetPackage="com.android.phone"

android:targetClass="com.android.phone.DectSettings"

我们指明了包名,类名后,因这是个activity,所以我们需要到Phone目录下修改

AndroidManifest.xml文件,指明启动的activity的类名.

Java代码

<activity android:name="CdmaCallOptions"

android:label="@string/cdma_options">

<intent-filter>

<action android:name="android.intent.action.MAIN" />

</intent-filter>

</activity>

<!-- dect activity -->

<activity android:name="DectSettings"

android:label="@string/dect_mole_title">

<intent-filter>

<action android:name="android.intent.action.MAIN" />

</intent-filter>

</activity>

<activity android:name="CdmaCallOptions"

android:label="@string/cdma_options">

<intent-filter>

<action android:name="android.intent.action.MAIN" />

</intent-filter>

</activity>

<!-- dect activity -->

<activity android:name="DectSettings"

android:label="@string/dect_mole_title">

<intent-filter>

<action android:name="android.intent.action.MAIN" />

</intent-filter>

</activity>

3.修改好后,我们必须在此activity里添加preference布局文件。

在此目录Phone\res\xml下,新增dect_settings.xml

Java代码

<?xml version="1.0" encoding="utf-8"?>

<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"

android:title="@string/dect_mole_title">

<CheckBoxPreference

android:key="button_dect_mole_key"

android:title="@string/dect_mole_title"

android:defaultValue="true"

android:summaryOn="@string/dect_mole_start"

android:summaryOff="@string/dect_mole_stop"

/>

</PreferenceScreen>

<?xml version="1.0" encoding="utf-8"?>

<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"

android:title="@string/dect_mole_title">

<CheckBoxPreference

android:key="button_dect_mole_key"

android:title="@string/dect_mole_title"

android:defaultValue="true"

android:summaryOn="@string/dect_mole_start"

android:summaryOff="@string/dect_mole_stop"

/>

</PreferenceScreen>

好了,总体布局已经完成

4.在\packages\apps\Phone\src\com\android\phone目录下

新增DectSettings.java文件

加载布局文件:

//dect xml

addPreferencesFromResource(R.xml.dect_settings);

里面涉及到的MidPhoneServce服务,是自己添加的,主要通过此服务的AIDL接口跟硬件打交道。想了解系统服务,请网上查找资料。

源码如下:

Java代码

package com.android.phone;

import android.content.DialogInterface;

import android.os.AsyncResult;

import android.os.Bundle;

import android.os.Handler;

import android.os.Message;

import android.preference.CheckBoxPreference;

import android.preference.Preference;

import android.preference.PreferenceActivity;

import android.preference.PreferenceScreen;

import android.content.SharedPreferences;

import android.content.SharedPreferences.Editor;

import android.content.pm.ActivityInfo;

import android.content.pm.PackageManager;

import android.content.pm.ResolveInfo;

import android.os.Bundle;

import android.os.Handler;

import android.util.Log;

import android.content.Context;

import com.android.phone.R;

import android.os.IMidPhoneService;

import android.os.RemoteException;

import android.os.ServiceManager;

import android.provider.Settings;

public class DectSettings extends PreferenceActivity {

private static final String TAG = "DectSettings";

private static final String BUTTON_DECT_KEY = "button_dect_mole_key";

private CheckBoxPreference mButtonDect;

public IMidPhoneService midphoneservice = null;

@Override

protected void onCreate(Bundle icicle) {

super.onCreate(icicle);

//dect xml

addPreferencesFromResource(R.xml.dect_settings);

mButtonDect = (CheckBoxPreference)findPreference(BUTTON_DECT_KEY);

mButtonDect.setPersistent(false);

if(mButtonDect != null) {

int dect_state = Settings.System.getInt(

getContentResolver(),Settings.System.DECT_SAVED_STATE, 1);

mButtonDect.setChecked( dect_state!= 0);

Settings.System.putInt(getContentResolver(),

Settings.System.DECT_SAVED_STATE,dect_state);

Log.e(TAG,"settings:------------->" + dect_state);

}

}

@Override

public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {

if (preference == mButtonDect ) {

int dect = mButtonDect.isChecked() ? 1 : 0;

boolean state;

if(dect == 1)

state = true;

else

state = false;

try{

midphoneservice = IMidPhoneService.Stub.asInterface(ServiceManager.getService("midphone"));

Settings.System.putInt(getContentResolver(),

Settings.System.DECT_SAVED_STATE,dect);

midphoneservice.setDectEnabled(state);

Log.e(TAG,"settings:------------->" + dect);

} catch (RemoteException e) {

e.printStackTrace();

}

return true;

}

return false;

}

@Override

protected void onResume() {

super.onResume();

if (mButtonDect != null) {

mButtonDect.setChecked(Settings.System.getInt(

getContentResolver(),

阅读全文

与androidsettings修改相关的资料

热点内容
程序员那么可爱第几集在重庆相遇 浏览:673
上班两公里源码 浏览:817
南宁溯源码燕窝订制 浏览:933
在个人文件夹中新建文件 浏览:445
中国国家地理pdf下载 浏览:107
几套房子抵押可以解压其中一套吗 浏览:569
微爱app室外地板怎么装饰 浏览:231
辽宁省医保如何用app转 浏览:311
钟表cNc编程招聘 浏览:546
均线pdf 浏览:921
手机破解加密的压缩包 浏览:429
dnf程序员分析 浏览:365
外星人适合编程吗 浏览:205
phpcurl302跳转 浏览:843
奔放的程序员我的 浏览:714
服务器磁盘满了文件删不掉该如何处理 浏览:847
压缩弹簧展开长度 浏览:509
如何共享国外app 浏览:687
淘宝app如何扫描图片 浏览:594
反编译作业帮 浏览:856