Shared preferences and textview - Android Software Development

I originally asked this question in Srackoverflow. But I did not get any answers.
I am trying to set a text view number value to shared preferences using a string to get the values. Can anyone help with this?
Sent from my SGH-M919 using XDA Premium 4 mobile app

mistere372002 said:
I am trying to set a text view number value to shared preferences using a string to get the values
Click to expand...
Click to collapse
Could you elaborate on this?
You want to store the text (which is a number) in the textview to shared preferences?
Code:
mPrefs.edit().putInt("my-key", Integer.parse(mTextView.getText().toString())).commit();

That's correct. I forgot to mention that the number could be a decimal also.
Sent from my SGH-M919 using XDA Premium 4 mobile app

Thanks painless, that worked perfectly!
Sent from my SGH-M919 using XDA Premium 4 mobile app

Storing Chronometer time in SharedPreferences
mistere372002 said:
Thanks painless, that worked perfectly!
Sent from my SGH-M919 using XDA Premium 4 mobile app
Click to expand...
Click to collapse
I am actually trying to store the value of a chronometer in SharedPreferences but admittedly I have not worked with SharedPreferences much.
My end goal is to be able to close the Chronometer app and have the chronometer pick up from where it left off when the app is close.
Any help is appreciated.
Code:
chronometer = (Chronometer) findViewById(R.id.Chronometer1);
public void startClick (View view){
chronometer.setBase(SystemClock.elapsedRealtime());
chronometer.start();
Vibrator vib = (Vibrator)getSystemService(Context.VIBRATOR_SERVICE);
vib.vibrate(100);
}

Related

Keyboard shortcuts definitive list.

Lots of keyboard shortcuts appear in many different threads that allow us to access information like software ect, so add your short cut with a brief description of what it does.
YOU CAN CHANGE THINGS INSIDE CERTAIN SETTING SO BE CAREFULL I CANNOT BE HELD RESPONSIBLE.
*#*#4636#*#* = testing menu.
*#197328640# = service menu
*#34971539# = camera firmware
Sent from my GT-I9300 using xda premium
A whole bunch of codes are in this thread:
http://forum.xda-developers.com/showthread.php?t=1687249
Sent from my GT-I9300 using xda premium
Spent three days looking for that . Mods please delete.
Sent from my GT-I9300 using xda premium

How do I add a webview element?

I am coding an aggregation app for most of what we check on our smart phones.
I need a page that can display 4 HTML pages at once. I have no idea on even how to add 1 page. Any ideas?
Thanks in advance.
Sent from my HUAWEI-M835 using xda app-developers app
At once? Next to each other or three of some in the background?
For the last one search for the Fragments documentation.
crazy4creationstudios said:
I am coding an aggregation app for most of what we check on our smart phones.
I need a page that can display 4 HTML pages at once. I have no idea on even how to add 1 page. Any ideas?
Thanks in advance.
Sent from my HUAWEI-M835 using xda app-developers app
Click to expand...
Click to collapse
You should probably use fragments with a webview in each one since on smaller devices it would be really hard to read all 4 webviews or if your set on the webviews being on the same screen a table or grid layout would probably be the easiest way to organize them. There is a composite tab in Eclipse and the last entry is a webview.
This is thenewboston tutorial on webviews:
http://www.youtube.com/watch?v=lkadcYQ6SuY

Mobile device ID

