Excessive JNI global references - Android

本文介绍了一种使用Android系统的ContentObserver来监听特定号码短信的方法,实现了短信接收并将其标记为已读,避免系统通知用户的功能。文章提供了一个具体的实现代码示例。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

ContentObserver is used in ContentService

ObserverNode is a capsulation of ObserverEntry to provide addObserverLocked method and so on.

./frameworks/base/core/java/android/content/ContentService.java calls registerContentObserver method to register uri and responding observer.

during this registering, a ObserverNode instance would be created, so, a ObserverEntry would be created as a observer list.

./frameworks/base/services/java/com/android/server/SystemServer.java initializes ContentService via ContentService.main.

 

 

 

 

 

 

 


Here is a example for using ContentObserver.
http://www.eoeandroid.com/forum.php?mod=viewthread&tid=9162&page=1

最近有个朋友问了我如何接受指定号码的短信,并且不让系统截取到通知用户。真好前端时间看天朝group,也有个朋友问了这个问题,而且通过ContentObserver方式解决了,我这里就把我实现的代码贴出来,以便需要的朋友参考。

   1. public class ScreenTest extends Activity {
   2.       
   3.         class SmsContent extends ContentObserver{
   4.                 private Cursor cursor = null;
   5.                 public SmsContent(Handler handler) {
   6.                         super(handler);
   7.                 }
   8.               
   9.                 /**
  10.                  * @Description 当短信表发送改变时,调用该方法
  11.                  *                                 需要两种权限
  12.                  *                                 android.permission.READ_SMS读取短信
  13.                  *                                 android.permission.WRITE_SMS写短信
  14.                  * @Author Snake
  15.                  * @Date 2010-1-12
  16.                  */
  17.                 @Override
  18.                 public void onChange(boolean selfChange) {
  19.                         // TODO Auto-generated method stub
  20.                         super.onChange(selfChange);
  21.                         //读取收件箱中指定号码的短信
  22.                         cursor = managedQuery(Uri.parse("content://sms/inbox"),
                                                    new String[]{"_id", "address", "read"},
                                                    " address=? and read=?",
                                                    new String[]{"12345678901", "0"},
                                                    "date desc");
  23.                       
  24.                         if (cursor != null){
  25.                                 ContentValues values = new ContentValues();
  26.                                 values.put("read", "1");                //修改短信为已读模式
  27.                                 cursor.moveToFirst();
  28.                                 while (cursor.isLast()){
  29.                                         //更新当前未读短信状态为已读
  30.                                         getContentResolver().update(Uri.parse("content://sms/inbox"),
                                                                          values,
                                                                          " _id=?",
                                                                          new String[]{""+cursor.getInt(0)});
  31.                                         cursor.moveToNext();
  32.                                 }
  33.                         }
  34.                 }
  35.         }
  36.       
  37.     /** Called when the activity is first created. */
  38.     @Override
  39.     public void onCreate(Bundle savedInstanceState) {
  40.         super.onCreate(savedInstanceState);
  41.         setContentView(R.layout.main);
  42.         SmsContent content = new SmsContent(new Handler());
  43.         //注册短信变化监听
  44.         this.getContentResolver().registerContentObserver(Uri.parse("content://sms/"), true, content);
  45.     }
  46. }

### 关于 ErrNodeExcessRotation 错误的原因分析 ErrNodeExcessRotation 是指在节点集合旋转过程中检测到超出预期范围的旋转误差。这种错误通常发生在三维重建或结构计算的过程中,特别是在处理全局平移优化(Global Translation Optimization)或者初始结构计算时[^1]。 #### 可能的原因 1. **相对位移图的最大连通分量问题** 在 `Translation_averaging()` 函数的第一步中,程序会保留最大边连接组件图中的相对位移关系。如果某些节点未被正确纳入该图,则可能导致后续的全局翻译求解器无法获得一致的结果,从而引发过大的旋转偏差[^1]。 2. **线性规划求解失败** 使用 `OSI_CLP_SolverWrapper` 进行线性规划求解时,可能会因为输入数据不满足约束条件而返回不可行状态 (`bFeasible = false`)。这可能进一步影响最终的全局旋转估计精度。 3. **初始化阶段的数据质量问题** 如果在调用 `Compute_Initial_Structure(tripletWise_matches)` 的时候传入了低质量匹配数据,则会导致初始结构存在较大噪声,进而传播至后续步骤并放大为显著的旋转误差。 4. **排列方向的影响** 考虑到引用[2]提到的方法,在构建排列组合时采用特定的方向切换策略可以有效减少累积误差。然而,如果没有遵循这一原则,则可能出现不必要的额外旋转角度积累[^2]。 #### 解决方案建议 - 对输入数据进行预筛选和验证,确保所有参与运算的节点都属于同一个强连通子图。 - 增加对线性规划求解过程的状态监控机制,当发现不可行情况时及时调整参数设置重新尝试。 - 改善 triplet-wise 匹配的质量控制流程,剔除明显异常点后再执行初始结构计算操作。 - 遵循推荐的最佳实践来管理排列顺序变化规律,避免因不当选择而导致过多无谓转动发生。 ```python def validate_and_adjust_rotations(sfm_data, globalR_map): """ Validate rotations within nodes and adjust if necessary. Args: sfm_data (dict): Structure-from-motion data containing all relevant information. globalR_map (dict): Map of global rotations associated with each node. Returns: dict: Adjusted global rotation mappings after validation checks. """ adjusted_globalR = {} for key, value in globalR_map.items(): # Perform sanity check on individual rotation matrices here... # Example adjustment logic based on some criteria corrected_value = apply_correction(value) # Hypothetical function call adjusted_globalR[key] = corrected_value return adjusted_globalR def apply_correction(rotation_matrix): """Apply correction to given rotation matrix.""" pass # Placeholder implementation; actual algorithm depends on specific requirements ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值