Help with scanner object - Vibrant Q&A, Help & Troubleshooting

I no I should post in some java forum but I don't know any and I need to get this program done by tonight
I want to reuse a scanner object that I have already used, so in this case I used the nextLine() method but know I want to use the next() method on the original input, so if the console input was "hello xda" I want to use the nextLine method to the whole line, and the next()method to just get the first part
Basically is their anyway I can reuse a scanner object twice on the same input
Sent from my SGH-T959 using XDA App

There's probably a simpler way but maybe just assign the your scanner input from the nextLine() method to two different strings and run next() on the other one to get the first token.

I got the first word into a string by using the substring method but I still have the original problem because I need to use the hasNext() to see if the user inputs 2 or 3 words
Thanks for the help
Sent from my SGH-T959 using XDA App

Related

[APP] Caesura remote administration/ parental control/practical joke app BETA R1

Hey everybody, I am posting this here cause I just built a new parental control, remote administration and practical joke app for Android called caesura. Caesura is a remote administration app that allows an Android phone to be controlled via SMS messages, in much the same was as one can post to Facebook via SMS.
By sending the !login command to the phone in question and then texting back the password, you can signal the phone to start listening for commands. These commands include panic (turn up the volume all the way and ring and flash lights to help find lost phone), status (find out how much battery life the phone has left and get other info), contacts (in case you forgot your phone at home, u can still access your address book), block (block all SMS messages from specified number, useful for parental control),.and many more.
Like I said, this is just a beta so I'm open to any suggestions
The app can be downloaded from this page on my website:
http://www.gundersoft.com/pages/downloads/caesura
As of yet this work is beta...it doesn't have decent instructions...these are forth coming. For now, the three commands you need to know are as follows: !login logs in to the remote phone. Help command (replace command with the name of a command you need help with) gives help related to command usage, and exit logs you out of the remote phone. Make sure you always use the exit command when finished! You cannot send any texts to the remote phone from the phone you used to control it while logged in.
for a list of the available commands, use the "login to another phone" button to control the phone instead of SMS. In this console there is a drop down menu containing all of the commands.
Finally, for the sake of research, every copy of this app "calls home" the first time it launches to register the version number so I can keep track of roughly how many of each version of caesura out in the wild lol.
Tell me what you think of all of this!
Sent from my MB860 using XDA App
Need to move this to the apps forum. This is the rom development forum. I will give this a try though, thanks for sharing.
Sent from my MB860 using xda premium
Oops, Sorry
Sent from my MB860 using XDA App
ur android market link is not working
https://market.android.com/developer?pub=Gundersoft+Studios

Tasker help question?

I have my work wifi which to fully connect to it I have to open a browser and basically click a connect button to be fully connected, is there a way to automate this in tasker?
Sent from my Galaxy Nexus using Tapatalk 2
I wrote one answer below. It's still an option, but you may be better investigating this first....
Under "Net," there are HTTP-Get and HTTP-Post actions. I'm not an HTTP expert, but I would suggest dissecting the gateway webpage to see if you can use these actions to get through.
------------- First thought ----------------------------
Is your device rooted?
If yes, then you might try the "Type" action in the Input actions. The documentation is very limited, so I don't know what you can and can not generate. I'm automating websites on Windows using Autohotkey, and Enter is the "best" character for hitting website buttons. I don't know if you can generate special characters from the Type action.
Detecting when to issue the Type action is another matter. A timer delay is simple to do, but "dumb" with respect to the website status.
Thanks for the reply I'll look at dissecting the the page.
Sent from my Galaxy Nexus using Tapatalk 2

[Q] onSizeChanged (dev Question)

I want to know the sizes of view is my app. Most forums say override the onSizeChanged method, but Netbeans isn't finding the method to override like it usually does. How can I get it to?
why not use eclipse? it can quickly find and auto generate the method related code that you mention
Wrote lots of custom views, and never had any issue with onSizeChanged(). Except that Android can be tricky on you and calling it with height and width set to zero if the layout has not been completed by the inflater (then just wait for another callback with non-zero values.)
Using Eclipse.
Alright guys. I'll betray my first Java IDE for Eclipse. =P
I should have done it earlier. This isn't my first problem for not using Eclipse.

[Q]Get hardware-key-event while in background

