android EditText 的输入监听

EditText keyEdit = (EditText) GetSubView(R.id.searchkey);keyEdit.addTextChangedListener(watcher);  

private TextWatcher watcher = new TextWatcher(){public void beforeTextChanged(CharSequence s, int start, int count,int after) {}public void onTextChanged(CharSequence s, int start, int before,int count) {Log.d("TAG","[TextWatcher][onTextChanged]"+s);}public void afterTextChanged(Editable s) {}    };


打电话

Uri uri = Uri.parse("tel:" + "15950521838");Intent intent = new Intent(Intent.ACTION_CALL, uri);intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);startActivity(intent);


判断当前的场景或服务


public boolean getCurrentSence(Context mContext) {boolean sence = false;try {ActivityManager am = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE);ComponentName cn = am.getRunningTasks(1).get(0).topActivity;if ("com.pateo.music.app.NetMusicPlayer".indexOf(cn.getClassName()) >= 0) {sence = true;}} catch (Exception e) {Log.d(TAG, "" + e);}return sence;}private boolean isStartService(Context ctx,String igrsClassName) {Log.d(TAG, "isStartService : igrsClassName " + igrsClassName  );ActivityManager mActivityManager = (ActivityManager) ctx.getSystemService(Context.ACTIVITY_SERVICE);List<ActivityManager.RunningServiceInfo> currentService = mActivityManager.getRunningServices(100);boolean b = igrsBaseServiceIsStart(currentService, igrsClassName);return b;}private boolean igrsBaseServiceIsStart(List<ActivityManager.RunningServiceInfo> mServiceList,String className) {Log.d(TAG, "igrsBaseServiceIsStart :  className " + className  );String serviceClassName;for (int i = 0; i < mServiceList.size(); i++) { serviceClassName = mServiceList.get(i).service.getClassName(); Log.d(TAG, "serviceClassName : " + serviceClassName);if (className.equals(serviceClassName)) {return true;}}return false;}

数据变动监听


  getContentResolver().registerContentObserver(Contacts.People.CONTENT_URI, true,                new ContentObserver(new Handler()) {                    public void onChange(boolean selfChange) {                        Log.d(TAG,"========= Received Contacts Changes Notification========");                        addContactsToGrammer();                        super.onChange(selfChange);                    }                });

应用下的xml文件的全局保存


String times = getSharedPreferences("voice_first",PreferenceActivity.MODE_WORLD_WRITEABLE | PreferenceActivity.MODE_WORLD_READABLE).getString("times", "0");getSharedPreferences("voice_first",PreferenceActivity.MODE_WORLD_READABLE).edit().putString("times", "1").commit();

判断是否通话中

private boolean phoneIsInUse() {boolean phoneInUse = false;try {ITelephony phone = ITelephony.Stub.asInterface(ServiceManager.checkService("phone"));if (phone != null){phoneInUse = !phone.isIdle();}} catch (RemoteException e) {Log.w(TAG, "", e);}Log.d(TAG,"phoneIsInUse() phoneInUse ======" + phoneInUse);return phoneInUse;}



更多相关文章

  1. android 全局变量 Application
  2. android 中的全局变量问题
  3. 在Android中如何使用全局变量--Application context
  4. Android 全局背景音乐
  5. android 全局异常的处理 详解
  6. Android Application (全局变量)学习使用
  7. android 使用Intent传递数据之全局变量传递
  8. Android 替换全局字体
  9. c++如何设置全局变量

随机推荐

  1. 手动安装android support library 23.0.1
  2. Android 更新UI 只能在主线程?
  3. android listview优化及其解释
  4. Android 使用 ALSA
  5. Android让Library中Manifest也包含进来
  6. Android取消EditText自动获取焦点行为
  7. Android 面试(七):Serializable 这么牛逼,Par
  8. android2.3编译的两个问题
  9. Android 之 下拉(Spinner) 组件示例
  10. Android 控件ImageView图片框