use of android.content.IntentFilter in project android_frameworks_base by ParanoidAndroid.
the class MobileDataStateTracker method startMonitoring.
/**
* Begin monitoring data connectivity.
*
* @param context is the current Android context
* @param target is the Hander to which to return the events.
*/
public void startMonitoring(Context context, Handler target) {
mTarget = target;
mContext = context;
mHandler = new MdstHandler(target.getLooper(), this);
IntentFilter filter = new IntentFilter();
filter.addAction(TelephonyIntents.ACTION_ANY_DATA_CONNECTION_STATE_CHANGED);
filter.addAction(TelephonyIntents.ACTION_DATA_CONNECTION_CONNECTED_TO_PROVISIONING_APN);
filter.addAction(TelephonyIntents.ACTION_DATA_CONNECTION_FAILED);
mContext.registerReceiver(new MobileDataStateReceiver(), filter);
mMobileDataState = PhoneConstants.DataState.DISCONNECTED;
}
use of android.content.IntentFilter in project android_frameworks_base by ParanoidAndroid.
the class AnalogClock method onAttachedToWindow.
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
if (!mAttached) {
mAttached = true;
IntentFilter filter = new IntentFilter();
filter.addAction(Intent.ACTION_TIME_TICK);
filter.addAction(Intent.ACTION_TIME_CHANGED);
filter.addAction(Intent.ACTION_TIMEZONE_CHANGED);
getContext().registerReceiver(mIntentReceiver, filter, null, mHandler);
}
// NOTE: It's safe to do these after registering the receiver since the receiver always runs
// in the main thread, therefore the receiver can't run before this method returns.
// The time zone may have changed while the receiver wasn't registered, so update the Time
mCalendar = new Time();
// Make sure we update to the current time
onTimeChanged();
}
use of android.content.IntentFilter in project android_frameworks_base by ParanoidAndroid.
the class ExternalMediaFormatActivity method onResume.
@Override
protected void onResume() {
super.onResume();
IntentFilter filter = new IntentFilter();
filter.addAction(Intent.ACTION_MEDIA_REMOVED);
filter.addAction(Intent.ACTION_MEDIA_CHECKING);
filter.addAction(Intent.ACTION_MEDIA_MOUNTED);
filter.addAction(Intent.ACTION_MEDIA_SHARED);
registerReceiver(mStorageReceiver, filter);
}
use of android.content.IntentFilter in project android_frameworks_base by ParanoidAndroid.
the class ResolverActivity method onIntentSelected.
protected void onIntentSelected(ResolveInfo ri, Intent intent, boolean alwaysCheck) {
if (alwaysCheck) {
// Build a reasonable intent filter, based on what matched.
IntentFilter filter = new IntentFilter();
if (intent.getAction() != null) {
filter.addAction(intent.getAction());
}
Set<String> categories = intent.getCategories();
if (categories != null) {
for (String cat : categories) {
filter.addCategory(cat);
}
}
filter.addCategory(Intent.CATEGORY_DEFAULT);
int cat = ri.match & IntentFilter.MATCH_CATEGORY_MASK;
Uri data = intent.getData();
if (cat == IntentFilter.MATCH_CATEGORY_TYPE) {
String mimeType = intent.resolveType(this);
if (mimeType != null) {
try {
filter.addDataType(mimeType);
} catch (IntentFilter.MalformedMimeTypeException e) {
Log.w("ResolverActivity", e);
filter = null;
}
}
}
if (data != null && data.getScheme() != null) {
// or "content:" schemes (see IntentFilter for the reason).
if (cat != IntentFilter.MATCH_CATEGORY_TYPE || (!"file".equals(data.getScheme()) && !"content".equals(data.getScheme()))) {
filter.addDataScheme(data.getScheme());
// Look through the resolved filter to determine which part
// of it matched the original Intent.
Iterator<IntentFilter.AuthorityEntry> aIt = ri.filter.authoritiesIterator();
if (aIt != null) {
while (aIt.hasNext()) {
IntentFilter.AuthorityEntry a = aIt.next();
if (a.match(data) >= 0) {
int port = a.getPort();
filter.addDataAuthority(a.getHost(), port >= 0 ? Integer.toString(port) : null);
break;
}
}
}
Iterator<PatternMatcher> pIt = ri.filter.pathsIterator();
if (pIt != null) {
String path = data.getPath();
while (path != null && pIt.hasNext()) {
PatternMatcher p = pIt.next();
if (p.match(path)) {
filter.addDataPath(p.getPath(), p.getType());
break;
}
}
}
}
}
if (filter != null) {
final int N = mAdapter.mList.size();
ComponentName[] set = new ComponentName[N];
int bestMatch = 0;
for (int i = 0; i < N; i++) {
ResolveInfo r = mAdapter.mList.get(i).ri;
set[i] = new ComponentName(r.activityInfo.packageName, r.activityInfo.name);
if (r.match > bestMatch)
bestMatch = r.match;
}
getPackageManager().addPreferredActivity(filter, bestMatch, set, intent.getComponent());
}
}
if (intent != null) {
startActivity(intent);
}
}
use of android.content.IntentFilter in project android_frameworks_base by ParanoidAndroid.
the class ThemeUtils method registerThemeChangeReceiver.
public static void registerThemeChangeReceiver(final Context context, final BroadcastReceiver receiver) {
IntentFilter filter = new IntentFilter(ACTION_TMOBILE_THEME_CHANGED);
try {
filter.addDataType(DATA_TYPE_TMOBILE_THEME);
filter.addDataType(DATA_TYPE_TMOBILE_STYLE);
} catch (IntentFilter.MalformedMimeTypeException e) {
Log.e(TAG, "Could not add MIME types to filter", e);
}
context.registerReceiver(receiver, filter);
}
Aggregations