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

The following examples show how to use android.content.IntentFilter#getAction() . These examples are extracted from open source projects. 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 Project: Dashchan   File: LocalBroadcastManager.java    License: 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 2
/**
 * 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 3
/**
 * 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 4
/**
 * 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
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 6
/**
 * 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 Project: V.FlyoutTest   File: LocalBroadcastManager.java    License: 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 8
Source Project: android-sdk   File: LocalBroadcastManager.java    License: 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 9
Source Project: guideshow   File: LocalBroadcastManager.java    License: 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 10
Source Project: letv   File: LocalBroadcastManager.java    License: 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 11
/**
 * 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);
        }
    }
}
 
Example 12
/**
 * 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 13
Source Project: iMoney   File: LocalBroadcastManager.java    License: 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 14
Source Project: Dashchan   File: LocalBroadcastManager.java    License: 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
/**
 * 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
/**
 * 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
/**
 * 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 Project: V.FlyoutTest   File: LocalBroadcastManager.java    License: 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 19
Source Project: android-sdk   File: LocalBroadcastManager.java    License: 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 20
Source Project: guideshow   File: LocalBroadcastManager.java    License: 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);
                    }
                }
            }
        }
    }
}