Java Code Examples for android.content.IntentFilter#getAction()

The following examples show how to use android.content.IntentFilter#getAction() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LocalBroadcastManager.java    From guideshow with MIT License 6 votes vote down vote up
/**
 * Register a receive for any local broadcasts that match the given IntentFilter.
 *
 * @param receiver The BroadcastReceiver to handle the broadcast.
 * @param filter Selects the Intent broadcasts to be received.
 *
 * @see #unregisterReceiver
 */
public void registerReceiver(BroadcastReceiver receiver, IntentFilter filter) {
    synchronized (mReceivers) {
        ReceiverRecord entry = new ReceiverRecord(filter, receiver);
        ArrayList<IntentFilter> filters = mReceivers.get(receiver);
        if (filters == null) {
            filters = new ArrayList<IntentFilter>(1);
            mReceivers.put(receiver, filters);
        }
        filters.add(filter);
        for (int i=0; i<filter.countActions(); i++) {
            String action = filter.getAction(i);
            ArrayList<ReceiverRecord> entries = mActions.get(action);
            if (entries == null) {
                entries = new ArrayList<ReceiverRecord>(1);
                mActions.put(action, entries);
            }
            entries.add(entry);
        }
    }
}
 
Example 2
Source File: LocalBroadcastManager.java    From Dashchan with Apache License 2.0 6 votes vote down vote up
/**
 * Register a receive for any local broadcasts that match the given IntentFilter.
 *
 * @param receiver
 *            The BroadcastReceiver to handle the broadcast.
 * @param filter
 *            Selects the Intent broadcasts to be received.
 *
 * @see #unregisterReceiver
 */
public void registerReceiver(BroadcastReceiver receiver, IntentFilter filter) {
	synchronized (mReceivers) {
		ReceiverRecord entry = new ReceiverRecord(filter, receiver);
		ArrayList<IntentFilter> filters = mReceivers.get(receiver);
		if (filters == null) {
			filters = new ArrayList<>(1);
			mReceivers.put(receiver, filters);
		}
		filters.add(filter);
		for (int i = 0; i < filter.countActions(); i++) {
			String action = filter.getAction(i);
			ArrayList<ReceiverRecord> entries = mActions.get(action);
			if (entries == null) {
				entries = new ArrayList<>(1);
				mActions.put(action, entries);
			}
			entries.add(entry);
		}
	}
}
 
Example 3
Source File: LocalBroadcastManager.java    From android-sdk with MIT License 6 votes vote down vote up
/**
 * Register a receive for any local broadcasts that match the given IntentFilter.
 *
 * @param receiver The BroadcastReceiver to handle the broadcast.
 * @param filter   Selects the Intent broadcasts to be received.
 * @see #unregisterReceiver
 */
public void registerReceiver(BroadcastReceiver receiver, IntentFilter filter) {
    synchronized (mReceivers) {
        ReceiverRecord entry = new ReceiverRecord(filter, receiver);
        ArrayList<IntentFilter> filters = mReceivers.get(receiver);
        if (filters == null) {
            filters = new ArrayList<>(1);
            mReceivers.put(receiver, filters);
        }
        filters.add(filter);
        for (int i = 0; i < filter.countActions(); i++) {
            String action = filter.getAction(i);
            ArrayList<ReceiverRecord> entries = mActions.get(action);
            if (entries == null) {
                entries = new ArrayList<>(1);
                mActions.put(action, entries);
            }
            entries.add(entry);
        }
    }
}
 
Example 4
Source File: LocalBroadcastManager.java    From CodenameOne with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Register a receive for any local broadcasts that match the given IntentFilter.
 *
 * @param receiver The BroadcastReceiver to handle the broadcast.
 * @param filter Selects the Intent broadcasts to be received.
 *
 * @see #unregisterReceiver
 */
