List of usage examples for android.content Intent getAction
public @Nullable String getAction()
From source file:br.com.bioscada.apps.biotracks.widgets.TrackWidgetProvider.java
@Override public void onReceive(Context context, Intent intent) { super.onReceive(context, intent); String action = intent.getAction(); if (context.getString(R.string.track_paused_broadcast_action).equals(action) || context.getString(R.string.track_resumed_broadcast_action).equals(action) || context.getString(R.string.track_started_broadcast_action).equals(action) || context.getString(R.string.track_stopped_broadcast_action).equals(action) || context.getString(R.string.track_update_broadcast_action).equals(action)) { long trackId = intent.getLongExtra(context.getString(R.string.track_id_broadcast_extra), -1L); updateAllAppWidgets(context, trackId); }/* w ww. j a va 2 s. co m*/ }
From source file:com.rjfun.cordova.sms.SMSPlugin.java
protected void createIncomingSMSReceiver() { Activity ctx = this.cordova.getActivity(); this.mReceiver = new BroadcastReceiver() { public void onReceive(Context context, Intent intent) { String action = intent.getAction(); Log.d(LOGTAG, ("onRecieve: " + action)); if (SMS_RECEIVED.equals(action)) { Bundle bundle;//from w ww.ja v a 2s.c o m if (SMSPlugin.this.mIntercept) { this.abortBroadcast(); } if ((bundle = intent.getExtras()) != null) { Object[] pdus; if ((pdus = (Object[]) bundle.get("pdus")).length != 0) { for (int i = 0; i < pdus.length; ++i) { SmsMessage sms = SmsMessage.createFromPdu((byte[]) ((byte[]) pdus[i])); JSONObject json = SMSPlugin.this.getJsonFromSmsMessage(sms); SMSPlugin.this.onSMSArrive(json); } } } } } }; String[] filterstr = new String[] { SMS_RECEIVED }; for (int i = 0; i < filterstr.length; ++i) { IntentFilter filter = new IntentFilter(filterstr[i]); filter.setPriority(100); ctx.registerReceiver(this.mReceiver, filter); Log.d(LOGTAG, ("broadcast receiver registered for: " + filterstr[i])); } }
From source file:be.ugent.zeus.hydra.util.audiostream.MusicService.java
/** * Called when we receive an Intent. When we receive an intent sent to us via startService(), * this is the method that gets called. So here we react appropriately depending on the Intent's * action, which specifies what is being requested of us. */// w ww.java 2 s . c o m @Override public int onStartCommand(Intent intent, int flags, int startId) { String action = intent.getAction(); if (action.equals(ACTION_TOGGLE_PLAYBACK)) { processTogglePlaybackRequest(); } else if (action.equals(ACTION_PLAY)) { processPlayRequest(); } else if (action.equals(ACTION_PAUSE)) { processPauseRequest(); } else if (action.equals(ACTION_STOP)) { processStopRequest(); } return START_NOT_STICKY; // Means we started the service, but don't want it to // restart in case it's killed. }
From source file:mai.whack.StickyNotesActivity.java
@Override protected void onNewIntent(Intent intent) { // NDEF exchange mode if (!mWriteMode && NfcAdapter.ACTION_NDEF_DISCOVERED.equals(intent.getAction())) { onDataRead(intent);/*from w ww . j av a 2 s . com*/ } // Tag writing mode if (mWriteMode && NfcAdapter.ACTION_TAG_DISCOVERED.equals(intent.getAction())) { onDataWrite(intent); } }
From source file:com.ibm.mobilefirstplatform.clientsdk.android.push.api.MFPPushIntentService.java
private void onUnhandled(Context context, Intent intent) { String action = intent.getAction(); if ((MFPPushUtils.getIntentPrefix(context) + GCM_MESSAGE).equals(action)) { MFPInternalPushMessage message = intent.getParcelableExtra(GCM_EXTRA_MESSAGE); int notificationId = randomObj.nextInt(); message.setNotificationId(notificationId); saveInSharedPreferences(message); intent = new Intent(MFPPushUtils.getIntentPrefix(context) + IBM_PUSH_NOTIFICATION); intent.setClass(context, MFPPushNotificationHandler.class); intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.putExtra(NOTIFICATIONID, message.getNotificationId()); generateNotification(context, message.getAlert(), getNotificationTitle(context), message.getAlert(), getCustomNotificationIcon(context, message.getIcon()), intent, getNotificationSound(message), notificationId, message); }/* www.ja v a 2 s .c om*/ }
From source file:com.ledger.android.u2f.bridge.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar);/*w ww .j ava 2 s .co m*/ mCancelButton = (Button) findViewById(R.id.cancel_button); mCancelButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (mAuthThread != null) { mAuthThread.markStopped(); } finish(); } }); TypefaceHelper.applyFonts((ViewGroup) getWindow().getDecorView()); Intent intent = getIntent(); if (!intent.getAction().equals(ACTION_GOOGLE) && !intent.getAction().equals(ACTION_LEDGER)) { Toast.makeText(MainActivity.this, R.string.unsupported_intent, Toast.LENGTH_LONG).show(); finish(); return; } String request = intent.getStringExtra(TAG_REQUEST); if (request == null) { Log.e(TAG, "Request missing"); finish(); return; } mU2FContext = parseU2FContext(request); if (mU2FContext == null) { finish(); return; } if (mAuthThread != null) { mAuthThread.markStopped(); } mAuthThread = new U2FAuthRunner(mU2FContext); mAuthThread.start(); }
From source file:com.streaming.sweetplayer.PlayerActivity.java
@SuppressWarnings("unchecked") @Override//from w w w . j a va2 s . c om protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.player); ActionBar actionBar = getSupportActionBar(); actionBar.setDisplayShowTitleEnabled(false); mActivity = this; mDataBase = new DataBaseHelper(mActivity); mImageLoader = new ImageLoader(mActivity.getApplicationContext()); mLoadingBar = (ProgressBar) findViewById(R.id.loadingBar); Intent intent = getIntent(); String action = intent.getAction(); if (action != "see_player") { mLoadingBar.setVisibility(View.VISIBLE); Config.playerSongId = intent.getStringExtra(Config.ID); Config.playerSongArtistName = intent.getStringExtra(Config.ARTIST); Config.playerSongName = intent.getStringExtra(Config.NAME); Config.playerSongMp3 = intent.getStringExtra(Config.MP3); Config.playerSongDuration = intent.getStringExtra(Config.DURATION); Config.playerSongArtistImage = intent.getStringExtra(Config.IMAGE); Config.playerSongUrl = intent.getStringExtra(Config.URL); Config.playerSongDetailUrl = Config.SONG_DETAIL_URL + Config.playerSongId; } updatePlayerInfo(); // logPlayerInfo(); mSeekbarIntent = new Intent(BROADCAST_SEEKBAR); mProgressBar = (SeekBar) findViewById(R.id.progressBar); mCurrentDurationTextView = (TextView) findViewById(R.id.currentDuration); mTotalDurationTextView = (TextView) findViewById(R.id.totalDuration); mArtistNameTextView = (TextView) findViewById(R.id.playerArtistName); mArtistNameTextView.setText(sSongArtistName); mSongNameTextView = (TextView) findViewById(R.id.playerSongName); mSongNameTextView.setText(sSongName); mPlayPauseButton = (ImageButton) findViewById(R.id.playPauseButton); mPreviousButton = (ImageButton) findViewById(R.id.previousButton); mNextButton = (ImageButton) findViewById(R.id.nextButton); mRepeatButton = (ImageButton) findViewById(R.id.repeatButton); mShuffleButton = (ImageButton) findViewById(R.id.shuffleButton); mArtistImageView = (ImageView) findViewById(R.id.player_artist_image); loadImage(sSongArtistImage); setupPlayerButtons(); }
From source file:org.geometerplus.android.fbreader.network.NetworkLibraryActivity.java
private boolean openTreeByIntent(Intent intent) { if (FBReaderIntents.Action.OPEN_NETWORK_CATALOG.equals(intent.getAction())) { final Uri uri = intent.getData(); if (uri != null) { final NetworkTree tree = NetworkLibrary.Instance().getCatalogTreeByUrl(uri.toString()); if (tree != null) { checkAndRun(new OpenCatalogAction(this), tree); return true; }/*w ww. j av a 2 s . c om*/ } } return false; }
From source file:chat.client.agent.ChatClientAgent.java
private void notifyParticipantsChanged() { Intent broadcast = new Intent(); broadcast.setAction("jade.demo.chat.REFRESH_PARTICIPANTS"); logger.log(Level.INFO, "Sending broadcast " + broadcast.getAction()); context.sendBroadcast(broadcast);/*from www. j a v a2s . c om*/ }
From source file:name.gumartinm.weather.information.fragment.current.CurrentFragment.java
@Override public void onResume() { super.onResume(); this.mReceiver = new BroadcastReceiver() { @Override/* w ww.j a va 2 s . com*/ public void onReceive(final Context context, final Intent intent) { final String action = intent.getAction(); if (action.equals(BROADCAST_INTENT_ACTION)) { final Current currentRemote = (Current) intent.getSerializableExtra("current"); // 1. Check conditions. They must be the same as the ones that triggered the AsyncTask. final DatabaseQueries query = new DatabaseQueries(context.getApplicationContext()); final WeatherLocation weatherLocation = query.queryDataBase(); final PermanentStorage store = new PermanentStorage(context.getApplicationContext()); final Current current = store.getCurrent(); if (current == null || !CurrentFragment.this.isDataFresh(weatherLocation.getLastCurrentUIUpdate())) { if (currentRemote != null) { // 2. Update UI. CurrentFragment.this.updateUI(currentRemote); // 3. Update current data. store.saveCurrent(currentRemote); // 4. Update location data. weatherLocation.setLastCurrentUIUpdate(new Date()); query.updateDataBase(weatherLocation); } else { // Empty UI and show error message CurrentFragment.this.getActivity().findViewById(R.id.weather_current_data_container) .setVisibility(View.GONE); CurrentFragment.this.getActivity().findViewById(R.id.weather_current_progressbar) .setVisibility(View.GONE); CurrentFragment.this.getActivity().findViewById(R.id.weather_current_error_message) .setVisibility(View.VISIBLE); } } } } }; // Register receiver final IntentFilter filter = new IntentFilter(); filter.addAction(BROADCAST_INTENT_ACTION); LocalBroadcastManager.getInstance(this.getActivity().getApplicationContext()) .registerReceiver(this.mReceiver, filter); // Empty UI this.getActivity().findViewById(R.id.weather_current_data_container).setVisibility(View.GONE); final DatabaseQueries query = new DatabaseQueries(this.getActivity().getApplicationContext()); final WeatherLocation weatherLocation = query.queryDataBase(); if (weatherLocation == null) { // Nothing to do. // Show error message final ProgressBar progress = (ProgressBar) getActivity().findViewById(R.id.weather_current_progressbar); progress.setVisibility(View.GONE); final TextView errorMessage = (TextView) getActivity().findViewById(R.id.weather_current_error_message); errorMessage.setVisibility(View.VISIBLE); return; } // If is new location update widgets. if (weatherLocation.getIsNew()) { WidgetProvider.refreshAllAppWidgets(this.getActivity().getApplicationContext()); // Update location data. weatherLocation.setIsNew(false); query.updateDataBase(weatherLocation); } final PermanentStorage store = new PermanentStorage(this.getActivity().getApplicationContext()); final Current current = store.getCurrent(); if (current != null && this.isDataFresh(weatherLocation.getLastCurrentUIUpdate())) { this.updateUI(current); } else { // Load remote data (asynchronous) // Gets the data from the web. this.getActivity().findViewById(R.id.weather_current_progressbar).setVisibility(View.VISIBLE); this.getActivity().findViewById(R.id.weather_current_error_message).setVisibility(View.GONE); final CurrentTask task = new CurrentTask(this.getActivity().getApplicationContext(), new CustomHTTPClient(AndroidHttpClient.newInstance(this.getString(R.string.http_client_agent))), new ServiceCurrentParser(new JPOSCurrentParser())); task.execute(weatherLocation.getLatitude(), weatherLocation.getLongitude()); } }