基本上我有一个运行整个项目的Main类.代码工作正常但是一旦App没有聚焦它变得不活跃.我想知道如何将它作为一项服务.一个会在启动时启动.
该应用程序将是用于通知的单向消息系统.IE
桌面客户端 - > Openfire服务器 - > Android XMPP服务 - >存储(DB) - >用于显示的Android GUI
正如我所说,代码正在运行(连接,登录,接收),但不是服务.
我可以使用BEEM源,但它太功能和隔行扫描.我是一个轻量级的服务.
代码:
public class MainActivity extends Activity {
public static final String HOST = "fire.example.com";
public static final int PORT = 5222;
public static final String SERVICE = "example.com";
public static final String USERNAME = "metest@fire.example.com";
public static final String PASSWORD = "mepass";
private XMPPConnection connection;
private ArrayList<String> messages = new ArrayList<String>();
private Handler mHandler = new Handler();
private ListView listview;
/** Called when …Run Code Online (Sandbox Code Playgroud) 有人可以解释这些登录LogCat.它真的很烦人,我在谷歌上找不到任何关于它的东西.
这在模拟设备上不会发生,但它发生在我的Galaxy S3上.
日志示例如下:
03-07 15:15:09.480: E/Trace(4912): error opening trace file: No such file or directory (2)
03-07 15:15:09.565: D/TextLayoutCache(4912): TextLayoutCache::replaceThai, prevBuffer[0] is 74
03-07 15:15:09.565: D/TextLayoutCache(4912): TextLayoutCache::replaceThai, prevBuffer[0] is 74
03-07 15:15:09.565: D/TextLayoutCache(4912): TextLayoutCache::replaceThai, prevBuffer[1] is 61
03-07 15:15:09.565: D/TextLayoutCache(4912): TextLayoutCache::replaceThai, prevBuffer[0] is 74
03-07 15:15:09.565: D/TextLayoutCache(4912): TextLayoutCache::replaceThai, prevBuffer[1] is 61
03-07 15:15:09.565: D/TextLayoutCache(4912): TextLayoutCache::replaceThai, prevBuffer[2] is 43
03-07 15:15:09.570: D/TextLayoutCache(4912): TextLayoutCache::replaceThai, prevBuffer[0] is 21
03-07 15:15:09.570: D/TextLayoutCache(4912): TextLayoutCache::replaceThai, prevBuffer[0] is 21
03-07 15:15:09.570: D/TextLayoutCache(4912): TextLayoutCache::replaceThai, prevBuffer[1] is 64 …Run Code Online (Sandbox Code Playgroud)