• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

How to add livedata to spinner

How can we use livedata in spinners? I have the following:

LiveData<List<Site>> sites = SiteDatabase.getInstance(this).siteDao().getAllSites();

Spinner spinner = findViewById(R.id.spinnerSites);
**What Goes Here!!*** adapter = new ArrayAdapter<Site>(this, android.R.layout.simple_dropdown_item_1line, sites);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(adapter);


Not sure how to proceed..

Thanks!!

How to open and read .pfx file?

I want to sign a String for my app using a .pfx A1 Certificate but Android Studio isn't reading the file. The iteration below* works on Netbeans just fine but in Android Studio returns false as it was not reading the .pfx file at all.

public String signApp(String input) throws NoSuchAlgorithmException, InvalidKeyException, SignatureException, KeyStoreException, IOException, CertificateException, UnrecoverableEntryException {
String signedString = "";
InputStream certificado;
char[] password = null;
KeyStore keystore = null;
Enumeration<String> aliases;
String alias = "";
//Open the .pfx file
certificado = getClass().getResourceAsStream("imediata.pfx");

password = "1234".toCharArray();
keystore = KeyStore.getInstance("PKCS12");
keystore.load(certificado, password );
//Get the alias
KeyStore.PrivateKeyEntry pkEntry = null;
PrivateKey pk = null;
try {
aliases = keystore.aliases();
while(aliases.hasMoreElements()) { //* problem: it's returning false as it not reading at
// all!!
alias = aliases.nextElement();
if (keystore.isKeyEntry(alias)) {
pkEntry = (KeyStore.PrivateKeyEntry) keystore.getEntry(alias, new
KeyStore.PasswordProtection(password ));
pk = pkEntry.getPrivateKey();
}
}
} catch (KeyStoreException e) {
throw new RuntimeException("CATCH", e);
}


//Keystore

Key key = (PrivateKey) keystore.getKey(alias, password );
java.security.cert.Certificate cert = keystore.getCertificate(alias);
PublicKey publicKey = cert.getPublicKey();
KeyPair kPair = new KeyPair(publicKey, (PrivateKey) key);

byte[] buffer = chave.getBytes();
// Signature
Signature signatureProvider = Signature.getInstance("SHA1withRSA");
signatureProvider.initSign(kPair.getPrivate());
signatureProvider.initSign(pk);
signatureProvider.update(buffer, 0, buffer.length);
byte[] signature = signatureProvider.sign();
signedString = Base64.getEncoder().encodeToString(signature);
return signedString;
}

Question related to the camera quality images on the Samsung Galaxy S20?

Hi,
I always wanted to take a photo and have it printed on a huge canvas like for example. a 36" (3Ft) X 48" (4 Ft), although it was impossible due to low resolution! I had a Samsung Galaxy S8+ and it took beautiful pictures but the resolution was too low when it comes to enlarged the image!

Now, my question is, with this new Samsung Galaxy S20, will the resolution be high enough to take photo and printed on a huge canvas?

So for the regular S20 (and the Plus) you have a 64mp shooter (not the main camera) which should be able to produce very large pics. You would need to play around a bit because I am not photo savvy enough to know *exactly* how big that goes, but a pic taken using that setting comes out to (let me check real quick on my S20 Plus), 6936 x 9248 pixels, 64.1mp and a 15mg pic size. This was all auto settings in a pic of my cat.

Hopefully that helps some!

Motorola Moto G6 play - backing up to PC

Hi, I would like to backup my phone but not to google of the cloud. Is there a way I can back up to my pc and if so how.

Thanks.
i looked and there does not seem to be a way to backup without using google. some manufacturer's have their own way to back up things, but i guess moto is not one of them. with my note 10+, samsung has smart switch that can update and backup and restore data......not sure what else you can do other then to use google.

S20 Ultra 5G and Straight Talk

Well update, the Verizon rep in the port center called me back in an hour like she promised, but while she was on the phone with straight talk, they both lost their computers. So she was going to call me back today. BUT she called me back about 10 minutes later and everything was all set. My phone switched to my old number at 1am just like she said. I was a little nervous at first because I shut it off for 5 minutes like she told me, twice, and it didn't update. So, I did a factory reset, and when it came back on, it was my old number!! So then I had to stay awake a little while longer and set it up and redownload my apps. LOL But so far I love the phone!! It's almost set up. Just need to do my ringtones and fix my notifications and stuff!! Thanks for your suggestions and help!

AWESOME! So glad it worked out!!!

Reviews Is the Galaxy S20 Ultra Worth it?

Now that I have it, I would say NO. If you feel the need to upgrade from the S10+ or Note 10+, go for the S20+ but the 2019 line ups are not far behind so an upgrade from 2019 is completely unnecessary.