Ever since I got my Droid 3 I wanted to be able to control games using the keypad, but sadly most games won't support it, so I figured, it would be cool if I could make an app that catches all the keyboard events and triggers fake MotionEvents for preset regions of the touchscreen (kindof how it's done on the iControlPad).
I believe I've found a way to fake the touches, but when searching for a way to read keyboard events when my app doesn't have the focus all lead to dead ends.
Does anybody have a clue how I could do that?
If anyone cares: I not only managed to find a way to read out all the touches and keystrokes that should go to other apps (though some android-coworker said it was impossible), but I can also filter which one of those I let through. I can even block the back- and home-buttons. And it's runnable without any running service or activity, so invisible and unkillable. I don't need most of that for my app, so I won't use what I don't need, I just stumbled across it by accident.
Every threat on this topic ended with "It's impossible to read out keystrokes destined to another app, because it would be too much of a security issue." Well, it is possible.
Sent from my XT860 using xda app-developers app
Dakkaron said:
If anyone cares: I not only managed to find a way to read out all the touches and keystrokes that should go to other apps (though some android-coworker said it was impossible), but I can also filter which one of those I let through. I can even block the back- and home-buttons. And it's runnable without any running service or activity, so invisible and unkillable. I don't need most of that for my app, so I won't use what I don't need, I just stumbled across it by accident.
Every threat on this topic ended with "It's impossible to read out keystrokes destined to another app, because it would be too much of a security issue." Well, it is possible.
Sent from my XT860 using xda app-developers app
Click to expand...
Click to collapse
I do care! I would appriciate to hear how this works, because I would need it for my ongoing development.
Besides Camara button, which is of cause easy due to the broadcast event, and the volume keys (which are more tricky, since you have to inject an own BroadcastReceiver to the AudioManager), how do you handle other keys?
Ok, it's been a while since I did this, and I had a lot of work on other projects in between so, I hope I get everything right.
To do the whole trick you need root access.
1) Get the android.permission.SYSTEM_ALERT_WINDOW permission
2) Open up a system alert window with no content. There is a setting somewhere that lets you catch all keystrokes and touches. This blocks them all from going through
3) This one is tricky. I had to analyse nonsense for days to get it right, and I fear it's still not very good. Go to /dev/input on your phone. There are files named event1, event2, ...
Each of those correspond to one input device, so one is your touchscreen, one is the keyboard and so on. What you do now is you perform the action you want to recreate on the phone (e.g. press a key) and monitor the event files through adb (there is a linux command, that I forgot, that lets you view a file in real time. Also you can copy that real time view to your harddrive by typing "adb shell [command] > record.txt").
Once you know every event that you want to recreate, you can go to the next step.
4) This is what your app has to do to let a keystroke through: The user presses a key, your app catches it. Then it changes it's mode (see 2) ) to not catch any keystrokes at all, posts the corresponding event for that key in the fitting /dev/input/eventX-file, and sets itself to catch keystrokes again.
Before the whole thing make sure, your /dev/input/eventX-file has a chmod of 666 or therelike, since you can't write into it from your app. You only need root for that, after that you don't need root. The OS resets the chmod on each reboot.
It is a hell of a lot of work. Calculate about a week or more for just that (at least that was what it took me to figure it all out). Good luck
PS: If you get your app system privileges, there is also the android.permission.INJECT_EVENTS, which allows you to inject key- and touch-events to another app using a simple function (can't remember it, but Google does). For your app to be able to get system privileges you need to copy it to /system/app, which requires root and a mounted /system. Catching the keystrokes still works the same way as above.
Dakkaron said:
Ok, it's been a while since I did this, and I had a lot of work on other projects in between so, I hope I get everything right.
To do the whole trick you need root access.
1) Get the android.permission.SYSTEM_ALERT_WINDOW permission
2) Open up a system alert window with no content. There is a setting somewhere that lets you catch all keystrokes and touches. This blocks them all from going through
3) This one is tricky. I had to analyse nonsense for days to get it right, and I fear it's still not very good. Go to /dev/input on your phone. There are files named event1, event2, ...
Each of those correspond to one input device, so one is your touchscreen, one is the keyboard and so on. What you do now is you perform the action you want to recreate on the phone (e.g. press a key) and monitor the event files through adb (there is a linux command, that I forgot, that lets you view a file in real time. Also you can copy that real time view to your harddrive by typing "adb shell [command] > record.txt").
Once you know every event that you want to recreate, you can go to the next step.
4) This is what your app has to do to let a keystroke through: The user presses a key, your app catches it. Then it changes it's mode (see 2) ) to not catch any keystrokes at all, posts the corresponding event for that key in the fitting /dev/input/eventX-file, and sets itself to catch keystrokes again.
Before the whole thing make sure, your /dev/input/eventX-file has a chmod of 666 or therelike, since you can't write into it from your app. You only need root for that, after that you don't need root. The OS resets the chmod on each reboot.
It is a hell of a lot of work. Calculate about a week or more for just that (at least that was what it took me to figure it all out). Good luck
PS: If you get your app system privileges, there is also the android.permission.INJECT_EVENTS, which allows you to inject key- and touch-events to another app using a simple function (can't remember it, but Google does). For your app to be able to get system privileges you need to copy it to /system/app, which requires root and a mounted /system. Catching the keystrokes still works the same way as above.
Click to expand...
Click to collapse
Thank you for your innovative solution
I do not understand two points:
1. How does your app will stay on top and its windows receives events, when the user opens another app, a game for example.
2. How does the background app, the game, keep running? Isn't the game onPause() when you are running your app in front?
Thanks you.
Dakkaron said:
2) Open up a system alert window with no content. There is a setting somewhere that lets you catch all keystrokes and touches. This blocks them all from going through
Click to expand...
Click to collapse
Can you please try to remember and elaborate " a setting somewhere" part?

