iteye.com/blog/1420761" pre_index="4" title="android-如何在系统settings里添加设置选项">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_module_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(),
Settings.System.DECT_SAVED_STATE, 1) != 0);
}
}
}

</pre>
<br>5.编译,烧录。
<br> # . build/envsetup.sh
<br> 执行 # mmm packages/apps/Phone/
<br> 会在\out\target\product\generic\system\app 生成 Phone.apk文件
<br> 拷贝 此apk到 \out\target\product\smdkv210\system\app 目录下
<br> 编译就行: ./build_android
<br>此时,才能看到修改的效果!
</div>



<div>
<!-- 广告位:PC端-iteye博客详情页底部banner2-728*90 -->
<script>
(function() {
var s = "_" + Math.random().toString(36).slice(2);
document.write('<div id="' + s + '"></div>');
(window.slotbydup=window.slotbydup || []).push({
id: '4774193',
container: s,
size: '728,90',
display: 'inlay-fix'
});
})();
</script><div id="_b8wu5xsq0inc23xr"></div><script charset="utf-8" src="http://pos.baidu.com/qcmm?di=4774193&amp;dri=0&amp;dis=0&amp;dai=0&amp;ps=6141x249&amp;enu=encoding&amp;dcb=___adblockplus&amp;dtm=SSP_JSONP&amp;dvi=0.0&amp;dci=-1&amp;dpt=none&amp;tsr=0&amp;tpr=1535613235796&amp;ti=android-%E5%A6%82%E4%BD%95%E5%9C%A8%E7%B3%BB%E7%BB%9Fsettings%E9%87%8C%E6%B7%BB%E5%8A%A0%E8%AE%BE%E7%BD%AE%E9%80%89%E9%A1%B9%20-%20%E6%97%A0%E8%AF%AD%20-%20ITeye%E5%8D%9A%E5%AE%A2&amp;ari=2&amp;dbv=0&amp;drs=1&amp;pcs=980x1270&amp;pss=980x6189&amp;cfv=0&amp;cpl=0&amp;chi=1&amp;cce=true&amp;cec=UTF-8&amp;tlm=1535584436&amp;rw=320&amp;ltu=http%3A%2F%2Fkoliy.iteye.com%2Fblog%2F1420761&amp;ecd=1&amp;uc=480x800&amp;pis=-1x-1&amp;sr=480x800&amp;tcn=1535613236"></script>
</div>



<div id="bottoms" class="clearfix">
<div id="digg_bottom" class="clearfix"><div class="digged"><strong>2</strong> <br>顶</div><div class="digged"><strong>0</strong> <br>踩</div></div>
<div id="share_weibo">分享到:
<a data-type="sina" href="javascript:;" title="分享到新浪微博"><img src="/images/sina.jpg"></a>
<a data-type="qq" href="javascript:;" title="分享到腾讯微博"><img src="/images/tec.jpg"></a>
</div>
</div>

<div class="blog_nav">
<div class="pre_next">
<a href="/blog/1423579" class="next" title="android-insmod驱动模块出错问题解决方法">android-insmod驱动模块出错问题解决方法</a>
|
<a href="/blog/1407883" class="pre" title="如何把应用程序app编译进android系统">如何把应用程序app编译进android系统</a>
</div>
</div>
<div class="blog_bottom">
<ul>
<li>2012-02-24 10:35</li>
<li>浏览 33108</li>
<li><a href="#comments">评论(0)</a></li>


<li>分类:<a href="http://www.iteye.com/blogs/category/language">编程语言</a></li>
<li class="last"><a href="http://www.iteye.com/wiki/blog/1420761" target="_blank" class="more">查看更多</a></li>
</ul>
</div>

<div class="blog_comment">
<h5>评论</h5>
<a id="comments" name="comments"></a>



</div>

<div class="blog_comment">
<h5>发表评论</h5>
<p style="text-align:center; margin-top:30px;margin-bottom:0px;"><a href="/login" style="background-color:white;"> <img src="/images/login_icon.png" style="vertical-align:middle; margin-right: 10px;"></a><a href="/login"> 您还没有登录,请您登录后再发表评论 </a></p>
</div>



<div class="boutique-curr-box blog_comment">
<div class="boutique-curr clearfix" id="album_detail_wrap">
<h5 class="h3titles">相关资源推荐</h5>
<ul style="margin-top: 15px" class="clearfix">

<li style="width: 50%;float: left;margin: 0;line-height: 25px;overflow:hidden; text-overflow:ellipsis; white-space:nowrap;">

Prev | Next
Pg.: 1 ... 3 4 5 6 7 8 9 10 11 12 13


Back to home | File page

Subscribe | Register | Login | N