English 中文(简体)
在将不同活动视为不同活动时,服务仍受主要活动的影响
原标题:Service still bound to main activity when pressing home button, when viewing different activity

因此,申请表I ve书面有一项服务(跟踪全球定位系统数据),其中一项主要活动对其具有约束力,其编号为) 方法,以及其<代码>onStop( > 采用<代码>unbind Services(serviceConnection)的服务中的未并入。

我也开展了一项活动,这是一次选择,通过在主要活动上建立一个纽扣地启动。 在这种选择筛选方面,我有一个检查箱,即“处于背景的Run”,如果真的,这意味着当用户离开申请时,该服务机构将继续运行,而不是将全球定位系统移走。

我通过打电话this.startForeground on Unbind,和this.stopForeground onRebind,如果该词的确定是真实的,则请打电话给on UnbindonRebind,如果该词是假的,则分别拦截和启动我的所在地读码<>。

如果该服务是在这种背景下运行的,它也会发出通知,以确保用户了解全球定位系统仍在运行和耗尽其权力。 这一通知通过依赖<条码>启动/code>和<条码>停用>。

因此,问题在于,如果我看一看各种选择,我就希望服务保持下去,而我不想看到这一通知。 因此,如果我打上 but子去接受选择的屏幕,那么我就树立了真正的旗帜,如果旗帜真的话,不会叫不白。

This works, except for one slight problem. If the user hits the home button while viewing the options screen, the service is not stopped if it is supposed to be (because it s still bound to the main screen), and if it is supposed to keep running, it does not display the warning notification (and of course, this means that the service is still considered to be in the background).

我应如何让这一申请成为我想要它的方式?

问题回答

因此,我刚刚找到了似乎行之有效的解决办法。 我将选择屏幕与Start(Start)方法中的活动联系起来,并将之重新纳入到桌面上。 以前的“Stop(Stop)”方法在采用新的“Resume(Resume)”方法后一直使用,因此该方法运行。

是否有更好的办法? 把某项活动与实际上需要获得的服务联系起来似乎令人sil笑.。





相关问题
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 ...

热门标签