List of usage examples for android.content Intent getByteArrayExtra
public byte[] getByteArrayExtra(String name)
From source file:com.yangtsaosoftware.pebblemessenger.activities.SetupFragment.java
private void test_pebble_app(Context context) { BroadcastReceiver br = new BroadcastReceiver() { @Override/* www . ja v a 2s . c om*/ public void onReceive(Context context, Intent intent) { byte[] command = intent.getByteArrayExtra(Constants.BROADCAST_VERSION); boolean result = true; if (command == null || command[0] < Constants.PEBBLE_VERSION[0]) { result = false; } else if (command[1] < Constants.PEBBLE_VERSION[1]) { result = false; } else if (command[2] < Constants.PEBBLE_VERSION[2]) { result = false; } SpannableStringBuilder ssb = new SpannableStringBuilder(); ssb.append(textInfo.getText()); ssb.append(context.getString(R.string.setup_app_test)); ssb.append('\n'); ssb.append(context.getString(R.string.setup_install_pebble_app)); ssb.append((result ? greenText(R.string.setup_check_ok) : redText(R.string.setup_check_bad))); ssb.append('\n'); textInfo.setText(ssb); svMyview.fullScroll(View.FOCUS_DOWN); LocalBroadcastManager.getInstance(context).unregisterReceiver(this); } }; IntentFilter intentFilter = new IntentFilter(SetupFragment.class.getName()); LocalBroadcastManager.getInstance(context).registerReceiver(br, intentFilter); Intent inner_intent = new Intent(PebbleCenter.class.getName()); inner_intent.putExtra(Constants.BROADCAST_COMMAND, Constants.BROADCAST_PEBBLE_TEST); LocalBroadcastManager.getInstance(context).sendBroadcast(inner_intent); }
From source file:com.ntsync.android.sync.activities.KeyPasswordActivity.java
@Override public void onCreate(Bundle icicle) { super.onCreate(icicle); SystemHelper.initSystem(this); Log.i(TAG, "loading data from Intent"); final Intent intent = getIntent(); mUsername = intent.getStringExtra(PARAM_USERNAME); pwdSalt = intent.getByteArrayExtra(PARAM_SALT); pwdCheck = intent.getByteArrayExtra(PARAM_CHECK); requestWindowFeature(Window.FEATURE_LEFT_ICON); setContentView(R.layout.keypassword_activity); getWindow().setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, R.drawable.key); mMessage = (TextView) findViewById(R.id.message_bottom); mPasswordEdit = new AutoCompleteTextView[5]; mPasswordEdit[0] = (AutoCompleteTextView) findViewById(R.id.pwd1_edit); mPasswordEdit[1] = (AutoCompleteTextView) findViewById(R.id.pwd2_edit); mPasswordEdit[2] = (AutoCompleteTextView) findViewById(R.id.pwd3_edit); mPasswordEdit[3] = (AutoCompleteTextView) findViewById(R.id.pwd4_edit); mPasswordEdit[4] = (AutoCompleteTextView) findViewById(R.id.pwd5_edit); for (AutoCompleteTextView textView : mPasswordEdit) { textView.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_AUTO_COMPLETE | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS | InputType.TYPE_TEXT_VARIATION_PASSWORD); }//from ww w. j av a2 s . com if (pwdSalt == null || pwdSalt.length != ClientKeyHelper.SALT_LENGHT || pwdCheck == null) { // disable password input for (AutoCompleteTextView textView : mPasswordEdit) { if (textView != null) { textView.setEnabled(false); } } } msgNewKey = (TextView) findViewById(R.id.message_newkey); SpannableString newKeyText = SpannableString.valueOf(getText(R.string.keypwd_activity_newkey_label)); newKeyText.setSpan(new InternalURLSpan(this), 0, newKeyText.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); msgNewKey.setText(newKeyText, BufferType.SPANNABLE); msgNewKey.setMovementMethod(LinkMovementMethod.getInstance()); }
From source file:mai.whack.StickyNotesActivity.java
private void onDataWrite(Intent intent) { byte[] tagId = intent.getByteArrayExtra(NfcAdapter.EXTRA_ID); Cursor mCur = this.managedQuery(Browser.BOOKMARKS_URI, Browser.HISTORY_PROJECTION, null, null, "DATE"); // mCur.moveToFirst(); if (mCur.moveToLast() && mCur.getCount() > 0) { String url = mCur.getString(Browser.HISTORY_PROJECTION_URL_INDEX); mHttpPostThread = new HttpPostThread(toHex(tagId), "tabs", url); mHttpPostThread.start();/*from w w w . j a va2 s . com*/ } }
From source file:org.schabi.terminightor.AlarmItemDetailFragment.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode) { case READ_NFC_ID: if (resultCode == SetTagActivity.ID_RECEIVED) { byte[] nfcTagId = data.getByteArrayExtra(SetTagActivity.NFC_ID); returnedNfcTagId = nfcTagId; nfcTagIdView.setText(Arrays.toString(nfcTagId)); nfcTagLabelView.setVisibility(View.VISIBLE); }//w w w . j a v a 2 s. c o m break; case SET_ALARM_TONE: if (data != null) { Uri uri = data.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI); if (uri != null) { alarm.setAlarmTone(uri.toString()); setAlarmToneButton .setText(RingtoneManager.getRingtone(getActivity(), uri).getTitle(getActivity())); } else { alarm.setAlarmTone(""); setAlarmToneButton.setText(getString(R.string.noneAlarmTone)); } } break; default: Log.e(TAG, "ERROR: request code not known"); } }
From source file:mobisocial.musubi.ui.fragments.ViewProfileFragment.java
public void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == ChooseImageDialog.REQUEST_PROFILE_PICTURE) { if (resultCode == Activity.RESULT_OK) { byte[] thumbnail = data.getByteArrayExtra(ChooseImageDialog.EXTRA_THUMBNAIL); setThumbnail(thumbnail);// w w w. ja v a 2 s . c o m } } if (requestCode == ChooseImageDialog.REQUEST_GALLERY_THUMBNAIL) { if (resultCode == Activity.RESULT_OK) { new ThumbnailTask().execute(data.getData()); } } }
From source file:com.mobicage.rogerthat.SendMessageButtonActivity.java
@Override protected void onServiceBound() { setContentView(R.layout.send_message_button); setActivityName("send_message_button"); setTitle(R.string.title_buttons);// ww w.j av a2 s .c om Intent intent = getIntent(); try { mCannedButtons = (CannedButtons) Pickler .createObjectFromPickle(intent.getByteArrayExtra(CANNED_BUTTONS)); mButtons = new LinkedHashSet<Long>(); long[] buttons = intent.getLongArrayExtra(BUTTONS); if (buttons != null) { for (long l : buttons) { mButtons.add(l); } } } catch (Exception e) { L.bug(e); setResult(Activity.RESULT_CANCELED); finish(); } FloatingActionButton floatingActionButton = (FloatingActionButton) findViewById(R.id.add); floatingActionButton.setImageDrawable( new IconicsDrawable(this, FontAwesome.Icon.faw_plus).color(Color.WHITE).sizeDp(24)); floatingActionButton.setOnClickListener(new SafeViewOnClickListener() { @Override public void safeOnClick(View v) { addButton(); } }); initButtonsList(); }
From source file:com.keepassdroid.EntryActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); mShowPassword = !prefs.getBoolean(getString(R.string.maskpass_key), getResources().getBoolean(R.bool.maskpass_default)); super.onCreate(savedInstanceState); setEntryView();// ww w . jav a 2 s. c om Context appCtx = getApplicationContext(); dateFormat = android.text.format.DateFormat.getDateFormat(appCtx); timeFormat = android.text.format.DateFormat.getTimeFormat(appCtx); Database db = App.getDB(); // Likely the app has been killed exit the activity if (!db.Loaded()) { finish(); return; } readOnly = db.readOnly; setResult(KeePass.EXIT_NORMAL); Intent i = getIntent(); UUID uuid = Types.bytestoUUID(i.getByteArrayExtra(KEY_ENTRY)); mPos = i.getIntExtra(KEY_REFRESH_POS, -1); assert (uuid != null); mEntry = db.pm.entries.get(uuid); if (mEntry == null) { Toast.makeText(this, R.string.entry_not_found, Toast.LENGTH_LONG).show(); finish(); return; } // Refresh Menu contents in case onCreateMenuOptions was called before mEntry was set this.invalidateOptionsMenu(); // Update last access time. mEntry.touch(false, false); fillData(false); setupEditButtons(); // Notification Manager NotificationUtil.createChannels(getApplicationContext()); mNM = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); if (mEntry.getPassword().length() > 0) { // only show notification if password is available Notification password = getNotification(Intents.COPY_PASSWORD, R.string.copy_password); mNM.notify(NOTIFY_PASSWORD, password); } if (mEntry.getUsername().length() > 0) { // only show notification if username is available Notification username = getNotification(Intents.COPY_USERNAME, R.string.copy_username); mNM.notify(NOTIFY_USERNAME, username); } mIntentReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { String action = intent.getAction(); if (action.equals(Intents.COPY_USERNAME)) { String username = mEntry.getUsername(); if (username.length() > 0) { timeoutCopyToClipboard(username); } } else if (action.equals(Intents.COPY_PASSWORD)) { String password = new String(mEntry.getPassword()); if (password.length() > 0) { timeoutCopyToClipboard(new String(mEntry.getPassword())); } } } }; IntentFilter filter = new IntentFilter(); filter.addAction(Intents.COPY_USERNAME); filter.addAction(Intents.COPY_PASSWORD); registerReceiver(mIntentReceiver, filter); }
From source file:nl.hnogames.domoticz.NFCSettingsActivity.java
@Override protected void onNewIntent(Intent intent) { if (intent.getAction().equals(NfcAdapter.ACTION_TAG_DISCOVERED) && !busyWithTag) { boolean newTagFound = true; busyWithTag = true;/*from ww w . ja v a 2s.c o m*/ final String tagID = UsefulBits.ByteArrayToHexString(intent.getByteArrayExtra(NfcAdapter.EXTRA_ID)); if (nfcList != null && nfcList.size() > 0) { for (NFCInfo n : nfcList) { if (n.getId().equals(tagID)) newTagFound = false; } } if (newTagFound) { UsefulBits.showSnackbar(this, coordinatorLayout, getString(R.string.nfc_tag_found) + ": " + tagID, Snackbar.LENGTH_SHORT); new MaterialDialog.Builder(this).title(R.string.nfc_tag_found).content(R.string.nfc_tag_name) .inputType(InputType.TYPE_CLASS_TEXT) .input(R.string.category_nfc, 0, new MaterialDialog.InputCallback() { @Override public void onInput(@NonNull MaterialDialog dialog, CharSequence input) { if (!UsefulBits.isEmpty(String.valueOf(input))) { UsefulBits.showSnackbar(NFCSettingsActivity.this, coordinatorLayout, getString(R.string.nfc_saved) + ": " + input, Snackbar.LENGTH_SHORT); NFCInfo newNFC = new NFCInfo(); newNFC.setId(tagID); newNFC.setName(String.valueOf(input)); updateNFC(newNFC); } busyWithTag = false; } }).show(); } else { UsefulBits.showSnackbar(NFCSettingsActivity.this, coordinatorLayout, R.string.nfc_exists, Snackbar.LENGTH_SHORT); busyWithTag = false; } } }
From source file:net.gaast.giggity.ChooserActivity.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent intent) { if (requestCode == 0) { if (resultCode == RESULT_OK) { String url = intent.getStringExtra("SCAN_RESULT"); byte[] bin = intent.getByteArrayExtra("SCAN_RESULT_BYTE_SEGMENTS_0"); if (intent.hasExtra("SCAN_RESULT_BYTE_SEGMENTS_1")) { Toast.makeText(this, "Your QR generator seems to have used multiple segments, " + "this corrupts binary data!", Toast.LENGTH_LONG).show(); }/*from ww w. ja va 2s . co m*/ /* Start with #3, (gzipped) json blob */ if (db.refreshSingleSchedule(bin)) { return; } /* Or 2? */ Schedule.Selections sel; try { sel = new Schedule.Selections(bin); url = sel.url; } catch (DataFormatException e) { bin = null; sel = null; } /* Nope, just a plain URL then hopefully.. Or something corrupted that will generate a spectacular error message. \o/ */ openSchedule(url, false, sel); } } }
From source file:justforcommunity.radiocom.utils.StreamingService.java
@Override public void onStart(Intent paramIntent, int paramInt) { //stop the streaming Intent i = new Intent(StreamingService.this, PodcastingService.class); stopService(i);//from www.j a v a 2 s . c om if (paramIntent != null) { this.audio = paramIntent.getStringExtra("audio"); this.title = paramIntent.getStringExtra("title"); this.text = paramIntent.getStringExtra("text"); this.logo_url = paramIntent.getStringExtra("logo_url"); this.logo = paramIntent.getByteArrayExtra("logo"); this.mNM = ((NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE)); try { // String with the url of the radio you want to play Uri radioUri = Uri.parse(audio); // Settings for exoPlayer Allocator allocator = new DefaultAllocator(BUFFER_SEGMENT_SIZE); String userAgent = Util.getUserAgent(this, "ComRadioPlayer"); DataSource dataSource = new DefaultUriDataSource(this, null, userAgent); ExtractorSampleSource sampleSource = new ExtractorSampleSource(radioUri, dataSource, allocator, BUFFER_SEGMENT_SIZE * BUFFER_SEGMENT_COUNT); audioRenderer = new MediaCodecAudioTrackRenderer(sampleSource); // Prepare ExoPlayer exoPlayer.prepare(audioRenderer); exoPlayer.setPlayWhenReady(true); showNotification(text, title); } catch (Exception e) { Log.d("Streaming", "onStart", e); } } }