English 中文(简体)
改变从一项活动[复制]提供的服务中的分类
原标题:Change an Integer in a service from an activity [duplicate]

I need to be able to change the value of an Integer in a service while it is running, using an activity. How should I implement this? Any help or advice is appreciated.

最佳回答

你可以做的一件事是,通过你的活动,在你的工作中增加广播接收器。

来文:

  • 从活动中广播

  • Have your BroadcastReceiver (potentially in your service) listen to this broadcast from your activity and when it receives it, just update a member variable found in your service.

问题回答

假设你从你的客户开始提供开办服务,在较长时间内从事某些工作(例如开航),而客户则想以某种方式改变服务(例如使用优惠)。 然后,我建议你也能够约束服务(即有可能开始服务并约束服务)。

服从一项服务是难以利用强有力的转录器服务。 而且,建立当地服务(如果客户和服务在同一过程中运行)确实很简单。

(第二种选择是用新的参数再次使用起职服务,但如果这比对服务有约束力的要好,则取决于实际使用情况。)

即便是使用意向制作简单的短信也更容易产生错误,如果服务在电话中(低记忆状态)被杀,你就没有想法,因为除非你对服务状况负责,否则不会通知客户。 而且,与以往一样,没有保证开始服务将永远运作。 认为你的工作将被杀害;这只是需要多长时间的问题。





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

热门标签