public void registerReceiver(BroadcastReceiver receiver, IntentFilter filter) {
    synchronized (mReceivers) {
        ReceiverRecord entry = new ReceiverRecord(filter, receiver);
        ArrayList<IntentFilter> filters = mReceivers.get(receiver);
        if (filters == null) {
            filters = new ArrayList<IntentFilter>(1);
            mReceivers.put(receiver, filters);
        }
        filters.add(filter);
        for (int i=0; i<filter.countActions(); i++) {
            String action = filter.getAction(i);
            ArrayList<ReceiverRecord> entries = mActions.get(action);
            if (entries == null) {
                entries = new ArrayList<ReceiverRecord>(1);
                mActions.put(action, entries);
            }
            entries.add(entry);
        }
    }
}
 
Example 5
Source File: LocalBroadcastManager.java    From adt-leanback-support with Apache License 2.0 6 votes vote down vote up
/**
 * Register a receive for any local broadcasts that match the given IntentFilter.
 *
 * @param receiver The BroadcastReceiver to handle the broadcast.
 * @param filter Selects the Intent broadcasts to be received.
 *
 * @see #unregisterReceiver
 */
public void registerReceiver(BroadcastReceiver receiver, IntentFilter filter) {
    synchronized (mReceivers) {
        ReceiverRecord entry = new ReceiverRecord(filter, receiver);
        ArrayList<IntentFilter> filters = mReceivers.get(receiver);
        if (filters == null) {
            filters = new ArrayList<IntentFilter>(1);
            mReceivers.put(receiver, filters);
        }
        filters.add(filter);
        for (int i=0; i<filter.countActions(); i++) {
            String action = filter.getAction(i);
            ArrayList<ReceiverRecord> entries = mActions.get(action);
            if (entries == null) {
                entries = new ArrayList<ReceiverRecord>(1);
                mActions.put(action, entries);
            }
            entries.add(entry);
        }
    }
}
 
Example 6
Source File: LocalBroadcastManager.java    From V.FlyoutTest with MIT License 6 votes vote down vote up
/**
 * Register a receive for any local broadcasts that match the given IntentFilter.
 *
 * @param receiver The BroadcastReceiver to handle the broadcast.
 * @param filter Selects the Intent broadcasts to be received.
 *
 * @see #unregisterReceiver
 */
public void registerReceiver(BroadcastReceiver receiver, IntentFilter filter) {
    synchronized (mReceivers) {
        ReceiverRecord entry = new ReceiverRecord(filter, receiver);
        ArrayList<IntentFilter> filters = mReceivers.get(receiver);
        if (filters == null) {
            filters = new ArrayList<IntentFilter>(1);
            mReceivers.put(receiver, filters);
        }
        filters.add(filter);
        for (int i=0; i<filter.countActions(); i++) {
            String action = filter.getAction(i);
            ArrayList<ReceiverRecord> entries = mActions.get(action);
            if (entries == null) {
                entries = new ArrayList<ReceiverRecord>(1);
                mActions.put(action, entries);
            }
            entries.add(entry);
        }
    }
}
 
Example 7
Source File: LocalBroadcastManager.java    From android-recipes-app with Apache License 2.0 6 votes vote down vote up
/**
 * Register a receive for any local broadcasts that match the given IntentFilter.
 *
 * @param receiver The BroadcastReceiver to handle the broadcast.
 * @param filter Selects the Intent broadcasts to be received.
 *
 * @see #unregisterReceiver
 */
public void registerReceiver(BroadcastReceiver receiver, IntentFilter filter) {
    synchronized (mReceivers) {
        ReceiverRecord entry = new ReceiverRecord(filter, receiver);
        ArrayList<IntentFilter> filters = mReceivers.get(receiver);
        if (filters == null) {
            filters = new ArrayList<IntentFilter>(1);
            mReceivers.put(receiver, filters);
        }
        filters.add(filter);
        for (int i=0; i<filter.countActions(); i++) {
            String action = filter.getAction(i);
            ArrayList<ReceiverRecord> entries = mActions.get(action);
            if (entries == null) {
                entries = new ArrayList<ReceiverRecord>(1);
                mActions.put(action, entries);
            }
            entries.add(entry);
        }
    }
}
 
