List of usage examples for android.content IntentFilter addAction
public final void addAction(String action)
From source file:com.devalladolid.musictoday.activities.BaseActivity.java
@Override protected void onStart() { super.onStart(); final IntentFilter filter = new IntentFilter(); // Play and pause changes filter.addAction(MusicService.PLAYSTATE_CHANGED); // Track changes filter.addAction(MusicService.META_CHANGED); // Update a list, probably the playlist fragment's filter.addAction(MusicService.REFRESH); // If a playlist has changed, notify us filter.addAction(MusicService.PLAYLIST_CHANGED); // If there is an error playing a track filter.addAction(MusicService.TRACK_ERROR); registerReceiver(mPlaybackStatus, filter); }
From source file:com.customprogrammingsolutions.MediaStreamer.MediaStreamerService.java
@Override public void onCreate() { Log.i(TAG, "MediaStreamerService.onCreate()"); isPlaying = false;//from w w w. j a v a 2 s. c om isRunning = true; IntentFilter inf = new IntentFilter(); inf.addAction(AudioManager.ACTION_AUDIO_BECOMING_NOISY); inf.addAction(MainActivity.PLAYBACK_TIMEOUT_INTENT); registerReceiver(audioTooNoisyReceiver, inf); }
From source file:com.concentricsky.android.khanacademy.app.HomeActivity.java
@Override protected void onStart() { super.onStart(); if (!userHasAcceptedTOS()) { showTOSAcknowledgement();/*from ww w . ja v a 2 s . com*/ } mainMenuDelegate = new MainMenuDelegate(this); requestDataService(new ObjectCallback<KADataService>() { @Override public void call(KADataService dataService) { topic = dataService.getRootTopic(); if (topic != null) { // It is important to create the AbstractListFragment programmatically here as opposed to // specifying it in the xml layout. If it is specified in xml, we end up with an // error about "Content view not yet created" when clicking a list item after restoring // a fragment from the back stack. setListForTopic(topic, TopicListFragment.class, true); } } }); IntentFilter filter = new IntentFilter(); filter.addAction(ACTION_LIBRARY_UPDATE); filter.addAction(ACTION_BADGE_EARNED); filter.addAction(ACTION_TOAST); LocalBroadcastManager.getInstance(this).registerReceiver(receiver, filter); }
From source file:com.inbeacon.cordova.CordovaInbeaconManager.java
private void initEventListener() { if (broadcastReceiver != null) { // "Already listening, not adding again" return;//from ww w . jav a2 s. c om } broadcastReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { sendUpdate(getEventObject(intent)); } }; // get all notifications from the inBeacon SDK to our broadcastReceiver IntentFilter filter = new IntentFilter(); filter.addAction("com.inbeacon.sdk.event.enterregion"); // user entered a region filter.addAction("com.inbeacon.sdk.event.exitregion"); // user left a region filter.addAction("com.inbeacon.sdk.event.enterlocation"); // user entered a location filter.addAction("com.inbeacon.sdk.event.exitlocation"); // user left a location filter.addAction("com.inbeacon.sdk.event.regionsupdate"); // region definitions were updated filter.addAction("com.inbeacon.sdk.event.enterproximity"); // user entered a beacon proximity filter.addAction("com.inbeacon.sdk.event.exitproximity"); // user left a beacon proximity filter.addAction("com.inbeacon.sdk.event.proximity"); // low level proximity update, once every second when beacons are around filter.addAction("com.inbeacon.sdk.event.appevent"); // defined in the backend for special app-specific pages to show filter.addAction("com.inbeacon.sdk.event.appaction"); // defined in the backend to handle your own local notifications LocalBroadcastManager.getInstance(cordova.getActivity().getApplicationContext()) .registerReceiver(broadcastReceiver, filter); }
From source file:com.farmerbb.taskbar.activity.InvisibleActivityFreeform.java
@SuppressLint("HardwareIds") @TargetApi(Build.VERSION_CODES.N)/*w ww.j a v a 2 s . co m*/ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (FreeformHackHelper.getInstance().isFreeformHackActive()) { proceedWithOnCreate = false; super.finish(); } if (getIntent().hasExtra("check_multiwindow")) { showTaskbar = false; if (!isInMultiWindowMode()) { proceedWithOnCreate = false; super.finish(); } } if (proceedWithOnCreate) { // Detect outside touches, and pass them through to the underlying activity getWindow().setFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL, WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL); getWindow().setFlags(WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH, WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH); IntentFilter appearingReceiverFilter = new IntentFilter(); appearingReceiverFilter.addAction("com.farmerbb.taskbar.START_MENU_APPEARING"); appearingReceiverFilter.addAction("com.farmerbb.taskbar.CONTEXT_MENU_APPEARING"); IntentFilter disappearingReceiverFilter = new IntentFilter(); disappearingReceiverFilter.addAction("com.farmerbb.taskbar.START_MENU_DISAPPEARING"); disappearingReceiverFilter.addAction("com.farmerbb.taskbar.CONTEXT_MENU_DISAPPEARING"); LocalBroadcastManager.getInstance(this).registerReceiver(appearingReceiver, appearingReceiverFilter); LocalBroadcastManager.getInstance(this).registerReceiver(disappearingReceiver, disappearingReceiverFilter); LocalBroadcastManager.getInstance(this).registerReceiver(finishReceiver, new IntentFilter("com.farmerbb.taskbar.FINISH_FREEFORM_ACTIVITY")); FreeformHackHelper helper = FreeformHackHelper.getInstance(); helper.setFreeformHackActive(true); // Show power button warning on CyanogenMod / LineageOS devices if (getPackageManager().hasSystemFeature("com.cyanogenmod.android")) { SharedPreferences pref = U.getSharedPreferences(this); if (!pref.getString("power_button_warning", "null") .equals(Settings.Secure.getString(getContentResolver(), Settings.Secure.ANDROID_ID))) { new Handler().postDelayed(() -> { if (helper.isInFreeformWorkspace()) { Intent intent = null; switch (pref.getString("theme", "light")) { case "light": intent = new Intent(InvisibleActivityFreeform.this, InvisibleActivityAlt.class); break; case "dark": intent = new Intent(InvisibleActivityFreeform.this, InvisibleActivityAltDark.class); break; } if (intent != null) { intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.putExtra("power_button_warning", true); } U.launchAppMaximized(getApplicationContext(), intent); } }, 100); } } showTaskbar = true; } }
From source file:com.auth0.android.lock.PasswordlessLock.java
private void initialize(Activity activity) { IntentFilter filter = new IntentFilter(); filter.addAction(Constants.AUTHENTICATION_ACTION); filter.addAction(Constants.CANCELED_ACTION); filter.addAction(Constants.INVALID_CONFIGURATION_ACTION); LocalBroadcastManager.getInstance(activity).registerReceiver(this.receiver, filter); }
From source file:com.achep.acdisplay.services.BathService.java
@Override public void onCreate() { super.onCreate(); mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); mLanguage = getResources().getConfiguration().locale.getLanguage(); // Listen for the config changes to update notification just // once locale has changed. IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(Intent.ACTION_CONFIGURATION_CHANGED); registerReceiver(mReceiver, intentFilter); synchronized (monitor) { sCreated = true;//from w w w .j a v a 2s .c om // Register for add / remove service events. intentFilter = new IntentFilter(); intentFilter.addAction(ACTION_ADD_SERVICE); intentFilter.addAction(ACTION_REMOVE_SERVICE); mLocalBroadcastManager = LocalBroadcastManager.getInstance(this); mLocalBroadcastManager.registerReceiver(mReceiver, intentFilter); if (sServiceMap.isEmpty()) { stopSelf(); } else { // Init all children Set<Map.Entry<Class, ChildService>> set = sServiceMap.entrySet(); for (Map.Entry<Class, ChildService> entry : set) { ChildService child = entry.getValue(); child.setContext(this); child.onCreate(); mMap.put(entry.getKey(), child); } sServiceMap.clear(); startForeground(App.ID_NOTIFY_BATH, buildNotification()); } } }
From source file:com.alex.vmandroid.services.RecordDBService.java
@Override public void onCreate() { super.onCreate(); //region ???? NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this); Intent intent = new Intent(this, RecordDBActivity.class); //PendingIntent PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, 0); mBuilder.setSmallIcon(R.drawable.vm_android_app_icon).setContentTitle(getString(R.string.app_name)) .setContentText(getString(R.string.record)).setContentIntent(pendingIntent); Notification mNotification = mBuilder.build(); // ? /*from w ww. j a v a 2 s . c om*/ //mNotification.icon = R.drawable.icon_upload_location; //?? mNotification.flags = Notification.FLAG_ONGOING_EVENT;//FLAG_ONGOING_EVENT ?? FLAG_AUTO_CANCEL ?? //???Light mNotification.defaults = Notification.DEFAULT_VIBRATE; //?? mNotification.tickerText = "???"; //? mNotification.when = System.currentTimeMillis(); // ? //mNotification.icon = R.drawable.icon_upload_location; //?? mNotification.flags = Notification.FLAG_ONGOING_EVENT;//FLAG_ONGOING_EVENT ?? FLAG_AUTO_CANCEL ?? //???Light mNotification.defaults = Notification.DEFAULT_VIBRATE; //?? mNotification.tickerText = "???"; //? mNotification.when = System.currentTimeMillis(); //id?? int notifyId = 1001; startForeground(notifyId, mNotification); //endregion //region ? mReceiver = new RecordDBReceiver(); IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(RecordDBService.RecordDBServiceAction); registerReceiver(mReceiver, intentFilter); mReceiver2 = new MessageReceiver(); intentFilter = new IntentFilter(); intentFilter.addAction(RecordDBReceiver.ACTION); registerReceiver(mReceiver2, intentFilter); //endregion //region ?? mLocationClient = new AMapLocationClient(this); //??? AMapLocationClientOption locationOption = new AMapLocationClientOption(); //?? mLocationClient.setLocationListener(this); //???Battery_Saving?Device_Sensors? locationOption.setLocationMode(AMapLocationClientOption.AMapLocationMode.Hight_Accuracy); //?,??,2000ms locationOption.setInterval(2000); //?? mLocationClient.setLocationOption(locationOption); //endregion }
From source file:com.allthatseries.RNAudioPlayer.MediaNotificationManager.java
/** * Posts the notification and starts tracking the session to keep it * updated. The notification will automatically be removed if the session is * destroyed before {@link #stopNotification} is called. */// w w w. j a v a2 s . c om public void startNotification() { if (!mStarted) { mMetadata = mController.getMetadata(); mPlaybackState = mController.getPlaybackState(); // The notification must be updated after setting started to true Notification notification = createNotification(); if (notification != null) { mController.registerCallback(mCb); IntentFilter filter = new IntentFilter(); filter.addAction(ACTION_NEXT); filter.addAction(ACTION_PAUSE); filter.addAction(ACTION_PLAY); filter.addAction(ACTION_PREV); mService.registerReceiver(this, filter); mService.startForeground(NOTIFICATION_ID, notification); mStarted = true; } } }
From source file:com.aware.ESM.java
@Override public void onCreate() { super.onCreate(); TAG = Aware.getSetting(getApplicationContext(), Aware_Preferences.DEBUG_TAG).length() > 0 ? Aware.getSetting(getApplicationContext(), Aware_Preferences.DEBUG_TAG) : TAG;/*from w w w .j av a 2 s. com*/ DATABASE_TABLES = ESM_Provider.DATABASE_TABLES; TABLES_FIELDS = ESM_Provider.TABLES_FIELDS; CONTEXT_URIS = new Uri[] { ESM_Data.CONTENT_URI }; IntentFilter filter = new IntentFilter(); filter.addAction(ESM.ACTION_AWARE_QUEUE_ESM); registerReceiver(esmMonitor, filter); intent_ESM = new Intent(this, ESM_Queue.class); intent_ESM.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); pending_ESM = PendingIntent.getActivity(this, 0, intent_ESM, PendingIntent.FLAG_UPDATE_CURRENT); if (Aware.DEBUG) Log.d(TAG, "ESM service created!"); }