Java Code Examples for android.content.Intent#getAction()
The following examples show how to use
android.content.Intent#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: IntentUtils.java From Neptune with Apache License 2.0 | 6 votes |
/** * 重置恢复Intent中的Action */ public static void resetAction(Intent intent) { if (intent == null) { return; } String action = intent.getAction(); if (!TextUtils.isEmpty(action) && action.contains(TOKEN)) { String[] info = action.split(TOKEN); if (info != null && info.length == 2) { action = info[1]; } } PluginDebugLog.log(TAG, "resetAction: " + action); if (TextUtils.isEmpty(action) || action.equalsIgnoreCase("null")) { action = null; } intent.setAction(action); }
Example 2
Source File: WifiNetworkActivity.java From WiFiKeyShare with GNU General Public License v3.0 | 6 votes |
void initializeNfcStateChangeListener() { nfcStateChangeBroadcastReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { final String action = intent.getAction(); if (action.equals(NfcAdapter.ACTION_ADAPTER_STATE_CHANGED)) { final int state = intent.getIntExtra(NfcAdapter.EXTRA_ADAPTER_STATE, NfcAdapter.STATE_OFF); switch (state) { case NfcAdapter.STATE_OFF: case NfcAdapter.STATE_TURNING_OFF: onNfcDisabled(); break; case NfcAdapter.STATE_TURNING_ON: break; case NfcAdapter.STATE_ON: onNfcEnabled(); break; } } } }; }
Example 3
Source File: AlarmReceiver.java From Muslim-Athkar-Islamic-Reminders with MIT License | 6 votes |
@Override public void onReceive(Context context, Intent intent) { // TODO Auto-generated method stub context = LocaleManager.setLocale(context); this.context = context; savedData = new SavedData(context); myDatabase = new MyDatabase(context); hijriSpecialDay = new HijriSpecialDays(); if (intent.getAction() != null && context != null) { if (intent.getAction().equalsIgnoreCase(Intent.ACTION_BOOT_COMPLETED)) { // Set the alarm here. Log.d(TAG, "onReceive: BOOT_COMPLETED"); SavedData savedData = new SavedData(context); NotificationScheduler.setReminder(context, AlarmReceiver.class, savedData.getAppStartHour(), savedData.getAppStartMin(),savedData.getNewRemainderInterval()); return; } } NotificationScheduler.showNotification(context, MainActivity.class, context.getString(R.string.app_sub_name), getAtkhar()); }
Example 4
Source File: BookmarkWidgetProvider.java From 365browser with Apache License 2.0 | 6 votes |
@Override public void onReceive(Context context, Intent intent) { // Handle bookmark-specific updates ourselves because they might be // coming in without extras, which AppWidgetProvider then blocks. final String action = intent.getAction(); if (getBookmarkAppWidgetUpdateAction(context).equals(action)) { AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context); if (intent.hasExtra(AppWidgetManager.EXTRA_APPWIDGET_ID)) { performUpdate(context, appWidgetManager, new int[] {IntentUtils.safeGetIntExtra(intent, AppWidgetManager.EXTRA_APPWIDGET_ID, -1)}); } else { performUpdate(context, appWidgetManager, appWidgetManager.getAppWidgetIds(getComponentName(context))); } } else { super.onReceive(context, intent); } }
Example 5
Source File: LinkingBeaconManager.java From DeviceConnect-Android with MIT License | 6 votes |
public void onReceivedBeacon(final Intent intent) { if (BuildConfig.DEBUG) { Log.i(TAG, "@@ LinkingBeaconManager#onReceivedBeacon"); Log.i(TAG, "intent=" + intent); } if (intent == null) { return; } String action = intent.getAction(); if (LinkingBeaconUtil.ACTION_BEACON_SCAN_RESULT.equals(action)) { parseBeaconResult(intent); } else if (LinkingBeaconUtil.ACTION_BEACON_SCAN_STATE.equals(action)) { parseBeaconScanState(intent); } }
Example 6
Source File: VideoPlayerActivity.java From VCL-Android with Apache License 2.0 | 6 votes |
@Override public void onReceive(Context context, Intent intent) { String action = intent.getAction(); if (action.equalsIgnoreCase(Intent.ACTION_BATTERY_CHANGED)) { if (mBattery == null) return; int batteryLevel = intent.getIntExtra("level", 0); if (batteryLevel >= 50) mBattery.setTextColor(Color.GREEN); else if (batteryLevel >= 30) mBattery.setTextColor(Color.YELLOW); else mBattery.setTextColor(Color.RED); mBattery.setText(String.format("%d%%", batteryLevel)); } else if (action.equalsIgnoreCase(VLCApplication.SLEEP_INTENT)) { exitOK(); } }
Example 7
Source File: OnboardingActivity.java From zom-android-matrix with Apache License 2.0 | 6 votes |
/** * Get the URI of the selected image from {@link #getPickImageChooserIntent()}.<br/> * Will return the correct URI for camera and gallery image. * * @param data the returned data of the activity result */ public Uri getPickImageResultUri(Intent data) { boolean isCamera = true; if (data != null) { if (data.getData() == null) return getCaptureImageOutputUri(); else { String action = data.getAction(); isCamera = action != null && action.equals(MediaStore.ACTION_IMAGE_CAPTURE); return isCamera ? getCaptureImageOutputUri() : data.getData(); } } else return getCaptureImageOutputUri(); }
Example 8
Source File: MiBandService.java From Mi-Band with GNU General Public License v2.0 | 6 votes |
@Override public int onStartCommand(Intent intent, int flags, int startId) { if (intent == null) { Log.i(TAG, "no intent"); return START_NOT_STICKY; } String action = intent.getAction(); if (action == null) { Log.i(TAG, "no action"); return START_NOT_STICKY; } Bundle b = intent.getExtras(); if (b != null) { if (b.getBoolean("service", false)) { stopSelf(); } } connectMiBand(); return START_STICKY; }
Example 9
Source File: AbsMusicServiceActivity.java From Orin with GNU General Public License v3.0 | 5 votes |
@Override public void onReceive(final Context context, @NonNull final Intent intent) { final String action = intent.getAction(); AbsMusicServiceActivity activity = reference.get(); if (activity != null) { switch (action) { case MusicService.META_CHANGED: activity.onPlayingMetaChanged(); break; case MusicService.QUEUE_CHANGED: activity.onQueueChanged(); break; case MusicService.PLAY_STATE_CHANGED: activity.onPlayStateChanged(); break; case MusicService.REPEAT_MODE_CHANGED: activity.onRepeatModeChanged(); break; case MusicService.SHUFFLE_MODE_CHANGED: activity.onShuffleModeChanged(); break; case MusicService.MEDIA_STORE_CHANGED: activity.onMediaStoreChanged(); break; } } }
Example 10
Source File: GalleryActivity.java From EhViewer with Apache License 2.0 | 5 votes |
private void onInit() { Intent intent = getIntent(); if (intent == null) { return; } mAction = intent.getAction(); mFilename = intent.getStringExtra(KEY_FILENAME); mUri = intent.getData(); mGalleryInfo = intent.getParcelableExtra(KEY_GALLERY_INFO); mPage = intent.getIntExtra(KEY_PAGE, -1); buildProvider(); }
Example 11
Source File: PlayerService.java From Pocket-Plays-for-Twitch with GNU General Public License v3.0 | 5 votes |
private void handleIntent( Intent intent ) { if( intent == null || intent.getAction() == null || mCallbacks == null) { return; } String action = intent.getAction(); if( action.equalsIgnoreCase( ACTION_PLAY ) ) { mCallbacks.onPlay(); } else if( action.equalsIgnoreCase( ACTION_PAUSE ) ) { mCallbacks.onPause(); } else if( action.equalsIgnoreCase( ACTION_FORWARD) ) { mCallbacks.onFastForward(); } else if( action.equalsIgnoreCase( ACTION_REWIND ) ) { mCallbacks.onRewind(); } else if( action.equalsIgnoreCase( ACTION_PREVIOUS ) ) { mCallbacks.onSkipToPrevious(); } else if( action.equalsIgnoreCase( ACTION_NEXT ) ) { mCallbacks.onSkipToNext(); } else if( action.equalsIgnoreCase( ACTION_STOP ) ) { mCallbacks.onStop(); } else if( action.equalsIgnoreCase( ACTION_SEEK ) && intent.hasExtra( VOD_PROGRESS ) ) { if (mp != null && mediaSession.isActive()) { mp.seekTo(intent.getIntExtra( VOD_PROGRESS, 0 )); } } }
Example 12
Source File: HeartRateDeviceSettingsFragment.java From DeviceConnect-Android with MIT License | 5 votes |
@Override public void onReceive(Context context, Intent intent) { String action = intent.getAction(); if (BluetoothAdapter.ACTION_STATE_CHANGED.equals(action)) { int state = intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, -1); if (state == BluetoothAdapter.STATE_ON ){ addFooterView(); getManager().startScanBle(); } else if (state == BluetoothAdapter.STATE_OFF) { addFooterView(); getManager().stopScanBle(); } } }
Example 13
Source File: BroadcastIntent.java From container with GNU General Public License v3.0 | 5 votes |
@Override public Object call(Object who, Method method, Object... args) throws Throwable { Intent intent = (Intent) args[1]; String type = (String) args[2]; intent.setDataAndType(redirectData(intent.getData()), type); if (intent.getAction() != null && intent.getAction().equals(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE) && intent.getData() != null) { ContentValues values = new ContentValues(2); String mime = MimeTypeMap.getSingleton().getMimeTypeFromExtension(MimeTypeMap.getFileExtensionFromUrl(intent.getDataString())); values.put("mime_type", mime); values.put("_data", intent.getData().getPath()); VLog.d(getName(), "try " + values); if (mime.startsWith("image")) VirtualCore.get().getContext().getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values); else if (mime.startsWith("video")) VirtualCore.get().getContext().getContentResolver().insert(MediaStore.Video.Media.EXTERNAL_CONTENT_URI, values); else if (mime.startsWith("audio")) VirtualCore.get().getContext().getContentResolver().insert(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, values); } if (VirtualCore.get().getComponentDelegate() != null) { if (!VirtualCore.get().getComponentDelegate().onSendBroadcast(intent)) return null; } Intent newIntent = handleIntent(intent); if (newIntent != null) { args[1] = newIntent; } else { return 0; } if (args[7] instanceof String || args[7] instanceof String[]) { // clear the permission args[7] = null; } VLog.d(getName(), "broadcast " + intent); return method.invoke(who, args); }
Example 14
Source File: NewsFragment.java From YuanNewsForAndroid with Apache License 2.0 | 5 votes |
@Override public void onReceive(Context context, Intent intent) { String action=intent.getAction(); if(NEWSFRAGMENT_TYPE_ACTION.equals(action)){ type=intent.getIntExtra(NEWSFRAGMENT_TYPE_ACTION,2); refresh(); } }
Example 15
Source File: PersistReceiver.java From Trigger with Apache License 2.0 | 5 votes |
@Override public void onReceive(Context context, Intent intent) { String action = intent.getAction(); switch (action) { case Trigger.DEBUG_DEVICE_ON_B: if (!Trigger.DEBUG) break; case Intent.ACTION_BOOT_COMPLETED: context.startService(TriggerLoop.deviceOn(context)); break; default: break; } }
Example 16
Source File: BootReceiver.java From talkback with Apache License 2.0 | 5 votes |
@Override public void onReceive(Context context, Intent intent) { TalkBackService service = TalkBackService.getInstance(); if (service == null) { return; } EventId eventId = EVENT_ID_UNTRACKED; // Not a user-initiated event. // We need to ensure that onLockedBootCompleted() and onUnlockedBootCompleted() are called // *in that order* to properly set up TalkBack. switch (intent.getAction()) { case Intent.ACTION_LOCKED_BOOT_COMPLETED: // Only N+ devices will get this intent (even if they don't have FBE enabled). service.onLockedBootCompleted(eventId); break; case Intent.ACTION_BOOT_COMPLETED: if (!BuildVersionUtils.isAtLeastN()) { // Pre-N devices will never get LOCKED_BOOT, so we need to do the locked-boot // initialization here right before we do the unlocked-boot initialization. service.onLockedBootCompleted(eventId); } service.onUnlockedBootCompleted(); break; default: // fall out } }
Example 17
Source File: CbService.java From PressureNet-SDK with MIT License | 4 votes |
/** * Start running background data collection methods. * */ @Override public int onStartCommand(Intent intent, int flags, int startId) { log("cbservice onstartcommand"); checkBarometer(); loadConditionsNotificationPref(); // wakelock management if(wl!=null) { log("cbservice wakelock not null:"); if(wl.isHeld()) { log("cbservice existing wakelock; releasing"); wl.release(); } else { log("cbservice wakelock not null but no existing lock"); } } PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); wl = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP , "CbService"); // PARTIAL_WAKE_LOCK wl.acquire(1000); log("cbservice acquiring wakelock " + wl.isHeld()); dataCollector = new CbDataCollector(); try { if (intent != null) { if (intent.getAction() != null) { if (intent.getAction().equals(ACTION_SEND_MEASUREMENT)) { // send just a single measurement fromUser = false; log("sending single observation, request from intent"); sendSingleObs(); return START_NOT_STICKY; } else if (intent.getAction().equals(ACTION_SEND_MEASUREMENT_WITH_LOCATION)) { if(intent.hasExtra("latitude")) { fromUser = false; log("sending single observation, request from intent"); Location thisLocation = new Location("network"); double latitude = intent.getDoubleExtra("latitude", 0.0); double longitude = intent.getDoubleExtra("longitude", 0.0); thisLocation.setLatitude(latitude); thisLocation.setLongitude(longitude); sendSingleObs(thisLocation); } return START_NOT_STICKY; } } else if (intent.getBooleanExtra("alarm", false)) { // This runs when the service is started from the alarm. // Submit a data point log("cbservice alarm firing, sending data"); settingsHandler = new CbSettingsHandler(getApplicationContext()); settingsHandler = settingsHandler.getSettings(); removeOldSDKApps(); sendRegistrationInfo(); if(settingsHandler.isSharingData()) { //dataCollector.startCollectingData(); startWithIntent(intent, true); } else { log("cbservice not sharing data"); } LocationStopper stop = new LocationStopper(); mHandler.postDelayed(stop, 1000 * 3); return START_NOT_STICKY; } else { // Check the database log("cbservice on boot registering for notifications"); registerForNotifications(); log("starting service with db"); startWithDatabase(); return START_NOT_STICKY; } } } catch (Exception e) { log("cbservice onstartcommand exception " + e.getMessage()); } super.onStartCommand(intent, flags, startId); return START_NOT_STICKY; }
Example 18
Source File: IntentActionsService.java From Kore with Apache License 2.0 | 4 votes |
@Override public int onStartCommand(Intent intent, int flags, int startId) { // We won't create a new thread because the request to the host are // already done in a separate thread. Just fire the request and forget HostConnection hostConnection = HostManager.getInstance(this).getConnection(); String action = intent.getAction(); int playerId = intent.getIntExtra(EXTRA_PLAYER_ID, -1); if ((hostConnection != null) && (playerId != -1)) { switch (action) { case ACTION_PLAY_PAUSE: hostConnection.execute( new Player.PlayPause(playerId), null, null); break; case ACTION_REWIND: hostConnection.execute( new Player.SetSpeed(playerId, GlobalType.IncrementDecrement.DECREMENT), null, null); break; case ACTION_FAST_FORWARD: hostConnection.execute( new Player.SetSpeed(playerId, GlobalType.IncrementDecrement.INCREMENT), null, null); break; case ACTION_PREVIOUS: hostConnection.execute( new Player.GoTo(playerId, Player.GoTo.PREVIOUS), null, null); break; case ACTION_NEXT: hostConnection.execute( new Player.GoTo(playerId, Player.GoTo.NEXT), null, null); break; case ACTION_JUMP_BACKWARD: hostConnection.execute( new Player.Seek(playerId, Player.Seek.BACKWARD), null, null); break; case ACTION_JUMP_FORWARD: hostConnection.execute( new Player.Seek(playerId, Player.Seek.FORWARD), null, null); break; } } return START_NOT_STICKY; }
Example 19
Source File: MainActivity.java From memetastic with GNU General Public License v3.0 | 4 votes |
@SuppressWarnings("unchecked") @Override public void onReceive(Context context, Intent intent) { String action = intent.getAction(); switch (action) { case AppCast.ASSET_DOWNLOAD_REQUEST.ACTION: { switch (intent.getIntExtra(AppCast.ASSET_DOWNLOAD_REQUEST.EXTRA_RESULT, AssetUpdater.UpdateThread.ASSET_DOWNLOAD_REQUEST__FAILED)) { case AssetUpdater.UpdateThread.ASSET_DOWNLOAD_REQUEST__CHECKING: { updateInfoBar(0, R.string.download_latest_assets_checking_description, R.drawable.ic_file_download_white_32dp, false); break; } case AssetUpdater.UpdateThread.ASSET_DOWNLOAD_REQUEST__FAILED: { updateInfoBar(0, R.string.downloading_failed, R.drawable.ic_file_download_white_32dp, false); break; } case AssetUpdater.UpdateThread.ASSET_DOWNLOAD_REQUEST__DO_DOWNLOAD_ASK: { updateInfoBar(0, R.string.download_latest_assets_checking_description, R.drawable.ic_file_download_white_32dp, false); showDownloadDialog(); break; } } return; } case AppCast.DOWNLOAD_STATUS.ACTION: { int percent = intent.getIntExtra(AppCast.DOWNLOAD_STATUS.EXTRA_PERCENT, 100); switch (intent.getIntExtra(AppCast.DOWNLOAD_STATUS.EXTRA_STATUS, AssetUpdater.UpdateThread.DOWNLOAD_STATUS__FAILED)) { case AssetUpdater.UpdateThread.DOWNLOAD_STATUS__DOWNLOADING: { updateInfoBar(percent, R.string.downloading, R.drawable.ic_file_download_white_32dp, true); break; } case AssetUpdater.UpdateThread.DOWNLOAD_STATUS__FAILED: { updateInfoBar(percent, R.string.downloading_failed, R.drawable.ic_mood_bad_black_256dp, false); break; } case AssetUpdater.UpdateThread.DOWNLOAD_STATUS__UNZIPPING: { updateInfoBar(percent, R.string.unzipping, R.drawable.ic_file_download_white_32dp, true); break; } case AssetUpdater.UpdateThread.DOWNLOAD_STATUS__FINISHED: { updateInfoBar(percent, R.string.successfully_downloaded, R.drawable.ic_gavel_white_48px, false); break; } } return; } case AppCast.ASSETS_LOADED.ACTION: { selectTab(_tabLayout.getSelectedTabPosition(), _currentMainMode); updateHiddenNavOption(); break; } } }
Example 20
Source File: ForegroundAudioPlayer.java From flutter_exoplayer with MIT License | 4 votes |
@Override public int onStartCommand(Intent intent, int flags, int startId) { this.context = getApplicationContext(); mediaSession = new MediaSessionCompat(this.context, "playback"); // ! TODO handle MediaButtonReceiver's callbacks // MediaButtonReceiver.handleIntent(mediaSession, intent); // mediaSession.setCallback(mediaSessionCallback); if (intent.getAction() != null) { AudioObject currentAudioObject; if (this.playerMode == PlayerMode.PLAYLIST) { currentAudioObject = this.audioObjects.get(player.getCurrentWindowIndex()); } else { currentAudioObject = this.audioObject; } if (intent.getAction().equals(MediaNotificationManager.PREVIOUS_ACTION)) { if (currentAudioObject.getNotificationActionCallbackMode() == NotificationActionCallbackMode.DEFAULT) { previous(); } else { ref.handleNotificationActionCallback(this.foregroundAudioPlayer, NotificationActionName.PREVIOUS); } } else if (intent.getAction().equals(MediaNotificationManager.PLAY_ACTION)) { if (currentAudioObject.getNotificationActionCallbackMode() == NotificationActionCallbackMode.DEFAULT) { if (!stopped) { resume(); } else { if (playerMode == PlayerMode.PLAYLIST) { playAll(audioObjects, 0, 0); } else { play(audioObject, 0); } } } else { ref.handleNotificationActionCallback(this.foregroundAudioPlayer, NotificationActionName.PLAY); } } else if (intent.getAction().equals(MediaNotificationManager.PAUSE_ACTION)) { if (currentAudioObject.getNotificationActionCallbackMode() == NotificationActionCallbackMode.DEFAULT) { pause(); } else { ref.handleNotificationActionCallback(this.foregroundAudioPlayer, NotificationActionName.PAUSE); } } else if (intent.getAction().equals(MediaNotificationManager.NEXT_ACTION)) { if (currentAudioObject.getNotificationActionCallbackMode() == NotificationActionCallbackMode.DEFAULT) { next(); } else { ref.handleNotificationActionCallback(this.foregroundAudioPlayer, NotificationActionName.NEXT); } } else if (intent.getAction().equals(MediaNotificationManager.CUSTOM1_ACTION)) { ref.handleNotificationActionCallback(this.foregroundAudioPlayer, NotificationActionName.CUSTOM1); } else if (intent.getAction().equals(MediaNotificationManager.CUSTOM2_ACTION)) { ref.handleNotificationActionCallback(this.foregroundAudioPlayer, NotificationActionName.CUSTOM2); } } return START_STICKY; }