Example 8
Source File: HookIPCImpl.java    From Introspy-Android with GNU General Public License v2.0 6 votes vote down vote up
public void execute(Object... args) {
	_logBasicInfo();
	String out = "";
	
	// arg1 is an intent filter
	IntentFilter intentFilter = (IntentFilter) args[1];
	if (intentFilter != null) {
		out = "-> Intent Filter: \n";
		for (int i = 0; i < intentFilter.countActions(); i++)
			out += "--> [Action "+ i +":"+intentFilter.getAction(i)+"]\n";
		out = out.substring(0, out.length() - 1);
		_logParameter("Intent Filter", out);
	}
	
	// args[2] is the permissions
	if (args.length > 2 && args[2] != null) {
		out += ", permissions: " + args[2];
		_logParameter("Permissions", args[2]);
	}
	_logLine(out);
	
	if (args.length == 2 || (args.length > 2 && args[2] == null))			
		_logFlush_I("-> No permissions explicitely defined for the Receiver");
	else
		_logFlush_I();
}
 
Example 9
Source File: LocalBroadcastManager.java    From koala--Android-Plugin-Runtime- with Apache License 2.0 6 votes vote down vote up
/**
 * Register a receive for any local broadcasts that match the given
 * IntentFilter.
 * 
 * @param receiver
 *            The BroadcastReceiver to handle the broadcast.
 * @param filter
 *            Selects the Intent broadcasts to be received.
 * 
 * @see #unregisterReceiver
 */
public void registerReceiver(BroadcastReceiver receiver, IntentFilter filter) {
	synchronized (mReceivers) {
		ReceiverRecord entry = new ReceiverRecord(filter, receiver);
		ArrayList<IntentFilter> filters = mReceivers.get(receiver);
		if (filters == null) {
			filters = new ArrayList<IntentFilter>(1);
			mReceivers.put(receiver, filters);
		}
		filters.add(filter);
		for (int i = 0; i < filter.countActions(); i++) {
			String action = filter.getAction(i);
			ArrayList<ReceiverRecord> entries = mActions.get(action);
			if (entries == null) {
				entries = new ArrayList<ReceiverRecord>(1);
				mActions.put(action, entries);
			}
			entries.add(entry);
		}
	}
}
 
Example 10
Source File: LocalBroadcastManager.java    From guideshow with MIT License 5 votes vote down vote up
/**
 * Unregister a previously registered BroadcastReceiver.  <em>All</em>
 * filters that have been registered for this BroadcastReceiver will be
 * removed.
 *
 * @param receiver The BroadcastReceiver to unregister.
 *
 * @see #registerReceiver
 */
public void unregisterReceiver(BroadcastReceiver receiver) {
    synchronized (mReceivers) {
        ArrayList<IntentFilter> filters = mReceivers.remove(receiver);
        if (filters == null) {
            return;
        }
        for (int i=0; i<filters.size(); i++) {
            IntentFilter filter = filters.get(i);
            for (int j=0; j<filter.countActions(); j++) {
                String action = filter.getAction(j);
                ArrayList<ReceiverRecord> receivers = mActions.get(action);
                if (receivers != null) {
                    for (int k=0; k<receivers.size(); k++) {
                        if (receivers.get(k).receiver == receiver) {
                            receivers.remove(k);
                            k--;
                        }
                    }
                    if (receivers.size() <= 0) {
                        mActions.remove(action);
                    }
                }
            }
        }
    }
}
 
