简体   繁体   English

Android:组件的IntentFilters

[英]Android: IntentFilters for components

What is a reasonable way to filter out specific cmp Strings with an Android IntentFilters which are declared in code in broadcast Receivers (rather than in android.xml)? 有什么合理的方法可以使用Android IntentFilters过滤掉特定的cmp字符串,这些字符串在广播接收器(而不是android.xml)中的代码中声明?

The case I'm searching for has: 我要寻找的情况有:

   action = android.intent.action.MAIN
   category = android.intent.category.LAUNCHER

Any advice would be greatly appreciated. 任何建议将不胜感激。

I do a positive test for stuff I'm interested in and ignore everything that doesn't conform, as opposed to negatively trying to throw away all possible non-interesting things and keeping what's left. 我会对自己感兴趣的事物进行正面测试,并忽略所有不符合要求的事物,而不是消极地尝试丢弃所有可能的无趣事物并保留所剩内容。 But maybe I've misunderstood your problem. 但是也许我误解了你的问题。

The issue was the intent filter only works over the application in which it occurs. 问题是意图过滤器仅在发生它的应用程序上起作用。 This meant MAIN and LAUNCHER wasn't finding anything except for application relaunch events which weren't actually occurring. 这意味着MAIN和LAUNCHER除了实际上没有发生的应用程序重新启动事件之外,什么也没找到。 The system freeze up was caused by a separate error on the phone, not by the FILTER actually processing over too much information. 系统死机是由手机上的一个单独错误引起的,而不是由FILTER实际处理了太多信息引起的。

Still not sure how to search within an app by cmp or Component but the bigger issue was not finding stuff outside the application and that has alternative approaches. 仍然不确定如何通过cmp或Component在应用程序内进行搜索,但更大的问题是没有在应用程序之外找到东西,这具有替代方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM