OutCallReceiver
package org.gentry.ipdail;import android.content.BroadcastReceiver;import android.content.Context;import android.content.Intent;import android.content.SharedPreferences;public class OutCallReceiver extends BroadcastReceiver {/** * 当有广播时间产生的时候,就会执行onReceive方法 */@Overridepublic void onReceive(Context context, Intent intent) {String number = getResultData(); // 外拨的电话号码// 替换掉这个号码SharedPreferences sp = context.getSharedPreferences("config",Context.MODE_PRIVATE);String ipnumber = sp.getString("ipnumber", "");String newnumber = ipnumber + number;// 设置外拨的电话号码setResultData(newnumber);}}
MainActivity
package org.gentry.ipdail;import android.app.Activity;import android.content.SharedPreferences;import android.content.SharedPreferences.Editor;import android.os.Bundle;import android.view.View;import android.widget.EditText;import android.widget.Toast;public class MainActivity extends Activity {private EditText et_ipnumber;private SharedPreferences sp;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);et_ipnumber = (EditText) findViewById(R.id.et_ipnumber);// 程序下次打开时edittext内容存在sp = getSharedPreferences("config", MODE_PRIVATE);et_ipnumber.setText(sp.getString("ipnumber", ""));}public void click(View view) {String ipnumber = et_ipnumber.getText().toString().trim();Editor editor = sp.edit();editor.putString("ipnumber", ipnumber);editor.commit();Toast.makeText(this, "设置完成", Toast.LENGTH_SHORT).show();}}



更多相关文章

  1. Android(安卓)仿苹果自定义Dialog
  2. com.android.cts.devicepolicy.ManagedProfileTest -- testAppLi
  3. Android(安卓)Metrail Design
  4. Android(安卓)技术总结(016)—— 使用百度地图api获取当前位置
  5. android EditText不弹出软键盘的方法
  6. ListView设置Header无分隔线
  7. android广播 demo
  8. GPS的开关设置
  9. Android(安卓)Activity生命周期应用 网络设置

随机推荐

  1. Android遍历数组、集合和Map
  2. Android(安卓)天气预报(使用okHttp、Async
  3. Android(安卓)Notification 显示后消失
  4. Android(安卓)ContentProvider和getConte
  5. Android(安卓)多点触控初步学习
  6. Android(安卓)修改开机画面
  7. 单独编译Android(安卓)app模块
  8. Could not resolve all files for config
  9. android中设置Animation 动画效果
  10. Android(安卓)Phone 类的详细 分析 各个