Example 11
Source File: LocalBroadcastManager.java    From letv with Apache License 2.0 5 votes vote down vote up
public void unregisterReceiver(BroadcastReceiver receiver) {
    synchronized (this.mReceivers) {
        ArrayList<IntentFilter> filters = (ArrayList) this.mReceivers.remove(receiver);
        if (filters == null) {
            return;
        }
        for (int i = 0; i < filters.size(); i++) {
            IntentFilter filter = (IntentFilter) filters.get(i);
            for (int j = 0; j < filter.countActions(); j++) {
                String action = filter.getAction(j);
                ArrayList<ReceiverRecord> receivers = (ArrayList) this.mActions.get(action);
                if (receivers != null) {
                    int k = 0;
                    while (k < receivers.size()) {
                        if (((ReceiverRecord) receivers.get(k)).receiver == receiver) {
                            receivers.remove(k);
                            k--;
                        }
                        k++;
                    }
                    if (receivers.size() <= 0) {
                        this.mActions.remove(action);
                    }
                }
            }
        }
    }
}
 
Example 12
Source File: LocalBroadcastManager.java    From android-sdk with MIT License 5 votes vote down vote up
/**
 * Unregister a previously registered BroadcastReceiver.  <em>All</em>
 * filters that have been registered for this BroadcastReceiver will be
 * removed.
 *
 * @param receiver The BroadcastReceiver to unregister.
 * @see #registerReceiver
 */
public void unregisterReceiver(BroadcastReceiver receiver) {
    synchronized (mReceivers) {
        ArrayList<IntentFilter> filters = mReceivers.remove(receiver);
        if (filters == null) {
            return;
        }
        for (int i = 0; i < filters.size(); i++) {
            IntentFilter filter = filters.get(i);
            for (int j = 0; j < filter.countActions(); j++) {
                String action = filter.getAction(j);
                ArrayList<ReceiverRecord> receivers = mActions.get(action);
                if (receivers != null) {
                    for (int k = 0; k < receivers.size(); k++) {
                        if (receivers.get(k).receiver == receiver) {
                            receivers.remove(k);
                            k--;
                        }
                    }
                    if (receivers.size() <= 0) {
                        mActions.remove(action);
                    }
                }
            }
        }
    }
}
 
Example 13
Source File: LocalBroadcastManager.java    From V.FlyoutTest with MIT License 5 votes vote down vote up
/**
 * Unregister a previously registered BroadcastReceiver.  <em>All</em>
 * filters that have been registered for this BroadcastReceiver will be
 * removed.
 *
 * @param receiver The BroadcastReceiver to unregister.
 *
 * @see #registerReceiver
 */
public void unregisterReceiver(BroadcastReceiver receiver) {
    synchronized (mReceivers) {
        ArrayList<IntentFilter> filters = mReceivers.remove(receiver);
        if (filters == null) {
            return;
        }
        for (int i=0; i<filters.size(); i++) {
            IntentFilter filter = filters.get(i);
            for (int j=0; j<filter.countActions(); j++) {
                String action = filter.getAction(j);
                ArrayList<ReceiverRecord> receivers = mActions.get(action);
                if (receivers != null) {
                    for (int k=0; k<receivers.size(); k++) {
                        if (receivers.get(k).receiver == receiver) {
                            receivers.remove(k);
                            k--;
                        }
                    }
                    if (receivers.size() <= 0) {
                        mActions.remove(action);
                    }
                }
            }
        }
    }
}
 
Example 14
Source File: LocalBroadcastManager.java    From koala--Android-Plugin-Runtime- with Apache License 2.0 5 votes vote down vote up
/**
 * Unregister a previously registered BroadcastReceiver. <em>All</em>
 * filters that have been registered for this BroadcastReceiver will be
 * removed.
 * 
 * @param receiver
 *            The BroadcastReceiver to unregister.
 * 
 * @see #registerReceiver
 */
