English 中文(简体)
如何使用服务?
原标题:How to use service?
  • 时间:2011-11-02 10:02:23
  •  标签:
  • android

我正在执行一些法典,我希望定期加以管理(一段时间后进行重新更新......)。 我决定与警报管理员接洽,因为我知道,我们能够利用等待的意图,要求其他人代表我们做一些工作。 在此,我开始使用警报管理员。

intent = new Intent(AutoUpdateActivity.this, AlarmService.class);
pI =  PendingIntent.getService(AutoUpdateActivity.this,0, intent, 0);
alarmManager.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,firstTime,10*1000,pI);

我的服务在每10个秘密之后,也受到罚款。 我现在结束我的发言。

pI.cancel();

这也是工作上的罚款,我的服务不再继续。

但是,当我去找和检查管理服务时,我仍然显示,服务是运行的。 在什么地方我错了? 我有什么误导?

为了方便我的解决办法,我停止了我这样的服务。

pI.cancel();
stopService(intent);

this cancel pI as well as stop service,but I am not sure is this correct way. so kindly share your knowledge and let me know where i am going wrong.

最佳回答

这样做的最佳途径是在其工作完成后,在您的服务范围内打上<条码>。 在不需要服务的情况下,这将有效地关闭。

如果服务完成就立即关闭,你就不太可能获得第三方工作队的帮助。

问题回答

或许你也可以试图取消既定任务,包括:

alarmManager.cancel(pI);




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

热门标签