Java 类android.content.IntentFilter 实例源码
项目:CRT
文件:MainActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
s = new Setting();
Language = s.getLang();
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
Language = preferences.getString("l",Language);
setLanguage(Language);
setContentView(R.layout.activity_main);
BottomNavigationView navigation = findViewById(R.id.navigation);
navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener);
fm=getSupportFragmentManager();
fm.beginTransaction().add(R.id.content,new BlankFragment()).commit();
Intent i = new Intent(this,SocketService.class);
bindService(i,myConnection,Context.BIND_AUTO_CREATE);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
Log.e("Brodcast","Broadcast intent onCreate invoked");
if(savedInstanceState == null){
if(!registred){
LocalBroadcastManager.getInstance(this).registerReceiver(mMessageReceiver,
new IntentFilter("my-event"));
Log.e("Registre","Broadcast intent register");
registred = true;
}}
}
项目:Android_Sunshine_Watch
文件:MyWatchFace.java
private void registerReceiver() {
if (mRegisteredTimeZoneReceiver) {
return;
}
mRegisteredTimeZoneReceiver = true;
IntentFilter filter = new IntentFilter(Intent.ACTION_TIMEZONE_CHANGED);
MyWatchFace.this.registerReceiver(mTimeZoneReceiver, filter);
}
项目:NoticeDog
文件:AppMonitor.java
public void start(Context context, List<App> appsToMonitor) {
this.context = context;
this.appsToMonitor = appsToMonitor;
this.lastSeenRunningApps = new ArrayList();
IntentFilter filter = new IntentFilter();
filter.addAction("android.intent.action.SCREEN_OFF");
filter.addAction("android.intent.action.SCREEN_ON");
filter.addAction(ACTION_MONITOR_APPS);
this.receiver = new AppMonitorReceiver();
context.registerReceiver(this.receiver, filter);
if (((PowerManager) context.getSystemService("power")).isScreenOn()) {
startMonitoring();
}
}
项目:pass_the_bomb
文件:BluetoothServices.java
/**
* Starts bluetooth and listens to pairing requests and bluetooth state changes
*/
public static void startBluetoothServices() {
mReceiver = new BluetoothReceiver();
//Register the BroadcastReceiver for multiple bluetooth actions
//when another bluetooth device is discovered in range
IntentFilter filter = new IntentFilter(BluetoothDevice.ACTION_FOUND);
//when discovering action finishes (discovering means that bluetooth searches for nearby devices)
filter.addAction(BluetoothAdapter.ACTION_DISCOVERY_FINISHED);
//when bluetooth changes from on to off
filter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED);
//when another device requests pairing with this device
filter.addAction(BluetoothDevice.ACTION_PAIRING_REQUEST);
mainActivity.mainRegisterReceiver(mReceiver, filter);
if(!started) {
//tries to start bluetooth if it is not on
mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
if(mBluetoothAdapter!=null){
if (!mBluetoothAdapter.isEnabled()) {
Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
mainActivity.startActivityForResult(enableBtIntent, MainActivity.BLUETOOTH_ON);
} else {
started = true;
}
}
}
}
项目:sample-usbenum
文件:UsbActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_usb);
mStatusView = (TextView) findViewById(R.id.text_status);
mResultView = (TextView) findViewById(R.id.text_result);
mUsbManager = getSystemService(UsbManager.class);
// Detach events are sent as a system-wide broadcast
IntentFilter filter = new IntentFilter(UsbManager.ACTION_USB_DEVICE_DETACHED);
registerReceiver(mUsbReceiver, filter);
handleIntent(getIntent());
}
项目:MVP-Android
文件:SplashPresenter.java
void requestPushToken(Activity activity){
if (activity!=null) {
Intent service = new Intent(activity, RegistrationIntentService.class);
service.putExtra(RegistrationIntentService.TOKEN, "token");
activity.startService(service);
IntentFilter intentFilter = new IntentFilter(RegistrationIntentService.ACTION_TOKEN);
intentFilter.addCategory(Intent.CATEGORY_DEFAULT);
activity.registerReceiver(tokenBroadcastReceiver, intentFilter);
//send back first
sendBroadCast();
}
else{
}
}
项目:TPlayer
文件:SpecialComponentList.java
public static void protectIntentFilter(IntentFilter filter) {
if (filter != null) {
List<String> actions = mirror.android.content.IntentFilter.mActions.get(filter);
ListIterator<String> iterator = actions.listIterator();
while (iterator.hasNext()) {
String action = iterator.next();
if (SpecialComponentList.isActionInBlackList(action)) {
iterator.remove();
continue;
}
if (SYSTEM_BROADCAST_ACTION.contains(action)) {
continue;
}
String newAction = SpecialComponentList.protectAction(action);
if (newAction != null) {
iterator.set(newAction);
}
}
}
}
项目:GitHub
文件:CustomTabsHelper.java
/**
* Used to check whether there is a specialized handler for a given intent.
* @param intent The intent to check with.
* @return Whether there is a specialized handler for the given intent.
*/
private static boolean hasSpecializedHandlerIntents(Context context, Intent intent) {
try {
PackageManager pm = context.getPackageManager();
List<ResolveInfo> handlers = pm.queryIntentActivities(
intent,
PackageManager.GET_RESOLVED_FILTER);
if (handlers == null || handlers.size() == 0) {
return false;
}
for (ResolveInfo resolveInfo : handlers) {
IntentFilter filter = resolveInfo.filter;
if (filter == null) continue;
if (filter.countDataAuthorities() == 0 || filter.countDataPaths() == 0) continue;
if (resolveInfo.activityInfo == null) continue;
return true;
}
} catch (RuntimeException e) {
Log.e(TAG, "Runtime exception while getting specialized handlers");
}
return false;
}
项目:AutoScrollr
文件:ChromePackageHelper.java
private static boolean hasSpecializedHandlerIntents(Context context, Intent intent) {
try {
PackageManager pm = context.getPackageManager();
List<ResolveInfo> handlers = pm.queryIntentActivities(
intent,
PackageManager.GET_RESOLVED_FILTER);
if (handlers == null || handlers.size() == 0) {
return false;
}
for (ResolveInfo resolveInfo : handlers) {
IntentFilter filter = resolveInfo.filter;
if (filter == null) continue;
if (filter.countDataAuthorities() == 0 || filter.countDataPaths() == 0) continue;
if (resolveInfo.activityInfo == null) continue;
return true;
}
} catch (RuntimeException e) {
Log.e("Error", "Runtime exception while getting specialized handlers");
}
return false;
}
项目:GoUbiquitous
文件:DigitalWatchFaceService.java
private void registerReceiver() {
if (mRegisteredTimeZoneReceiver) {
return;
}
mRegisteredTimeZoneReceiver = true;
IntentFilter filter = new IntentFilter(Intent.ACTION_TIMEZONE_CHANGED);
DigitalWatchFaceService.this.registerReceiver(mTimeZoneReceiver, filter);
}
项目:Phoenix-for-VK
文件:AudioPlayerFragment.java
/**
* {@inheritDoc}
*/
@Override
public void onStart() {
super.onStart();
final IntentFilter filter = new IntentFilter();
// Play and pause changes
filter.addAction(MusicPlaybackService.PLAYSTATE_CHANGED);
// Shuffle and repeat changes
filter.addAction(MusicPlaybackService.SHUFFLEMODE_CHANGED);
filter.addAction(MusicPlaybackService.REPEATMODE_CHANGED);
// Track changes
filter.addAction(MusicPlaybackService.META_CHANGED);
// Player prepared
filter.addAction(MusicPlaybackService.PREPARED);
// Update a list, probably the playlist fragment's
filter.addAction(MusicPlaybackService.REFRESH);
getActivity().registerReceiver(mPlaybackStatus, filter);
// Refresh the current time
final long next = refreshCurrentTime();
queueNextRefresh(next);
MusicUtils.notifyForegroundStateChanged(getActivity(), isPlaying());
}
项目:aos-Video
文件:MainFragment.java
public void onCreate(Bundle bundle){
super.onCreate(bundle);
mUpdateReceiver = new BroadcastReceiver(){
@Override
public void onReceive(Context context, Intent intent) {
if(intent!=null&& ArchosMediaIntent.ACTION_VIDEO_SCANNER_SCAN_FINISHED.equals(intent.getAction())) {
getLoaderManager().restartLoader(LOADER_ID_LAST_ADDED, null, MainFragment.this);
Log.d(TAG, "manual reload");
}
}
};
mUpdateFilter = new IntentFilter();
for(String scheme : UriUtils.sIndexableSchemes){
mUpdateFilter.addDataScheme(scheme);
}
mUpdateFilter.addAction(ArchosMediaIntent.ACTION_VIDEO_SCANNER_SCAN_FINISHED);
}
项目:CXJPadProject
文件:KeyBoardPopWindow.java
/** 注册广播接受来自keyboard的车牌号 */
public void registerReceiver() {
// 输入车牌完成后的intent过滤器
IntentFilter finishFilter = new IntentFilter(INPUT_LICENSE_COMPLETE);
receiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String license = intent.getStringExtra(INPUT_LICENSE_KEY);
if (license != null && license.length() > 0) {
if (keyboardUtil != null) {
keyboardUtil.hideKeyboard();
}
KeyBoardPopWindow.this.dismiss();
mListener.setLicense(license);
}
}
};
mContext.registerReceiver(receiver, finishFilter);
}
项目:ArtOfAndroid
文件:MainActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
findViewById(R.id.btn_default).setOnClickListener(this);
findViewById(R.id.btn_custom).setOnClickListener(this);
findViewById(R.id.btn_demo).setOnClickListener(this);
mLlRemoteViewsContainer = (LinearLayout) findViewById(R.id.ll_remote_views);
mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
IntentFilter intentFilter = new IntentFilter(DemoActivity.ACTION_REMOTE_VIEWS);
registerReceiver(mBroadcastReceiver, intentFilter);
}
项目:mobly-bundled-snippets
文件:BluetoothA2dpSnippet.java
@TargetApi(Build.VERSION_CODES.KITKAT)
@RpcMinSdk(Build.VERSION_CODES.KITKAT)
@Rpc(
description =
"Connects to a paired or discovered device with A2DP profile."
+ "If a device has been discovered but not paired, this will pair it."
)
public void btA2dpConnect(String deviceAddress) throws Throwable {
BluetoothDevice device = BluetoothAdapterSnippet.getKnownDeviceByAddress(deviceAddress);
IntentFilter filter = new IntentFilter(BluetoothDevice.ACTION_PAIRING_REQUEST);
mContext.registerReceiver(new PairingBroadcastReceiver(mContext), filter);
Utils.invokeByReflection(sA2dpProfile, "connect", device);
if (!Utils.waitUntil(
() -> sA2dpProfile.getConnectionState(device) == BluetoothA2dp.STATE_CONNECTED,
120)) {
throw new BluetoothA2dpSnippetException(
"Failed to connect to device "
+ device.getName()
+ "|"
+ device.getAddress()
+ " with A2DP profile within 2min.");
}
}
项目:pixelwallpaper
文件:PixelWallpaperService.java
public PixelWallpaperEngine() {
prefs = PreferenceManager.getDefaultSharedPreferences(PixelWallpaperService.this);
Resources res = getResources();
borderDefault = res.getBoolean(R.bool.pref_border_default);
blackWhiteDefault = res.getBoolean(R.bool.pref_black_white_default);
touchmodeDefault = res.getString(R.string.pref_touch_default);
pixelsizeDefault = res.getString(R.string.pref_pixel_default);
framerateDefault = res.getString(R.string.pref_frame_default);
boolean blackWhiteMode = prefs.getBoolean(PreferencesActivity.PREF_BLACK_WHITE, blackWhiteDefault);
border = prefs.getBoolean(PreferencesActivity.PREF_BORDER, borderDefault);
touchmode = Integer.valueOf(prefs.getString(PreferencesActivity.PREF_TOUCH, touchmodeDefault));
pixelsize = Integer.valueOf(prefs.getString(PreferencesActivity.PREF_PIXEL, pixelsizeDefault));
framerate = Integer.valueOf(prefs.getString(PreferencesActivity.PREF_FRAME, framerateDefault));
prefs.registerOnSharedPreferenceChangeListener(this);
IntentFilter filter = new IntentFilter(Intent.ACTION_SHUTDOWN);
shutdownReceiver = new ShutdownReceiver(this);
registerReceiver(shutdownReceiver, filter);
WindowManager wm = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
Display d = wm.getDefaultDisplay();
DisplayMetrics dm = new DisplayMetrics();
d.getMetrics(dm);
height = dm.heightPixels;
width = dm.widthPixels;
pa = new PixelArray(touchmode, blackWhiteMode);
}
项目:weex-3d-map
文件:InactivityTimer.java
public synchronized void onResume() {
if (registered) {
Log.w(TAG, "PowerStatusReceiver was already registered?");
} else {
activity.registerReceiver(powerStatusReceiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
registered = true;
}
onActivity();
}
项目:LQRWeChat-master
文件:BroadcastManager.java
/**
* 添加
*/
public void register(String action, BroadcastReceiver receiver) {
try {
IntentFilter filter = new IntentFilter();
filter.addAction(action);
mContext.registerReceiver(receiver, filter);
mReceiverMap.put(action, receiver);
} catch (Exception e) {
e.printStackTrace();
}
}
项目:orgzly-android
文件:ListWidgetProvider.java
@Override
public void onEnabled(Context context) {
IntentFilter filter = new IntentFilter();
filter.addAction(AppIntent.ACTION_UPDATE_LIST_WIDGET);
filter.addAction(AppIntent.ACTION_UPDATE_LAYOUT_LIST_WIDGET);
LocalBroadcastManager.getInstance(context).registerReceiver(this, filter);
scheduleUpdate(context);
}
项目:nat-media-video
文件:VideoActivity.java
@Override
protected void onStart() {
super.onStart();
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(Constant.VIDEO_PAUSE_OPERATE);
intentFilter.addAction(Constant.VIDEO_STOP_OPERATE);
registerReceiver(mReceiver, intentFilter);
}
项目:Swap
文件:FriendsFragment.java
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
rootView = inflater.inflate(R.layout.friends_fragment, container, false);
SharedPreferences prefs=getActivity().getSharedPreferences("user", Context.MODE_PRIVATE);
SharedPreferences.Editor editor=prefs.edit();
username=prefs.getString("username"," ");
localBroadcastManger=LocalBroadcastManager.getInstance(getActivity());
intentFilter=new IntentFilter();
intentFilter.addAction("com.shmily.tjz.swap.LOCAL_SPECIAL");
localReceiver=new LocalReceiver();
localBroadcastManger.registerReceiver(localReceiver,intentFilter);
friends_recy= (RecyclerView) rootView.findViewById(R.id.friends_recy);
swipRefresh= (SwipeRefreshLayout) rootView.findViewById(R.id.swipRefresh);
friends_fragment_load_layout= (LoadingLayout) rootView.findViewById(R.id.friends_fragment_load_layout);
friends_fragment_load_layout.setStatus(LoadingLayout.Loading);
set_username= (TextView) rootView.findViewById(R.id.set_username);
friends_headview= (CircleImageView) rootView.findViewById(R.id.friends_headview);
set_username.setText(username);
headimage_url="http://www.shmilyz.com/headimage/"+username+".jpg";
findnumber();
swipRefresh.setColorSchemeColors(getResources().getColor(R.color.colorPrimary));
swipRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
findnumber();
adapter.notifyDataSetChanged();
swipRefresh.setRefreshing(false);
}
});
return rootView;
}
项目:OkUSB
文件:USB.java
private void register() {
IntentFilter usbFilter = new IntentFilter();
usbFilter.addAction(UsbManager.ACTION_USB_DEVICE_ATTACHED);
usbFilter.addAction(UsbManager.ACTION_USB_DEVICE_DETACHED);
usbFilter.addAction(ACTION_USB_PERMISSION);
Activity activity = ctx.get();
if (activity != null) {
activity.registerReceiver(mUsbPermissionActionReceiver, usbFilter);
}
}
项目:treasure
文件:TimeReceiver.java
public void registerReceiver(Context context, TimeListener timeListener) {
try {
IntentFilter filter = new IntentFilter();
filter.addAction(Intent.ACTION_TIME_CHANGED);
filter.addAction(Intent.ACTION_TIME_TICK);
filter.addAction(Intent.ACTION_TIMEZONE_CHANGED);
filter.setPriority(Integer.MAX_VALUE);
context.registerReceiver(this, filter);
this.timeListener = timeListener;
} catch (Exception e) {
e.printStackTrace();
}
}
项目:okwallet
文件:PeerListFragment.java
@Override
protected void onStartLoading() {
super.onStartLoading();
broadcastManager.registerReceiver(broadcastReceiver, new IntentFilter(BlockchainService.ACTION_PEER_STATE));
forceLoad();
}
项目:quickblox-android
文件:ChatPingAlarmManager.java
/**
* Register a pending intent with the AlarmManager to be broadcasted every
* half hour and register the alarm broadcast receiver to receive this
* intent. The receiver will check all known questions if a ping is
* Necessary when invoked by the alarm intent.
*
* @param context
*/
public static void onCreate(Context context) {
sContext = context;
context.registerReceiver(ALARM_BROADCAST_RECEIVER, new IntentFilter(PING_ALARM_ACTION));
sAlarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
sPendingIntent = PendingIntent.getBroadcast(context, 0, new Intent(PING_ALARM_ACTION), 0);
sAlarmManager.setInexactRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,
SystemClock.elapsedRealtime() + PING_INTERVAL,
PING_INTERVAL, sPendingIntent);
}
项目:EarPhoneKeySet
文件:EarPhoneSetService.java
private void registerListener() {
IntentFilter filter = new IntentFilter();
filter.addAction(Intent.ACTION_SCREEN_ON);
filter.addAction(Intent.ACTION_SCREEN_OFF);
filter.addAction("android.media.VOLUME_CHANGED_ACTION");
registerReceiver(mReceiver, filter);
}
项目:SocketListenerSampleApp
文件:MainActivity.java
@Override
protected void onResume() {
super.onResume();
registerReceiver(
receiver,
new IntentFilter(SocketListeningService.MESSAGE_RECEIVED));
}
项目:AstronomyTourPadova
文件:LocationService.java
@Override
public void onCreate() {
Log.d(TAG, "onCreate");
googleApiClient = new GoogleApiClient.Builder(this)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(LocationServices.API)
.build();
googleApiClient.connect();
createLocationRequest("highest");
LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder();
builder.addLocationRequest(locationRequest);
builder.setAlwaysShow(true); // "This app wants to change your device settings for GPS location"
locationSettingsRequest = builder.build();
HandlerThread handlerThread = new HandlerThread(TAG);
handlerThread.start();
handler = new Handler(handlerThread.getLooper());
notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
currentNotificationTitle = getResources().getString(R.string.app_name);
currentNotificationText = getResources().getString(R.string.notification_desc);
// Handling interaction with WiFi
wifiConnected = Utils.isWifiConnected(getApplicationContext());
// Listening to Network changes (WiFi mostly)
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction("android.net.wifi.WIFI_STATUS_CHANGED");
intentFilter.addAction("android.net.wifi.STATUS_CHANGE");
registerReceiver(AtNetworkReceiver, intentFilter);
}
项目:mobile-store
文件:BannerUpdatingRepos.java
private void monitorRepoUpdates() {
if (isInEditMode()) {
return;
}
LocalBroadcastManager.getInstance(getContext()).registerReceiver(onRepoFeedback,
new IntentFilter(UpdateService.LOCAL_ACTION_STATUS));
setBannerIsVisible(UpdateService.isUpdating());
}
项目:BluetoothAPP
文件:BluetoothUtil.java
/**
* 广播拦截
*
* @return IntentFilter
*/
public static IntentFilter makeFilters() {
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED);//开关监听
intentFilter.addAction(BluetoothDevice.ACTION_FOUND);//查询
intentFilter.addAction(BluetoothAdapter.ACTION_DISCOVERY_FINISHED);//查询结束
intentFilter.addAction(BluetoothDevice.ACTION_BOND_STATE_CHANGED);//绑定状况
return intentFilter;
}
项目:igrow-android
文件:EnvironmentalSensorsScanActivity.java
@Override
protected void onResume() {
super.onResume();
IntentFilter filter = new IntentFilter();
filter.addAction(ACTION_SCAN_UPDATE);
registerReceiver(mBroadcastReceiver, filter);
}
项目:Pc-Control
文件:BluetoothDevicesActivity.java
protected void onResume()
{
super.onResume();
this.registerReceiver(this.broadcastReceiver, new IntentFilter(BluetoothAdapter.ACTION_DISCOVERY_STARTED));
this.registerReceiver(this.broadcastReceiver, new IntentFilter(BluetoothAdapter.ACTION_DISCOVERY_FINISHED));
this.registerReceiver(this.broadcastReceiver, new IntentFilter(BluetoothDevice.ACTION_FOUND));
this.bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
if (this.bluetoothAdapter != null)
{
if (this.bluetoothAdapter.isEnabled())
{
Set<BluetoothDevice> deviceSet = this.bluetoothAdapter.getBondedDevices();
this.deviceList.addAll(deviceSet);
this.deviceListAdapter.notifyDataSetChanged();
this.bluetoothAdapter.startDiscovery();
}
else
{
if (this.requestEnableBluetooth)
{
this.startActivity(new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE));
this.requestEnableBluetooth = false;
}
else
{
this.finish();
}
}
}
else
{
Toast.makeText(this, "Bluetooth is not available", Toast.LENGTH_SHORT).show();
}
}
项目:StartThirdApp
文件:HomeWatcher.java
public HomeWatcher(Context context) {
mContext = context;
//当按下Home键时,系统会发出action为Intent.ACTION_CLOSE_SYSTEM_DIALOGS的BroadcastReceiver
mFilter = new IntentFilter(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
}
项目:nightmode
文件:MainActivity.java
@Override
public void onStart() {
super.onStart(); // Call onStart on the superclass
mReceiver = new MessageReceiver(); // Start a new message receiver, if not already started.
IntentFilter filter = new IntentFilter(); // Register it with the IntentFilter
filter.addAction(MainActivity.class.getCanonicalName());
registerReceiver(mReceiver, filter);
}
项目:Khonsu
文件:MapNavActivity.java
private void regsiterBroadCastReceivers() {
IntentFilter directionFilter = new IntentFilter(SensorService.ANGLE_UPDATE);
IntentFilter stepsFilter = new IntentFilter(SensorService.STEP_UPDATE);
mSensorReceiver = new SensorServiceReceiver(this);
registerReceiver(mSensorReceiver, stepsFilter);
registerReceiver(mSensorReceiver, directionFilter);
}
项目:GitHub
文件:CacheService.java
@Override
public void onCreate() {
super.onCreate();
dbHelper = new DatabaseHelper(this, "History.db", null, 5);
db = dbHelper.getWritableDatabase();
IntentFilter filter = new IntentFilter();
filter.addAction("com.marktony.zhihudaily.LOCAL_BROADCAST");
LocalBroadcastManager manager = LocalBroadcastManager.getInstance(this);
manager.registerReceiver(new LocalReceiver(), filter);
}
项目:QuranAndroid
文件:QuranPageFragment.java
/**
* Function fire when fragment created
*/
@Override
public void onResume() {
super.onResume();
isPauseResume = true;
drawSavedHighlight();
LocalBroadcastManager.getInstance(getActivity()).registerReceiver(ResetImage , new IntentFilter(AppConstants.Highlight.RESET_IMAGE));
}
项目:container
文件:BroadcastSystem.java
private void redirectFilterActions(IntentFilter filter) {
List<String> actions = mirror.android.content.IntentFilter.mActions.get(filter);
ListIterator<String> iterator = actions.listIterator();
while (iterator.hasNext()) {
String action = iterator.next();
if (SpecialComponentList.isActionInBlackList(action)) {
iterator.remove();
continue;
}
String protectedAction = SpecialComponentList.protectAction(action);
if (protectedAction != null) {
iterator.set(protectedAction);
}
}
}
项目:AndroidthingsStudy
文件:ForegroundDispatch.java
@Override
public void onCreate(Bundle savedState) {
super.onCreate(savedState);
setContentView(R.layout.foreground_dispatch);
mText = (TextView) findViewById(R.id.text);
mText.setText("Scan a tag");
mAdapter = NfcAdapter.getDefaultAdapter(this);
// Create a generic PendingIntent that will be deliver to this activity. The NFC stack
// will fill in the intent with the details of the discovered tag before delivering to
// this activity.
mPendingIntent = PendingIntent.getActivity(this, 0,
new Intent(this, getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0);
// Setup an intent filter for all MIME based dispatches
IntentFilter ndef = new IntentFilter(NfcAdapter.ACTION_NDEF_DISCOVERED);
try {
ndef.addDataType("*/*");
} catch (MalformedMimeTypeException e) {
throw new RuntimeException("fail", e);
}
mFilters = new IntentFilter[] {
ndef,
};
// Setup a tech list for all NfcF tags
mTechLists = new String[][] { new String[] { NfcF.class.getName() } };
}
项目:AndroidBookTest
文件:BaseActivity.java
@Override
protected void onResume() {
super.onResume();
IntentFilter intentFilter=new IntentFilter();
intentFilter.addAction("com.example.broadcastbestpractice.FORCE_OFFLINE");
receiver=new ForceOfflineReceiver();
registerReceiver(receiver,intentFilter);
}