[Q] Tasker, Autovoice and yatse

id like to intergrate yatse voice control with tasker and autovoice. id like to be able to say "xbmc" and then have the yatse voice control pop up to open up.
taking it a step further, id like to be able to control xbmc using autovoice itself, for example, open the autovoice popup and say "i want to watch (movie)" and then the system does the rest.
simple in essence, however i cannot find the correct way to do it.
According to the developers if Yatse themselves you should be able to accomplish this with the API.
http://yatse.leetzone.org/redmine/projects/androidwidget/wiki/Api
Not sure but you could try to send an intent with Tasker. Try this for playing a movie:
Profile:
Autovoice recognize:"xbmc"
Task:
Send intent
Action: org.leetzone.android.yatsewidget.ACTION_APP_VOICECOMMAND_PARSER
Extra: org.leetzone.android.yatsewidget.EXTRA_STRING_PARAMS:%avcommnofilter
Target: Service
The %avcommnofilter contains whatever you said after the trigger. Which is 'xbmc' in this case. So the command "xbmc play <movie>" would send org.leetzone.android.yatsewidget.EXTRA_STRING_PARAMS: play <movie> to yatse.
As for play, pause or stop you would use the MEDIA_COMMAND instead of the PARSER.
Let me know if it works. If not, maybe someone else can shed some light. I quite like the idea you've got there.
I don't know what i might be doing wrong, but i tried doing this and i'm not able to get this to work. Is there some special settings i need to have setup on xbmc/yatse?
Update: I got it figured out. Was doing something wrong, but all is good now.
What did you do to get it working.... using the sample above not getting anying
clayboy said:
What did you do to get it working.... using the sample above not getting anying
Click to expand...
Click to collapse
You need to take the spaces out of the action and extra lines. For some reason xda adds them, They aren't needed and are what's screwing it up if you do a direct 1:1 copy of the lines.
stearic said:
You need to take the spaces out of the action and extra lines. For some reason xda adds them, They aren't needed and are what's screwing it up if you do a direct 1:1 copy of the lines.
Click to expand...
Click to collapse
i typed it out without spaces and still unable to play a movie
clayboy said:
i typed it out without spaces and still unable to play a movie
Click to expand...
Click to collapse
Do you have the premium version of yatse?
stearic said:
Do you have the premium version of yatse?
Click to expand...
Click to collapse
yeah... I finallly got it by copying and pasting... just outrageous i spent hours trying to get it to work.... lol... thx now to get tasker to control my amp from avr romte... oh boy:good:
Yea, i spent a few hours only to find out that something didn't copy or paste right so it was all screwed up because of that.
Control XBMC from Tasker & AutoVoice
You know, you can take this one step further and actually control XBMC directly from an AutoVoice command just as you were seeking.
Here's how to do it... http://kinkeadtech.com/2014/08/control-xbmc-from-tasker/

Categories

Resources