How To Manage JSCH SSH Session Connection Across Classes
Jun 27, 2012
I have an Android application which connects to my desktop via SSH when I load it, it works fine. When I click a button on the interface on my phone, it sends a command through the SSH connection to be executed on my desktop, that works fine also. The problem is I have one class that opens the connection and sends all the commands through. I call this class from my onCreate method with button listeners.
So I have my class Init which opens the connection when the program starts, then I have a button listener for button_1 which calls
Code:
Init.send("mkdir "test_directory");
No problem, that works great but what if I want to have a button on another screen? How can I get the same Init object to maintain the open session with my desktop? If I create a new Init object in the other class it will reconnect on a new session but I want to use the same one.
So I'm wondering how I can (for example):
1. launch application, create Init object and call Init.connect(username, password, port, host)
2. click a button and use button listener to call Init.send("mkdir test_directory")
3. click a button and load a new screen with new buttons
4. this loads a new .java class with a new onCreate method to manage the new display with new buttons (is this necessary?)
------------everything works up to here--------------
5. click one of the new buttons managed by the new class but use the same session created in the original class from the original Android screen
To explain exactly what I'm doing, screen 1 has a button which loads screen 2. Screen 2 has a list of directories on the remote machine. Screen 3 has a list of directories inside the directory clicked on screen 2. I want to send a request for the directories on screen 2 using the Init object created from screen 1 which was displayed on launch.
View 2 Replies
Jun 21, 2010
I would like to know what is the recommendation for socket connection management in Android?In our App we would like to be connected to a TCP/IP server when our app is in the foreground or paused. So, create a connection to a TCP/ IP server when the App starts basically, On Create of the launcher activity. However, we do not want to create a new connection and close connection every time an activity is created, paused, destroyed or orientation changed. So, we save the connection object in the App class and the activities will reuse the same connection.Question is when do I close it? I would like to close the socket when the App is "paused", "stopped" or "destroyed". The problem is these messages are not sent in the App context. How can I figure out if the App is in foreground or not? Even the "Terminated" event for an App is not guaranteed to be delivered. So, in that case how do I know when to disconnect?
View 2 Replies
View Related
Nov 22, 2010
I just ran through the Unrevoked process, which ended in the software telling me, "This was a triumph". I am, however, unconvinced.I can not boot into any other recovery than the stock HTC recovery and therefore can not perform a Nand Back up or flash Unrevoked Forever.I'm running a newer Evo with 2.2, it has hboot 2.02 and is showing S-ON. Is this the problem?
View 34 Replies
View Related
Aug 25, 2010
This is a follow up question of http://stackoverflow.com/questions/3550593/sending-html-commands-over-httpclient-android , I have successfully Posted to the server and received 200 code but when I attempt to move to another page it does not recognize that I have logged in. I am wondering if it is a session issue or if i need to follow the redirect after the POST. How would I go about following a redirect?
View 1 Replies
View Related
Nov 19, 2010
I make an app with some activities.
The first is the login.
If I login correctly, I pass to the second activity, and I want download a stream (like twitter), but I cannot keep the session.
I saved user & pass in sharedpreferences, how can i keep the session through all activities?
View 1 Replies
View Related
Apr 9, 2010
I have an app that requires user to register. I've got the app conected to PHP in my server to do the logic of register/login and so, this is not problem at all.
But, I want to keep a session of the user in local, so the user doesn't have to login again every time he runs the app.
So, I want something like this:
First time user, he opens the app, register and login. Do some stuff with the app and closes it. Open the app again, the user is recognized so he doesn't need to login again.
I only need to store an ID and a Username (both fetched from the DB in the login php method). What's the best way to do this?
I've thought about doing a custom preference, store the data in files or even a local DB (sqlite).
View 1 Replies
View Related
Mar 15, 2010
The user must login through the WebView. Of course, the session is for that WebView.But, what if I need to make REST API calls during my Android application?Those REST API calls need the session to be authenticated , otherwise those will not work. Is there any way I can attach the cookies of WebView into everything I do in Android?
View 1 Replies
View Related
Jan 13, 2010
Can any one tell me how can we clear browse session history.We have api called Browser.ClearHistory(),this will delete entire records but i want to delete history of browsing session.
View 2 Replies
View Related
Mar 30, 2010
I've got a problem with my application when I make a number of requests using the HttpsUrlConnection class.
My program makes the first request using the HttpsUrlConnection class to retrieve a file. It then makes a second request to the same server to retrieve a different file. What happens however is that periodically I'm getting a -1 HTTP response code on the connection.
When the failure occurs between the two requests I see the following line of trace in logcat:
D/OpenSSLSessionImpl( 699): Freeing OpenSSL session
This seems to happen fairly consistently. If I retry the second request after it has failed it generally works and I get the requested file from the server.
Note that if I don't see the OpenSSL session being freed the second request works fine the first time.
Some other information:
1) I'm not calling disconnect on the connection
2) I'm don't always read the entire file from the server after the first request
3) I always close the InputStream in the event that I get an InputStream on the first connection
How to prevent the OpenSSL session from being freed.
View 2 Replies
View Related
Oct 28, 2010
I'm trying to avoid that when a user has connected to Facebook from my webview, the next time he do it, doesn't need to put the email and password. but doesn't work. That cookie I suppose that is not valid because the user has to put his username and his password again and after login, I get a different cookie that the one I had stored. What I'm doing wrong? Is there another way to accomplish that?
View 3 Replies
View Related
Feb 26, 2009
Ok I am at the end of my rope. I am doing some image processing. I have a large image file which I open and create a smaller bitmap from. At the end of processing I call recycle on everything. I null everything. I run GC manually.
I then try edit another image and I get an out of VM memory error. Bitmap exceeds etc etc.
I am looking at the heap and the secone edit doesn't seem to cause it to increase at all.
What else can I do. Surely google cannot possibly be suggesting that we can open one large bitmap per session and thats it?
View 16 Replies
View Related
Dec 13, 2012
Getting this in their notification tray? This has been happening once I turn my data back on after it being off to save battery. It also asks for you to log back in. Sounds like someone phishing so they can hack my accounts.
View 6 Replies
View Related
Jun 23, 2010
I am using Ksoap2-Android for consuming the WCF Services.
For the dotnet client we keep the allowCookies="true" in our binding configuration and it sends the same sessionid and keeps my sessions intact in my WCF services (My services are
interdependent and use the sessions).
Any one know any such setting for ksoap2-android, that will allow me to consume the
WCF service keeping my session intact on the server.
Currently when i make a new call to the service, the sessionid gets changed and all my
session variables clear out and loose their values.
View 1 Replies
View Related
Sep 25, 2010
Can anyone please recommend a training session/course for Android graphics API/OpenGL ES?
View 1 Replies
View Related
Aug 4, 2010
For example, I want my users to be able to click a button "Get new quote" which will start a new row in the the database for data to start being stored, but I'm unsure of how to store activity independent (or cross activity) data, like the _id of the row, which I will need to requery and update the row when new data becomes available on subsequent activities. What's the name of this mechanism and how is it done?
View 1 Replies
View Related
Dec 4, 2013
When I login to facebook app messenger shows me session expired.
When I login into messenger the main app logs me off.
So i cant have both apps logged in at once?
View 6 Replies
View Related
Oct 15, 2010
I'm developing an app using android 2.1. I have a problem with using session cookies to login to a RESTful web service. The code works fine on the emulator, but when I run it on my HTC Magic, the cookie logic doesn't work. I've confirmed that the magic is receiving cookies in the headers by listing them (see attached). Can anyone say why the cookie store would be empty even tho they are in the headers?
View 1 Replies
View Related
Apr 21, 2010
I'm writing an application consisting of several activities and, on restarts, I'd like the application to initially display the application's activity that was the last to display in the application's previous session.
I save information about the last activity in SharedPreferences and I'm trying to start that last activity with a call to startActivity(intent) from my Application's onCreate handler.
The problem is that if I don't set the intent's FLAG_ACTIVITY_NEW_TASK, the result is a run-time exception message in logcat suggesting that I should set the flag. And if I set that intent flag, the correct activity gets started but doesn't fully initialize resulting in null pointer exceptions (which don't occur when I don't attempt to start the activity from my Application class).
CODE:...........
Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?
How to correctly start a particular activity from the Application class's onCreate handler?
View 3 Replies
View Related
Jun 24, 2010
How come when m in a call session my 3g turns off? Is there a way to enable it to stay on while in call? Because id like to multitask.
View 5 Replies
View Related
Apr 23, 2010
The Facebook application that came loaded on my Droid has been working fine for 2 months. This afternoon, at first I couldn't access anything that had posted since this morning. Now I can't get anything at all. I keep getting an error message: "102/Session Key invalid or no longer valid" And it even happens when I try to go to my profile!
View 7 Replies
View Related
Jan 9, 2010
We're designing an Android app that has several activities which are working in a wizard like way - user should pass from the activity #1 to activity #5 to get to the final activity (#6).
Since we know an activity can be suddenly terminated by OS on low memory we used Application class as a static storage for keeping the data the user inputs on "wizard" activities and other data our app needs for the whole session.
Unfortunately we've discovered this approach fails - looks like the Application class instance is also can be killed by OS (this was specifically discovered on Android 1.6 versus 1.5). Are our expectations wrong on this approach (we think Application class instance always lives for the whole app session)?
So the question is - what is the best practices on Android to keep data between activities deathes/restarts for the whole application session?
View 2 Replies
View Related
Sep 7, 2009
If my screen locks while I have a wifi connection, then the connection is lost when I unlock the phone.First, is this perhaps deliberate, to save power? Also, either way, when I unlock the screen and go into wifi settings, I see that the phone is trying to make a wifi connection, but it never succeeds, even though it's my home network and I'm in the same room as the router. It just states 'Obtaining address.
View 10 Replies
View Related
Oct 14, 2009
I'm using ThreadSafeClientConnManager to manage a pool of client connections, because my application has several threads, which are simultaneously connecting to a webserver.
Abstract sample code:
CODE:..............
Now lets say on of this threads is downloading a large file, but then the user of my application is switching to another activity/screen. Therefor the file is needless and I'd like to abort this download connection.
In ThreadSafeClientConnManager I found this method: public ClientConnectionRequest requestConnection (HttpRoute route, Object state) Returns a new ClientConnectionRequest, from which a ManagedClientConnection can be obtained or the request can be aborted.
So far I've been using:
CODE:.........
Now from what I understand, I've to use:
httpclient.getConnectionManager().requestConnection(HttpRoute route, Object state);
And that's the point where I'm stuck. I assume that for the route I can just use new HttpRoute(new HttpHost("10.0.0.1")) or whatever my server is, but what to put in for Object state?
And second, as soon as I've the ClientConnectionManager I can call getConnection(long timeout, TimeUnit tunit). But then from there, how I do I execute my HttpGet httpRequest = new HttpGet(URL_TO_FILE); as I did before with HttpResponse response = (HttpResponse) httpclient.execute(httpRequest);?
I've been gone through the documentation and tried out quite a few different things, but I wasn't able to obtain a working solution. Therefor any suggestions and/or code examples are more than welcome.
View 1 Replies
View Related
May 12, 2010
Whenever a application needs internet and connection fails, I get a message dialog
Connection failed
This application requires network access. Enable mobile network or Wi-Fi to download data.
and two buttons, Settings, Cancel.
How do I detect there is no internet connection?
How do I popup a same dialog in my application?
View 3 Replies
View Related
Sep 15, 2010
Long time reader, first time poster here. How does one know if the Epic is using the wifi connection as opposed to using the 3G connection? When wifi is connected both that and the 3G connection shows at the top. So which one is in control per se? And how can it be verified?
View 3 Replies
View Related
Mar 31, 2009
I call WebView.clearHistory(), but I am still able to go back after doing so. I want to reuse a WebView, but I don't want the back button to allow the user to go back further than the current "session" of using the WebView. Anybody know what is the best way to handle this? I thought for sure that clearHistory() would do it.
View 3 Replies
View Related
Oct 29, 2010
I want to use the accessibility classes, but I'm a begginer in android programming and i can't understando how to use them. I don't find any example using these classes. Somebody can give me some use examples? Another thing Can I set enable the Accessility mode in the emulator?
View 2 Replies
View Related
May 18, 2009
I am writing a app, which has sort of plugin framework. public abstract class AbstractService {public abstract AbstractService getInstance(String name)..
View 2 Replies
View Related
May 29, 2009
I have an apk installed in /data/app. I want to use the class methods in there. Here is what I tried. code...
I got "ClassNotFoundException". By peeking into the apk, I don't see class files but classes.dex. I would assume SystemProperties class is in classes.dex. Why can I load it?
View 5 Replies
View Related
Oct 27, 2010
I'm coding a very basic FTP client on top of my application and I have 2 activities. The first one is the file explorer and the second one is the image viewer. Once I click on the image filename on the explorer, I want to pass the connection to the other activity to handle extra stuff. Basically, I want to keep the same org.apache.commons.net.ftp.FTPClient object (which handles the connection) alive in-between the 2 activities. I know I can't pass an object inside an intent so I don't know what my best bets are.
View 1 Replies
View Related