public void unregisterReceiver(BroadcastReceiver receiver) {
	synchronized (mReceivers) {
		ArrayList<IntentFilter> filters = mReceivers.remove(receiver);
		if (filters == null) {
			return;
		}
		for (int i = 0; i < filters.size(); i++) {
			IntentFilter filter = filters.get(i);
			for (int j = 0; j < filter.countActions(); j++) {
				String action = filter.getAction(j);
				ArrayList<ReceiverRecord> receivers = mActions.get(action);
				if (receivers != null) {
					for (int k = 0; k < receivers.size(); k++) {
						if (receivers.get(k).receiver == receiver) {
							receivers.remove(k);
							k--;
						}
					}
					if (receivers.size() <= 0) {
						mActions.remove(action);
					}
				}
			}
		}
	}
}
 
Example 15
Source File: LocalBroadcastManager.java    From adt-leanback-support with Apache License 2.0 5 votes vote down vote up
/**
 * Unregister a previously registered BroadcastReceiver.  <em>All</em>
 * filters that have been registered for this BroadcastReceiver will be
 * removed.
 *
 * @param receiver The BroadcastReceiver to unregister.
 *
 * @see #registerReceiver
 */
public void unregisterReceiver(BroadcastReceiver receiver) {
    synchronized (mReceivers) {
        ArrayList<IntentFilter> filters = mReceivers.remove(receiver);
        if (filters == null) {
            return;
        }
        for (int i=0; i<filters.size(); i++) {
            IntentFilter filter = filters.get(i);
            for (int j=0; j<filter.countActions(); j++) {
                String action = filter.getAction(j);
                ArrayList<ReceiverRecord> receivers = mActions.get(action);
                if (receivers != null) {
                    for (int k=0; k<receivers.size(); k++) {
                        if (receivers.get(k).receiver == receiver) {
                            receivers.remove(k);
                            k--;
                        }
                    }
                    if (receivers.size() <= 0) {
                        mActions.remove(action);
                    }
                }
            }
        }
    }
}
 
Example 16
Source File: LocalBroadcastManager.java    From CodenameOne with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Unregister a previously registered BroadcastReceiver.  <em>All</em>
 * filters that have been registered for this BroadcastReceiver will be
 * removed.
 *
 * @param receiver The BroadcastReceiver to unregister.
 *
 * @see #registerReceiver
 */
public void unregisterReceiver(BroadcastReceiver receiver) {
    synchronized (mReceivers) {
        ArrayList<IntentFilter> filters = mReceivers.remove(receiver);
        if (filters == null) {
            return;
        }
        for (int i=0; i<filters.size(); i++) {
            IntentFilter filter = filters.get(i);
            for (int j=0; j<filter.countActions(); j++) {
                String action = filter.getAction(j);
                ArrayList<ReceiverRecord> receivers = mActions.get(action);
                if (receivers != null) {
                    for (int k=0; k<receivers.size(); k++) {
                        if (receivers.get(k).receiver == receiver) {
                            receivers.remove(k);
                            k--;
                        }
                    }
                    if (receivers.size() <= 0) {
                        mActions.remove(action);
                    }
                }
            }
        }
    }
}
 
Example 17
Source File: LocalBroadcastManager.java    From Dashchan with Apache License 2.0 5 votes vote down vote up
/**
 * Unregister a previously registered BroadcastReceiver. <em>All</em> filters that have been registered for this
 * BroadcastReceiver will be removed.
 *
 * @param receiver
 *            The BroadcastReceiver to unregister.
 *
 * @see #registerReceiver
 */
public void unregisterReceiver(BroadcastReceiver receiver) {
	synchronized (mReceivers) {
		ArrayList<IntentFilter> filters = mReceivers.remove(receiver);
		if (filters == null) {
			return;
		}
		for (int i = 0; i < filters.size(); i++) {
			IntentFilter filter = filters.get(i);
			for (int j = 0; j < filter.countActions(); j++) {
				String action = filter.getAction(j);
				ArrayList<ReceiverRecord> receivers = mActions.get(action);
				if (receivers != null) {
					for (int k = 0; k < receivers.size(); k++) {
						if (receivers.get(k).receiver == receiver) {
							receivers.remove(k);
							k--;
						}
					}
					if (receivers.size() <= 0) {
						mActions.remove(action);
					}
				}
			}
		}
	}
}
 
