如何保持FTP连接(或任何连接对象)活活动之间 [英] How to keep FTP connection (or any connection object) alive between activities

查看:429
本文介绍了如何保持FTP连接(或任何连接对象)活活动之间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编码在我的应用程序的顶部一个非常基本的FTP客户端,我有2个活动。第一个是在文件浏览器,第二个是图像查看器。当我点击图像文件名的探险家,我想通过连接到其他活动来处理额外的东西。基本上,我想保持相同的 org.apache.commons.net.ftp.FTPClient 对象(它处理的连接)活着之间的2的活动。我知道我不能传递一个对象的意图里面,所以我不知道什么是我最好的投注。

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.

感谢。

推荐答案

扩展YOUT应用程序类和code FTP连接出现,每次你需要使用它拨打报名时间

Extend yout application class and code the ftp connection there, every time you need to use it call the Application

public class FtpConnect extends Application {

//FTP CODE

}

在任何你需要使用它

where ever you need to use it

FtpConnect singleFtpHandler = (FtpConnect) CurrentActivityClass.this.getApplication();              
singleFtpHandler.method();

您需要将appExtender名称添加到您的清单如下:

You need to add the appExtender name to your manifest like this:

<application android:icon="@drawable/icon" android:label="@string/app_name" android:name=".FtpConnect">

这篇关于如何保持FTP连接(或任何连接对象)活活动之间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