Win a copy of Java Challengers this week in the Java in General forum!

Johannes Thorén

Ranch Hand
+ Follow
since Nov 18, 2008
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Johannes Thorén

Is there some way to integrate sound to a phonecall?

Like playing a song in the background of a phonecall or something like it?

Kind regards,
Drace
9 years ago

Przemek Boryka wrote:Hi !

I tested it on real device not emulator, try to deploy application on mobile device, I don't know, maybe emulator doesn't have default Ringtones, I am not sure. Try to export your programme to apk and by USB copy it on mobile device and install it.

:/ Good luck

Bye

Just now, I have tested the same code on emulator, it doesn't work for me. I think the emulator do not handling sound system. But I am not sure. :/




I found the problem. The ringtone was set to silent since there was no ringtones in the emulator.
I had to push a mp3-file to the sd-card and set it as ringtone. Now everything works!
9 years ago

Przemek Boryka wrote:Hi!

I wrote two lines of code :



After running the programme I have heard sound, so I think you don't have default ringtones at "content://settings/system" or you made something wrong.

Try put those two lines in new empty android project and test it. You should hear sound.




Doesint work for me, it should be possible to play the alarm on the eclipse emulator right?
9 years ago
I'm trying to make a simple alarm clock. But i cant get the alarm to ring..

This is my method:



Does anyone know whats wrong? I keep googling but I only get a lot of message-alarm-problems. Or mp3-play/video-stream problems.
This is the error:

03-08 14:54:27.671: D/MediaPlayer(472): Couldn't open file on client side, trying server side
03-08 14:54:27.680: E/MediaPlayer(472): Unable to to create media player
03-08 14:54:27.680: E/RingtoneManager(472): Failed to open ringtone content://settings/system/alarm_alert


Thanks in advance,
Johannes
9 years ago

Eric Pascarello wrote:

That code is wrong.

First it is onload and not onLoad.
It is saying execute the function extendSearch and store whatever it returns to onload.

If your code was window.onLoad = extendSearch;, it would not of run.

Eric



But the method still runs, and if i change it to onLoad or onload, gives the same result

Bear Bibeault wrote:Right now, it looks like you are getting the language value from the parameters. Rather, once you know it, store and retrieve it from the session



Is that possible to do in a Spring project, the language works perfect between pages, exept for my interceptor. Since that url is set in an xml file.

How can i reach the session to save it?

Kind regards,
Drace
9 years ago
JSP


I got this code in my .jsp page. The intent is to add ?language=en to the url, for example. But the method seems to be called all the time so the url just builds
?language=en?language=en?language=en?language=en.. and so on.

How could i solve the problem?

kind regards,
Drace

Bear Bibeault wrote:Store the language selection in the user's session.



Could you be more specific please, I'm a total newcommer on this area. The code i have in my JSP-files right now are:






And then everything with dynamic language presented like:


9 years ago
JSP
I fixed the language problem, but one issue still remains. Now when i change the language using JSTL it changes for the webpage that i'm on. How can i make the language selection to be implementet on every page, when i brows to other pages on the same site?

I guess there must be some kind of way to send a value between pages and when the next page is about to load, checks "what language?".

Kind Regards,
Johannes
9 years ago
JSP

Kumaravadivel Subramani wrote:You may have two different property files to be served based on the language change. The same behavior is being followed in frameworks like struts. It would not be a recommendation to use same file for different language.



I found a solution using propertyfiles.
Awesome! :-)
9 years ago
JSP
I'm facing a problem where i have to internationalize a web service.

I have x number of .jsp files, where i present for example:

"Enter your surname:"
"Enter your e-mail".. and so on.

And i wonder if there is any simple way to change language by for example clicking a button.
The krux is that i have to use the same file, so I'm thinking, maybe there is a way to have 2 files with properties, same name of the properties
but the value is on 2 different language, and then when you click the button you simply read the properties from one file or the other?

Is this possible, if so, how do i implement it? :-)

Kind regards,
Drace
9 years ago
JSP

Paul Clapham wrote:

Johannes Thorén wrote:The program works perfect if i use a list with lets say 20 words.



I'm surprised. It looks to me like you're only putting half of the words into the list. But I suppose that testing wouldn't really expose that sort of error, since selecting random items from half of the words is almost indistinguishable from selecting random items from all of the words.



Yeah i think its more of an iterationproblem. Changed the code to this:



Since i only need one word for the game, i thought of reading just one word from the file. (altho i'm going to have to deal with the problem of encrypting every word on the file later). But it still just keeps loading and loading.>
9 years ago

Jeff Verdegan wrote:No, you don't actually need to read the whole thing into memory at once. Depending on your specific requirements, there are different approaches you could take. However, if you want to start with the simple approach of just reading it all in, then you have two options:

1) Increase the JVM's max available heap at startup time with the -Xmx option. For example, java -Xmx 512m -cp whatever Myclass

2) Start with a smaller file--much, much, much smaller--until you've verified that the logic of your program is correct. This is a good idea regardless of what approach you finally decide on, as it will make testing much simpler.



The program works perfect if i use a list with lets say 20 words. It's a hangman game, but the wordlist have like 400k + rows. A part of my task is to encrypt and decrypt all words in the file (seperate program).

But then in the game i need to read in all words, choose a random word for the game, decrypt it and present it to the player.
9 years ago
I'm trying to put about half a million strings into a linkedlist.
Im reading using bufferedReader, but it just keeps loading and nothing happens, or at best i get a java heap memory error.

Here's the code i use:



Any idea how i could solve the problem? I need every line to be read since i have to choose a random word for the game.
9 years ago
For some reason my byte[].toString() does not result in a string that represents the content of the byte array. I got this code:


I get this as output: [B@1732a4df


But when i do this, it works:

I get this output: start_game


This is the code that creates msg:


Does anyone know why my byte array does not result in the string "start_game" when converting with toString() ?
9 years ago