List of usage examples for android.content Intent getAction
public @Nullable String getAction()
From source file:com.googlecode.android_scripting.facade.ui.NFCBeamTask.java
@SuppressLint("NewApi") NdefMessage[] getNdefMessagesFromIntent(Intent intent) { // Parse the intent NdefMessage[] msgs = null;// w w w .j ava 2 s .c om String action = intent.getAction(); if (action.equals(NfcAdapter.ACTION_TAG_DISCOVERED) || action.equals(NfcAdapter.ACTION_NDEF_DISCOVERED)) { Parcelable[] rawMsgs = intent.getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES); if (rawMsgs != null) { msgs = new NdefMessage[rawMsgs.length]; for (int i = 0; i < rawMsgs.length; i++) { msgs[i] = (NdefMessage) rawMsgs[i]; } } else { // Unknown tag type byte[] empty = new byte[] {}; NdefRecord record = new NdefRecord(NdefRecord.TNF_UNKNOWN, empty, empty, empty); NdefMessage msg = new NdefMessage(new NdefRecord[] { record }); msgs = new NdefMessage[] { msg }; } } else { Log.e(TAG, "Unknown intent."); finish(); } return msgs; }
From source file:fr.cph.chicago.activity.MainActivity.java
@Override public void startActivity(Intent intent) { // check if search intent if (Intent.ACTION_SEARCH.equals(intent.getAction())) { ArrayList<BikeStation> bikeStations = getIntent().getExtras().getParcelableArrayList("bikeStations"); intent.putParcelableArrayListExtra("bikeStations", bikeStations); }// w w w. j a va 2 s. c o m super.startActivity(intent); }
From source file:com.halseyburgund.rwframework.core.RWStreamAssetsTracker.java
/** * Sends a RW.STREAM_METADATA_UPDATED broadcast intent that apps can * listen for to be notified about changes in the asset being played. * //from w w w .j a v a 2 s.c om * @param currentAssetId of asset that started playing * @param previousAssetId of asset that finished playing * @param meta Title of the asset */ private void broadcastStreamMetadataUpdate(int currentAssetId, int previousAssetId, String meta) { Intent intent = new Intent(); intent.setAction(RW.STREAM_METADATA_UPDATED); intent.putExtra(RW.EXTRA_STREAM_METADATA_CURRENT_ASSET_ID, currentAssetId); intent.putExtra(RW.EXTRA_STREAM_METADATA_PREVIOUS_ASSET_ID, previousAssetId); intent.putExtra(RW.EXTRA_STREAM_METADATA_TITLE, meta); if (D) { Log.d(TAG, "Going to send broadcast event, action = " + intent.getAction(), null); } mRwService.sendBroadcast(intent); }
From source file:cc.echonet.coolmicapp.MainActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.home);/* w ww .j a va 2s.com*/ timerValue = (TextView) findViewById(R.id.timerValue); BroadcastReceiver mPowerKeyReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { String strAction = intent.getAction(); if (strAction.equals(Intent.ACTION_SCREEN_OFF) || strAction.equals(Intent.ACTION_SCREEN_ON) || strAction.equals(Intent.ACTION_USER_PRESENT)) { if (isThreadOn) { RedFlashLight(); } } } }; final IntentFilter theFilter = new IntentFilter(); /** System Defined Broadcast */ theFilter.addAction(Intent.ACTION_SCREEN_ON); theFilter.addAction(Intent.ACTION_SCREEN_OFF); theFilter.addAction(Intent.ACTION_USER_PRESENT); getApplicationContext().registerReceiver(mPowerKeyReceiver, theFilter); imageView1 = (ImageView) findViewById(R.id.imageView1); Log.v("onCreate", (imageView1 == null ? "iv null" : "iv ok")); android.view.ViewGroup.LayoutParams layoutParams = imageView1.getLayoutParams(); if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { layoutParams.height = 400; } else { layoutParams.height = 180; } imageView1.setLayoutParams(layoutParams); myClipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE); getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); animation.setDuration(500); // duration - half a second animation.setInterpolator(new LinearInterpolator()); // do not alter animation rate animation.setRepeatCount(Animation.INFINITE); // Repeat animation infinitely animation.setRepeatMode(Animation.REVERSE); start_button = (Button) findViewById(R.id.start_recording_button); stop_button = (Button) findViewById(R.id.stop_recording_button); buttonColor = start_button.getBackground(); logArea = (TextView) findViewById(R.id.log_area); logArea.setMovementMethod(new ScrollingMovementMethod()); coolmic = new CoolMic(this, "default"); if (Wrapper.getState() == Wrapper.WrapperInitializationStatus.WRAPPER_UNINITIALIZED) { if (Wrapper.init() == Wrapper.WrapperInitializationStatus.WRAPPER_INITIALIZATION_ERROR) { Log.d("WrapperInit", Wrapper.getInitException().toString()); Toast.makeText(getApplicationContext(), "Could not initialize native components :( Blocking controls!", Toast.LENGTH_SHORT).show(); } else { Toast.makeText(getApplicationContext(), "Native components initialized!", Toast.LENGTH_SHORT) .show(); } } else if (Wrapper.init() == Wrapper.WrapperInitializationStatus.WRAPPER_INITIALIZATION_ERROR) { Toast.makeText(getApplicationContext(), "Previous problem detected with native components :( Blocking controls!", Toast.LENGTH_SHORT) .show(); } else if (Wrapper.init() != Wrapper.WrapperInitializationStatus.WRAPPER_INTITIALIZED) { Toast.makeText(getApplicationContext(), "Native components in unknown state!", Toast.LENGTH_SHORT) .show(); } txtListeners = (TextView) findViewById(R.id.txtListeners); IntentFilter mStatusIntentFilter = new IntentFilter(Constants.BROADCAST_STREAM_STATS_SERVICE); LocalBroadcastManager.getInstance(this).registerReceiver(mStreamStatsReceiver, mStatusIntentFilter); }
From source file:android.support.mediacompat.client.ClientBroadcastReceiver.java
@Override public void onReceive(Context context, Intent intent) { Bundle extras = intent.getExtras();//from w w w .ja v a 2 s . com MediaControllerCompat controller; try { controller = new MediaControllerCompat(context, (MediaSessionCompat.Token) extras.getParcelable(KEY_SESSION_TOKEN)); } catch (RemoteException ex) { // Do nothing. return; } int method = extras.getInt(KEY_METHOD_ID, 0); if (ACTION_CALL_MEDIA_CONTROLLER_METHOD.equals(intent.getAction()) && extras != null) { Bundle arguments; switch (method) { case SEND_COMMAND: arguments = extras.getBundle(KEY_ARGUMENT); controller.sendCommand(arguments.getString("command"), arguments.getBundle("extras"), new ResultReceiver(null)); break; case ADD_QUEUE_ITEM: controller.addQueueItem((MediaDescriptionCompat) extras.getParcelable(KEY_ARGUMENT)); break; case ADD_QUEUE_ITEM_WITH_INDEX: arguments = extras.getBundle(KEY_ARGUMENT); controller.addQueueItem((MediaDescriptionCompat) arguments.getParcelable("description"), arguments.getInt("index")); break; case REMOVE_QUEUE_ITEM: controller.removeQueueItem((MediaDescriptionCompat) extras.getParcelable(KEY_ARGUMENT)); break; case SET_VOLUME_TO: controller.setVolumeTo(extras.getInt(KEY_ARGUMENT), 0); break; case ADJUST_VOLUME: controller.adjustVolume(extras.getInt(KEY_ARGUMENT), 0); break; } } else if (ACTION_CALL_TRANSPORT_CONTROLS_METHOD.equals(intent.getAction()) && extras != null) { TransportControls controls = controller.getTransportControls(); Bundle arguments; switch (method) { case PLAY: controls.play(); break; case PAUSE: controls.pause(); break; case STOP: controls.stop(); break; case FAST_FORWARD: controls.fastForward(); break; case REWIND: controls.rewind(); break; case SKIP_TO_PREVIOUS: controls.skipToPrevious(); break; case SKIP_TO_NEXT: controls.skipToNext(); break; case SEEK_TO: controls.seekTo(extras.getLong(KEY_ARGUMENT)); break; case SET_RATING: controls.setRating((RatingCompat) extras.getParcelable(KEY_ARGUMENT)); break; case PLAY_FROM_MEDIA_ID: arguments = extras.getBundle(KEY_ARGUMENT); controls.playFromMediaId(arguments.getString("mediaId"), arguments.getBundle("extras")); break; case PLAY_FROM_SEARCH: arguments = extras.getBundle(KEY_ARGUMENT); controls.playFromSearch(arguments.getString("query"), arguments.getBundle("extras")); break; case PLAY_FROM_URI: arguments = extras.getBundle(KEY_ARGUMENT); controls.playFromUri((Uri) arguments.getParcelable("uri"), arguments.getBundle("extras")); break; case SEND_CUSTOM_ACTION: arguments = extras.getBundle(KEY_ARGUMENT); controls.sendCustomAction(arguments.getString("action"), arguments.getBundle("extras")); break; case SEND_CUSTOM_ACTION_PARCELABLE: arguments = extras.getBundle(KEY_ARGUMENT); controls.sendCustomAction((PlaybackStateCompat.CustomAction) arguments.getParcelable("action"), arguments.getBundle("extras")); break; case SKIP_TO_QUEUE_ITEM: controls.skipToQueueItem(extras.getLong(KEY_ARGUMENT)); break; case PREPARE: controls.prepare(); break; case PREPARE_FROM_MEDIA_ID: arguments = extras.getBundle(KEY_ARGUMENT); controls.prepareFromMediaId(arguments.getString("mediaId"), arguments.getBundle("extras")); break; case PREPARE_FROM_SEARCH: arguments = extras.getBundle(KEY_ARGUMENT); controls.prepareFromSearch(arguments.getString("query"), arguments.getBundle("extras")); break; case PREPARE_FROM_URI: arguments = extras.getBundle(KEY_ARGUMENT); controls.prepareFromUri((Uri) arguments.getParcelable("uri"), arguments.getBundle("extras")); break; case SET_CAPTIONING_ENABLED: controls.setCaptioningEnabled(extras.getBoolean(KEY_ARGUMENT)); break; case SET_REPEAT_MODE: controls.setRepeatMode(extras.getInt(KEY_ARGUMENT)); break; case SET_SHUFFLE_MODE: controls.setShuffleMode(extras.getInt(KEY_ARGUMENT)); break; } } }
From source file:com.google.zxing.client.android.CaptureActivity.java
@Override protected void onResume() { super.onResume(); Log.i("djf", "onResume"); // CameraManager must be initialized here, not in onCreate(). This is // necessary because we don't // want to open the camera driver and measure the screen size if we're // going to show the help on // first launch. That led to bugs where the scanning rectangle was the // wrong size and partially // off screen. cameraManager = CameraManager.getInstance(getApplication()); handler = null;//w w w.ja va2s . c o m // resetStatusView(); ambientLightManager.start(cameraManager); inactivityTimer.onResume(); Intent intent = getIntent(); source = IntentSource.NONE; decodeFormats = null; characterSet = null; if (intent != null) { String action = intent.getAction(); if (Intents.Scan.ACTION.equals(action)) { // Scan the formats the intent requested, and return the result // to the calling activity. source = IntentSource.NATIVE_APP_INTENT; } characterSet = intent.getStringExtra(Intents.Scan.CHARACTER_SET); } SurfaceView surfaceView = (SurfaceView) findViewById(EUExUtil.getResIdID("plugin_uexscanner_preview_view")); SurfaceHolder surfaceHolder = surfaceView.getHolder(); if (hasSurface) { // The activity was paused but not stopped, so the surface still // exists. Therefore // surfaceCreated() won't be called, so init the camera here. initCamera(surfaceHolder); } else { // Install the callback and wait for surfaceCreated() to init the // camera. surfaceHolder.addCallback(this); } }
From source file:be.brunoparmentier.wifikeyshare.ui.activities.WifiNetworkActivity.java
private void handleIntent(Intent intent) { Tag tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG); String action = intent.getAction(); Log.d(TAG, "handleIntent: action=" + action); if (isInWriteMode) { /* Write tag */ Log.d(TAG, "Writing tag"); if (NfcAdapter.ACTION_TAG_DISCOVERED.equals(action) || NfcAdapter.ACTION_NDEF_DISCOVERED.equals(action)) { if (NfcUtils.writeTag(wifiNetwork, tag)) { Toast.makeText(this, R.string.nfc_tag_written, Toast.LENGTH_LONG).show(); } else { Toast.makeText(this, R.string.error_nfc_tag_write, Toast.LENGTH_LONG).show(); }/*from w w w. j a v a2 s . c o m*/ disableTagWriteMode(); } } else { /* Read tag */ Log.d(TAG, "Reading tag"); if (NfcAdapter.ACTION_NDEF_DISCOVERED.equals(action)) { if (NfcUtils.NFC_TOKEN_MIME_TYPE.equals(intent.getType())) { Intent configureNetworkIntent = new Intent(intent) .setClass(this, ConfirmConnectToWifiNetworkActivity.class) .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(configureNetworkIntent); } else { Log.d(TAG, "Not a Wi-Fi configuration tag"); } } } }
From source file:com.hybris.mobile.app.commerce.fragment.CatalogContentFragmentBase.java
/** * Return true if we come from a search request * * @return//from ww w . j av a 2s.c o m */ protected boolean isSearchRequest() { Intent intent = getActivity().getIntent(); return (intent != null && StringUtils.equals(Intent.ACTION_SEARCH, intent.getAction()) && intent.hasExtra(SearchManager.QUERY)) || StringUtils.isNotBlank(mCurrentSearchText); }
From source file:app.axe.imooc.zxing.app.CaptureActivity.java
@SuppressWarnings("deprecation") @Override//from w w w .ja v a2s . c o m protected void onResume() { super.onResume(); resetStatusView(); if (hasSurface) { // The activity was paused but not stopped, so the surface still // exists. Therefore // surfaceCreated() won't be called, so init the camera here. if (ContextCompat.checkSelfPermission(this, android.Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) { ActivityCompat.requestPermissions(this, new String[] { android.Manifest.permission.CAMERA }, MY_PERMISSIONS_REQUEST_CAMERA); } else { initCamera(surfaceHolder); } } else { // Install the callback and wait for surfaceCreated() to init the // camera. Log.e("CaptureActivity", "onResume"); } Intent intent = getIntent(); String action = intent == null ? null : intent.getAction(); String dataString = intent == null ? null : intent.getDataString(); if (intent != null && action != null) { if (action.equals(Intents.Scan.ACTION)) { // Scan the formats the intent requested, and return the result // to the calling activity. source = Source.NATIVE_APP_INTENT; decodeFormats = DecodeFormatManager.parseDecodeFormats(intent); } else if (dataString != null && dataString.contains(PRODUCT_SEARCH_URL_PREFIX) && dataString.contains(PRODUCT_SEARCH_URL_SUFFIX)) { // Scan only products and send the result to mobile Product // Search. source = Source.PRODUCT_SEARCH_LINK; sourceUrl = dataString; decodeFormats = DecodeFormatManager.PRODUCT_FORMATS; } else if (dataString != null && dataString.startsWith(ZXING_URL)) { // Scan formats requested in query string (all formats if none // specified). // If a return URL is specified, send the results there. // Otherwise, handle it ourselves. source = Source.ZXING_LINK; sourceUrl = dataString; Uri inputUri = Uri.parse(sourceUrl); returnUrlTemplate = inputUri.getQueryParameter(RETURN_URL_PARAM); decodeFormats = DecodeFormatManager.parseDecodeFormats(inputUri); } else { // Scan all formats and handle the results ourselves (launched // from Home). source = Source.NONE; decodeFormats = null; } characterSet = intent.getStringExtra(Intents.Scan.CHARACTER_SET); } else { source = Source.NONE; decodeFormats = null; characterSet = null; } beepManager.updatePrefs(); }
From source file:com.chaturs.notepad.NoteEditor.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); final Intent intent = getIntent(); title = intent.getExtras().getString("note_title"); // Do some setup based on the action being performed. final String action = intent.getAction(); if (ACTION_EDIT.equals(action)) { // Requested to edit: set that state, and the data being edited. mState = STATE_EDIT;//w w w . j a va 2 s. com isSaved = false; mUri = intent.getData(); } else { // Whoops, unknown action! Bail. Log.e(TAG, "Unknown action, exiting"); finish(); return; } // Set the layout for this activity. You can find it in res/layout/note_editor.xml setContentView(R.layout.note_editor); preferences = getSharedPreferences(DOC_PREFERENCE, Context.MODE_PRIVATE); IpValue = preferences.getString(KEY_IPVALUE, ""); // The text view for our note, identified by its ID in the XML file. mText = (EditText) findViewById(R.id.note); // Get the note! mCursor = managedQuery(mUri, PROJECTION, null, null, null); // If an instance of this activity had previously stopped, we can // get the original text it started with. if (savedInstanceState != null) { mOriginalContent = savedInstanceState.getString(ORIGINAL_CONTENT); } DatabaseHandler databasehandler = DatabaseHandler.getInstance(); studyGroupList = databasehandler.listStudyGroupsInfo(); Iterator<StudyGroup> iterator = studyGroupList.iterator(); while (iterator.hasNext()) { StudyGroup studyGroup = iterator.next(); studyGroupNames.add(studyGroup.getName()); } }