本文整理匯總了Java中android.content.IntentFilter.hasAction方法的典型用法代碼示例。如果您正苦於以下問題:Java IntentFilter.hasAction方法的具體用法?Java IntentFilter.hasAction怎麽用?Java IntentFilter.hasAction使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.content.IntentFilter
的用法示例。
在下文中一共展示了IntentFilter.hasAction方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getReceiverName
import android.content.IntentFilter; //導入方法依賴的package包/類
private ActivityInfo getReceiverName (String pkg,
PackageManager packageManager) {
Intent intent = new Intent();
intent.setPackage(pkg);
//intent.setAction(Constants.ACTION_RECEIVE_MESSAGE);
for (ResolveInfo resolveInfo : packageManager.queryBroadcastReceivers(intent,
PackageManager.GET_RESOLVED_FILTER |
PackageManager.GET_DISABLED_COMPONENTS)) {
ActivityInfo activityInfo = resolveInfo.activityInfo;
if (!activityInfo.packageName.equals(pkg))
continue;
IntentFilter filter = resolveInfo.filter;
if (filter != null && filter.hasAction(Constants.ACTION_RECEIVE_MESSAGE)) {
return activityInfo;
}
}
// Not found
return null;
}
示例2: customReceiverPass
import android.content.IntentFilter; //導入方法依賴的package包/類
/**
* Check package's MiPush custom receiver (handle com.xiaomi.mipush.RECEIVE_MESSAGE action)
* is enabled.
* @see PushMessageReceiver
* @see Constants#ACTION_RECEIVE_MESSAGE
* @param info Package info
* @return enable status. If this package not have custom receiver, will
* still returns true.
*/
private boolean customReceiverPass (PackageInfo info, PackageManager packageManager) {
//if (info.receivers == null)
// return true;
Intent intent = new Intent();
intent.setPackage(info.packageName);
//intent.setAction(Constants.ACTION_RECEIVE_MESSAGE);
for (ResolveInfo resolveInfo : packageManager.queryBroadcastReceivers(intent,
PackageManager.GET_RESOLVED_FILTER |
PackageManager.GET_DISABLED_COMPONENTS)) {
ActivityInfo activityInfo = resolveInfo.activityInfo;
if (!activityInfo.packageName.equals(info.packageName))
continue;
IntentFilter filter = resolveInfo.filter;
if (filter != null && filter.hasAction(Constants.ACTION_RECEIVE_MESSAGE)) {
boolean enabled = packageManager.getComponentEnabledSetting(new ComponentName(
activityInfo.packageName, activityInfo.name
)) == PackageManager.COMPONENT_ENABLED_STATE_ENABLED;
Log4a.i(TAG, "Handle receiver: " + activityInfo.name +
"; enabled: " + enabled);
return enabled;
}
}
Log4a.d(TAG, "Not found custom message receiver in " + info.packageName);
// Not found
return true;
}
示例3: filterEquals
import android.content.IntentFilter; //導入方法依賴的package包/類
private boolean filterEquals(IntentFilter f1, IntentFilter f2) {
int s1 = f1.countActions();
int s2 = f2.countActions();
if (s1 != s2) {
return false;
}
for (int i = 0; i < s1; i++) {
if (!f2.hasAction(f1.getAction(i))) {
return false;
}
}
s1 = f1.countCategories();
s2 = f2.countCategories();
if (s1 != s2) {
return false;
}
for (int i = 0; i < s1; i++) {
if (!f2.hasCategory(f1.getCategory(i))) {
return false;
}
}
s1 = f1.countDataTypes();
s2 = f2.countDataTypes();
if (s1 != s2) {
return false;
}
s1 = f1.countDataSchemes();
s2 = f2.countDataSchemes();
if (s1 != s2) {
return false;
}
for (int i = 0; i < s1; i++) {
if (!f2.hasDataScheme(f1.getDataScheme(i))) {
return false;
}
}
s1 = f1.countDataAuthorities();
s2 = f2.countDataAuthorities();
if (s1 != s2) {
return false;
}
s1 = f1.countDataPaths();
s2 = f2.countDataPaths();
if (s1 != s2) {
return false;
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
s1 = f1.countDataSchemeSpecificParts();
s2 = f2.countDataSchemeSpecificParts();
if (s1 != s2) {
return false;
}
}
return true;
}
示例4: filterEquals
import android.content.IntentFilter; //導入方法依賴的package包/類
private boolean filterEquals(IntentFilter f1, IntentFilter f2) {
int s1 = f1.countActions();
int s2 = f2.countActions();
if (s1 != s2) {
return false;
}
for (int i=0; i<s1; i++) {
if (!f2.hasAction(f1.getAction(i))) {
return false;
}
}
s1 = f1.countCategories();
s2 = f2.countCategories();
if (s1 != s2) {
return false;
}
for (int i=0; i<s1; i++) {
if (!f2.hasCategory(f1.getCategory(i))) {
return false;
}
}
s1 = f1.countDataTypes();
s2 = f2.countDataTypes();
if (s1 != s2) {
return false;
}
for (int i=0; i<s1; i++) {
if (!f2.hasExactDataType(f1.getDataType(i))) {
return false;
}
}
s1 = f1.countDataSchemes();
s2 = f2.countDataSchemes();
if (s1 != s2) {
return false;
}
for (int i=0; i<s1; i++) {
if (!f2.hasDataScheme(f1.getDataScheme(i))) {
return false;
}
}
s1 = f1.countDataAuthorities();
s2 = f2.countDataAuthorities();
if (s1 != s2) {
return false;
}
for (int i=0; i<s1; i++) {
if (!f2.hasDataAuthority(f1.getDataAuthority(i))) {
return false;
}
}
s1 = f1.countDataPaths();
s2 = f2.countDataPaths();
if (s1 != s2) {
return false;
}
for (int i=0; i<s1; i++) {
if (!f2.hasDataPath(f1.getDataPath(i))) {
return false;
}
}
s1 = f1.countDataSchemeSpecificParts();
s2 = f2.countDataSchemeSpecificParts();
if (s1 != s2) {
return false;
}
for (int i=0; i<s1; i++) {
if (!f2.hasDataSchemeSpecificPart(f1.getDataSchemeSpecificPart(i))) {
return false;
}
}
return true;
}