Probably fair. *Maybe* the Ultra, just cause of the insanity they packed into it. But most of the s10 lineup is still top of line and barely a below the s20 line.

8K Video Sample (Almost Unboxing)

I was hoping to record a Galaxy S20 Ultra Unboxing with another Galaxy S20 Ultra... but my 2nd unit hasn't arrived yet. So for now... a quick 8K video sample looking out the window.


Truth be told, I don't have an 8K screen to watch it on so I can't comment on the quality!

Whaddaya think?

Looked good on my 4k monitor, impressed so far. I mean, this isn't taking over for Red cameras for youtubers or anything, but still cool to see this in phonesx.

s20 Plus camera issues

love the phone but can't seem to access the live focus mode im used to on my note 8. If I use the single take mode I sometimes get photos that I can change the background...i really like the ability to zoom the back ground or the color point option but I don't know how to access these options everything I like..does anyone know how to do that?? Thank you

Hmm, interesting. Not sure I've ever seen that option, but this is my first Samsung phone in a LONG time. You have link/reference to the functionality you speak of?

Stylo 4 stuck on zoom in lock screen

My mom's lg stylo 4 is stuck on the lock screen in zoom mode. I can enter the 4 digits for the code but I am unable to find the check button to unlock it. The only two numbers showing on the screen is 2 and 5. I have taken it to 3 TMobile stores and contacted lg customer service. no one knows how to help. I have done the 2 fingers trying to zoom in bit it's not letting me.
you will most likely need to do a hard reset . you will loose all of your data, but i'm not sure what else you can do.

here is how:
https://www.t-mobile.com/support/devices/android/lg-stylo-4/device-resets-lg-stylo-4

Fantastic Music Player app

Not sure if you updated your music app, but it seems to run now. However I think there's some issues and improvements to be made.

Album view seems to be in some arbitrary order, and some on the list are not actually music, things like Download, Data, and QQ Mail. Some music players you basically set like this is my Music folder, and don't look anywhere else for MP3s etc.
View attachment 148454

The songs list only shows 6 songs maximum, with no fast way I can see of scrolling down. And with 48847 songs, it could take a long time to get to the bottom.
The font used, while stylish, is not very efficient at showing song titles. Maybe use the same font, that was used in the Album list.
View attachment 148455

Also the Genre and Artist lists aren't showing anything.

One of my uses for my phone is music, and I sometimes do like to try out different music player apps.

Thank you so much for sharing your thoughts.&#128522;
Yes i made some changes in the new version due to which it is working on your device now, I do agree with your suggestions to have something that would easier finding songs while scrolling and the font seems to be very big. I have made a change in the app where I have changed the font of songs and now the titles gets displayed properly.
I am looking into the issue with genre and artist and albums with your device. Thank you for your patience. I will let you know once it is fixed. Thank you!!

Google assistant.

SMS is a telephony protocol, so if the SIM in your tablet is data-only I expect that you can't send/receive SMS from it (does the tablet have a telephone number?). My guess is that you should speak to your service provider, because whether it can send/receive SMS will depend on the account settings for that SIM.

Help Xbox 360 wired controller connection issues

Hello,

I have exactly the same problem: I can't connect my wired Xbox controller to my Huawei P Smart 2019.

The Xbox circle keeps flashing as if trying to connect or in simple charging mode. OTG checker apps identify the Xbox controller by name and manufacturer, but I can't make it work as an input device.

I tried what the original poster mentioned (USB debug mode) with no luck either.

Any new developments on this topic? Any suggestions?

I read that old phones did not have the right drivers for USB controllers but to install them the phone needs to be rooted. I suppose it's not that here, this phone is pretty new.

Thanks in advance for your help.

Encoding error when attempting to build with Cmake

Hi.
Im very new to Android studio, and i just ran into a problem with building the project in AS. I get the following error:
fatal error: UTF-16 (LE) byte order mark detected in 'A:/Visual Studio 2017/__Projects__/.../mycppfile.cpp', but encoding is not supported

I have tried few things. I tried changing the AS encoding to UTF-16, i tried enabling Tools -> Options -> Environment -> Documents -> "Save documents as Unicode when data cannot be saved" in my visual studio and tried to save the .cpp file again.

From the error it appears as if the issue comes from weird encoding from Visual Studio.

I would greatly appreciate help.

I have old lava pixel v2 2gb ram phone everytime i check for UPDATE it says connection timeout

Are you connecting to a WiFi network or using mobile data (cellular) when this error message occurs? Or does it happen when using both?
If just WiFi, try rebooting your router -- it could just be a local network glitch. Try connecting to a different WiFi network, like at a friend's home or work. If you have the same problem with a different WiFi network that indicates the problem is more likely to be with your phone.
If just mobile data, try re-seating your SIM card. It might also be helpful to log into your account with your carrier to check that your service is still active.

Filter

Back
Top Bottom