How does one change it? I looked with build prop but no luck.
Sent from my Nexus 4 using xda app-developers app
Tunderpimp said:
How does one change it? I looked with build prop but no luck.
Sent from my Nexus 4 using xda app-developers app
Click to expand...
Click to collapse
Talking bout the Android Device ID or something different? (Titanium Backup usually lets you generate a new one, or restore one from a previous backup).
kbeezie said:
Talking bout the Android Device ID or something different? (Titanium Backup usually lets you generate a new one, or restore one from a previous backup).
Click to expand...
Click to collapse
When I get work emails from co workers it says the type of phone they are using. When they get one from me it says android and some numbers. It's the mobile device ID
Sent from my Nexus 4 using xda app-developers app
Tunderpimp said:
When I get work emails from co workers it says the type of phone they are using. When they get one from me it says android and some numbers. It's the mobile device ID
Sent from my Nexus 4 using xda app-developers app
Click to expand...
Click to collapse
Where exactly does it say this, maybe you're thinking of email signatures or such, and it would depend on the type of email client. Normally your actual android device ID isn't just arbitrarily transmitted in an email.
kbeezie said:
Where exactly does it say this, maybe you're thinking of email signatures or such, and it would depend on the type of email client. Normally your actual android device ID isn't just arbitrarily transmitted in an email.
Click to expand...
Click to collapse
It's not a signature and it's not the android device ID, they don't match. My work email pulls it off the phone. It even shows it when I set up the email. I did some research and that's how I found out it's called a mobile device ID.
Sent from my Nexus 4 using xda app-developers app
Tunderpimp said:
It's not a signature and it's not the android device ID, they don't match. My work email pulls it off the phone. It even shows it when I set up the email. I did some research and that's how I found out it's called a mobile device ID.
Sent from my Nexus 4 using xda app-developers app
Click to expand...
Click to collapse
So you're using an app specific for work then I'm guessing. If you got access to the original rom where the ID is correct, you can install titanium backup from the play store there. Then backup the settings (under preference there's a way to save the titanium backup settings to the SD Card/media space), then restore new rom, install titanium backup again, point it to the sdcard/external for it's backup, and you may be prompted with a prompt that your android ID differs from the other, and given the opportunity to restore it from backup (however bear in midn you may have to reinstall some applications that are dependent on your new ID).
There may be an easier way, but it's just weird that you have a work email that would work based off that.
It's not a host name I just tried that too.
Sent from my Nexus 4 using xda app-developers app
Sent from my U.S. Cellular© Smartphone,
Sent from my iPhone, Sent from my Verizon Wireless 4G LTE Smartphone here are some examples I found.
My emails say sent from my Androidc random numbers right after androidc
Tunderpimp said:
Sent from my U.S. Cellular© Smartphone,
Sent from my iPhone, Sent from my Verizon Wireless 4G LTE Smartphone here are some examples I found.
My emails say sent from my Androidc random numbers right after androidc
Click to expand...
Click to collapse
That looks very much like a setting you jsut set in the app/email client. Just like the iPhone has that, it's in the settings. What email client are you using, should be just like the XDA/Tapatalk app where you can modify the manual signature.
kbeezie said:
That looks very much like a setting you jsut set in the app/email client. Just like the iPhone has that, it's in the settings. What email client are you using, should be just like the XDA/Tapatalk app where you can modify the manual signature.
Click to expand...
Click to collapse
It's the stock email app that comes with the phone its yellow and white.
Sent from my Nexus 4 using xda app-developers app
Tunderpimp said:
It's the stock email app that comes with the phone its yellow and white.
Sent from my Nexus 4 using xda app-developers app
Click to expand...
Click to collapse
Oh just the standard ol email app. Double check the settings of that app , On the message list -> menu -> settings -> Tap account -> Signature
(by default nothing shows in the signature area when I send myself a test email thru my yahoo account, nor nothing in the mail headers to designate operating system)
Unless of course you're saying that it's being performed serverside.
How about in developers options their is one called device hostname and it can be edited, by default my devices all say Android-some random numbers and letters.
Sent from my Nexus 4 using xda app-developers app
illgodson said:
How about in developers options their is one called device hostname and it can be edited, by default my devices all say Android-some random numbers and letters.
Sent from my Nexus 4 using xda app-developers app
Click to expand...
Click to collapse
The mobile device id is different in the Stock email app vs the touchwiz email app. Anyone know how to change the stock mobile device id?

[Q] Restart service after kill

Hi I want to start my service after it is killed by the user or the system.
I thought about creating a second app and monitor if the service is running and if not then start it.
The problem I have with that is
- I need two apps
- It drains more battery
I hope you can help me find the best solution for my problem
Yeah, I think if you override the onDestroy method on your service class, and then you can send a broadcast from there.
In your broadcast receiver you can start the service again.
Though i have never tried it myself, i think this should work.
Tell me how it goes
Happy coding!! :thumbup:
Sent from my GT-P3100 using XDA Free mobile app
hiphop12ism said:
Yeah, I think if you override the onDestroy method on your service class, and then you can send a broadcast from there.
In your broadcast receiver you can start the service again.
Though i have never tried it myself, i think this should work.
Tell me how it goes
Happy coding!! :thumbup:
Sent from my GT-P3100 using XDA Free mobile app
Click to expand...
Click to collapse
I thought about that too but unfortunately when the app is stopped by the user the onDestroy methode is not called...
Sent from my SM-N9005 using XDA Premium 4 mobile app
If yu are using android version less than 4.4.2 then returning start sticky should do it
Sent from my GT-P3100 using XDA Free mobile app
hiphop12ism said:
If yu are using android version less than 4.4.2 then returning start sticky should work
Sent from my GT-P3100 using XDA Free mobile app
Click to expand...
Click to collapse
That is only if the system stops the service not if the user does....
Sent from my SM-N9005 using XDA Premium 4 mobile app
Rick Clephas said:
That is only if the system stops the service not if the user does....
Click to expand...
Click to collapse
I believe there is no such way... otherwise android would be very insecure for malware that just does this . You can only restart your service once the user restarts your activity, there should not be another way (and START_STICKY for the system of course). And please don't do two apps which listen for each other, if the user willingly kills your service they usually have a reason and expect that your app is not working right until they restart it.
SimplicityApks said:
I believe there is no such way... otherwise android would be very insecure for malware that just does this . You can only restart your service once the user restarts your activity, there should not be another way (and START_STICKY for the system of course). And please don't do two apps which listen for each other, if the user willingly kills your service they usually have a reason and expect that your app is not working right until they restart it.
Click to expand...
Click to collapse
I have heard that a lot but does that mean that all the security apps available on the play store can be killed by the user? :what:
Sent from my SM-N9005 using XDA Premium 4 mobile app
Rick Clephas said:
I have heard that a lot but does that mean that all the security apps available on the play store can be killed by the user? :what:
Click to expand...
Click to collapse
Sure, why not? I could uninstall my firewall on my PC if I wasn't using Ubuntu and thus don't really need one
SimplicityApks said:
Sure, why not? I could uninstall my firewall on my PC if I wasn't using Ubuntu and thus don't really need one
Click to expand...
Click to collapse
Well that is a pitty. I really thought I had seen an app that could do that...
Sent from my SM-N9005 using XDA Premium 4 mobile app
Look this app says it can't be killed by task managers https://play.google.com/store/apps/details?id=com.domobile.applock
Sent from my SM-N9005 using XDA Premium 4 mobile app
Rick Clephas said:
Look this app says it can't be killed by task managers https://play.google.com/store/apps/details?id=com.domobile.applock
Click to expand...
Click to collapse
Just an idea, it might be possible when your app is a Device Admin with the APIs that you get with that. Though you have to read it yourself, I have no clue about how it works.
SimplicityApks said:
Just an idea, it might be possible when your app is a Device Admin with the APIs that you get with that. Though you have to read it yourself, I have no clue about how it works.
Click to expand...
Click to collapse
Thanks I will look at that. Most people have my app as Device Admin because that way it can't be uninstalled
Sent from my SM-N9005 using XDA Premium 4 mobile app
Well I found the solution.
When device admin is enabled the app can't be force-stopped or uninstalled. Then the user can only stop the service and then the onDestroy methode is called so then I can restart the service again. Tanks guys :thumbup:
Sent from my SM-N9005 using XDA Premium 4 mobile app

Change quick reply wordlist

Is there a way to change the standard quick reply word list?
Sent from my Nexus 5 using XDA Free mobile app
Get the WearResponses app. It will allow you to make any response you want And the latest version, can even scan your existing messages. To list for you your most used responses and add them to your quick response list in the app.
Sent from my Nexus 10 using Tapatalk
There's another app called "Coffee".

Categories

Resources