从android中的服务器连续获取数据

时间:2016-09-28 05:40:29

标签: android android-service

我正在从我的活动开始提供服务。这是我的代码:

 protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        startService();
    }
    // Method to start the service
    public void startService() {
        startService(new Intent(getBaseContext(), Service.class));
    }

    // Method to stop the service
    public void stopService() {
        stopService(new Intent(getBaseContext(), Service.class));
    }

如果有任何文件随时上传到服务器,我该如何启动服务?

0 个答案:

没有答案