Example 18
Source File: LocalBroadcastManager.java    From iMoney with Apache License 2.0 5 votes vote down vote up
public void unregisterReceiver(BroadcastReceiver receiver) {
    HashMap var2 = this.mReceivers;
    synchronized (this.mReceivers) {
        ArrayList filters = (ArrayList) this.mReceivers.remove(receiver);
        if (filters != null) {
            for (int i = 0; i < filters.size(); ++i) {
                IntentFilter filter = (IntentFilter) filters.get(i);

                for (int j = 0; j < filter.countActions(); ++j) {
                    String action = filter.getAction(j);
                    ArrayList receivers = (ArrayList) this.mActions.get(action);
                    if (receivers != null) {
                        for (int k = 0; k < receivers.size(); ++k) {
                            if (((LocalBroadcastManager.ReceiverRecord) receivers.get(k)).receiver == receiver) {
                                receivers.remove(k);
                                --k;
                            }
                        }

                        if (receivers.size() <= 0) {
                            this.mActions.remove(action);
                        }
                    }
                }
            }

        }
    }
}
 
Example 19
Source File: PluginLocalBroadcastManager.java    From springreplugin with Apache License 2.0 5 votes vote down vote up
/**
 * Unregister a previously registered BroadcastReceiver.  <em>All</em>
 * filters that have been registered for this BroadcastReceiver will be
 * removed.
 *
 * @param receiver The BroadcastReceiver to unregister.
 *
 * @see #registerReceiver
 */
public void unregisterReceiver(BroadcastReceiver receiver) {
    if (RePluginFramework.mHostInitialized) {
        try {
            ProxyLocalBroadcastManagerVar.unregisterReceiver.call(sOrigInstance, receiver);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return;
    }
    synchronized (mReceivers) {
        ArrayList<IntentFilter> filters = mReceivers.remove(receiver);
        if (filters == null) {
            return;
        }
        for (int i=0; i<filters.size(); i++) {
            IntentFilter filter = filters.get(i);
            for (int j=0; j<filter.countActions(); j++) {
                String action = filter.getAction(j);
                ArrayList<ReceiverRecord> receivers = mActions.get(action);
                if (receivers != null) {
                    for (int k=0; k<receivers.size(); k++) {
                        if (receivers.get(k).receiver == receiver) {
                            receivers.remove(k);
                            k--;
                        }
                    }
                    if (receivers.size() <= 0) {
                        mActions.remove(action);
                    }
                }
            }
        }
    }
}
 
Example 20
Source File: PluginLocalBroadcastManager.java    From springreplugin with Apache License 2.0 5 votes vote down vote up
/**
 * Register a receive for any local broadcasts that match the given IntentFilter.
 *
 * @param receiver The BroadcastReceiver to handle the broadcast.
 * @param filter Selects the Intent broadcasts to be received.
 *
 * @see #unregisterReceiver
 */
public void registerReceiver(BroadcastReceiver receiver, IntentFilter filter) {
    if (RePluginFramework.mHostInitialized) {
        try {
            ProxyLocalBroadcastManagerVar.registerReceiver.call(sOrigInstance, receiver, filter);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return;
    }
    synchronized (mReceivers) {
        ReceiverRecord entry = new ReceiverRecord(filter, receiver);
        ArrayList<IntentFilter> filters = mReceivers.get(receiver);
        if (filters == null) {
            filters = new ArrayList<IntentFilter>(1);
            mReceivers.put(receiver, filters);
        }
        filters.add(filter);
        for (int i=0; i<filter.countActions(); i++) {
            String action = filter.getAction(i);
            ArrayList<ReceiverRecord> entries = mActions.get(action);
            if (entries == null) {
                entries = new ArrayList<ReceiverRecord>(1);
                mActions.put(action, entries);
            }
            entries.add(entry);
        }
    }
}