English 中文(简体)
如果我开始在活动、完成(活动)之后再开始,会发生什么情况?
原标题:What happens if I startService from onCreate in Activity, finish() the Activity and then start the app again?

I am trying to figure out how Android works when it comes to lifecycle issues.

I have decided to have a long-running Service to hold my TCP-connections and other stuff.

我有一个活动,即启动活动。 这项活动开始提供服务,然后,我用一个顿子来否认这项活动。 然后,我再次提出同样的建议/行动,从而再次执行开办服务。

然而,我预计该处仍然活着(没有被叫到底),但该处仍在采用加泰特方法。

为什么?

www.un.org/Depts/DGACM/index_spanish.htm

@Override
protected void onCreate(android.os.Bundle savedInstanceState) 
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.startup);

    startService(new Intent(StartupActivity.this, SamcomService.class));
    registerReceiver(connectionReceiver, new IntentFilter("STARTUP_PROGRESS_MESSAGE"));
    registerReceiver(connectionReceiver, new IntentFilter("STARTUP_FINISH"));

    final Button button = (Button) findViewById(R.id.buttonExit);
    button.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            finish();
        }
    });
}

<>STEP> 2 我向纽芬兰报到,并叫作活动。

<>STEP> 3) 我再次发出信号,活动现场再次被执行,从而启动同一服务。

现在,当我开始第二次工作时(,我检查了)。 我亲眼看到了在被叫作消防局时所展示的Toast,我也看到该处所创建的通知(并去除)。

然而,该地国第二次被处决。 现在我是否有不止一个部门同时运作?

最佳回答

然而,该地国第二次被处决。 现在我是否有不止一个部门同时运作?

No, and I know this is confusing, but the startService() method does not start the service. It will be called in the service everytime you run it. For instance, if the service isn t started, it will start it and then run it. If the service is started, it will just run it. The android documentation says it was designed this way so that the startService() method is the easiest way to communicate with your service.

STEP2:我向县报到,并叫作活动。

这取决于你的工作是否与你的活动一样。 如果你有:处理面 = 显示的你的服务申报中“有点”的,而且你做了一切,这种服务又是另一个过程,只有三个地点将销毁你的服务。 页: 1 几乎保证不会因为你的工作具有积极的优先事项而发生, 2 最低记忆,3个服务电话自封。

由于完成(Android)没有销毁你的 app(Android公司在用户回头的情况下将其放在记忆中),你的服务要么只是停顿(如果它处于同一过程),要么仍在运行(如果它处于不同的过程)。 不管再一次要求开始服务,如果有人暂停服务,则将重新启用。 你们只得到你们的服务。

问题回答

暂无回答




相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...