jjzjj

stopservice

全部标签

android - stopService(intent_with_extras) - 你如何从服务中读取这些额外内容以停止?

我有一个可以通过多种方式停止的服务。每当我调用stopService(Intent)时,我都会传递一个带有一些额外内容的Intent。您如何检索这些额外内容?谢谢。 最佳答案 您需要覆盖onStartCommand()在你的Service这就是您如何从startService获取对传入Intent的引用.在这种情况下,您的Intent中会有一个特殊的操作来告诉服务自行停止。您为此Intent添加了额外内容,可以在onStartCommand()中阅读方法。示例代码publicclassMyServiceextendsService{

android - stopService() 会停止前台服务吗?

将stopService()停止作为foregroundservice运行的服务?它似乎胜过前台服务的重要性,但也“感觉”到它胜过前台服务的重要性。 最佳答案 已确认:是-正在运行stopService()来自Activity服务外部将停止服务——即使该服务是前台运行的服务。 关于android-stopService()会停止前台服务吗?,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questi

android - 我需要为 Android 服务调用 unbindService 和 stopService 吗?

在我的Android应用中,我同时调用startService和bindService:Intentintent=newIntent(this,MyService.class);ServiceConnectionconn=newServiceConnection(){...}startService(intent)bindService(intent,conn,BIND_AUTO_CREATE);稍后,我尝试同时unbindService和stopService`:unbindService(conn);stopService(intent);但是,我在调用unbindService时

android - 我需要为 Android 服务调用 unbindService 和 stopService 吗?

在我的Android应用中,我同时调用startService和bindService:Intentintent=newIntent(this,MyService.class);ServiceConnectionconn=newServiceConnection(){...}startService(intent)bindService(intent,conn,BIND_AUTO_CREATE);稍后,我尝试同时unbindService和stopService`:unbindService(conn);stopService(intent);但是,我在调用unbindService时

android - stopService 不会停止我的服务.... 为什么?

我的androidAPP上有一个后台服务,它正在获取我的GPS位置并将其发送到远程数据库。它工作正常。问题是当我想停止服务时......它不会停止:S。logcat上也没有出现异常或错误......它根本不会停止。这是启动我的服务的代码(带有按钮):startService(newIntent(GPSLoc.this,MyService.class));//enciendoelservice这是我停止它的代码(在onactivityresult方法上):stopService(newIntent(GPSLoc.this,MyService.class));我已经调试了这个应用程序,并且

android - stopService 不会停止我的服务.... 为什么?

我的androidAPP上有一个后台服务,它正在获取我的GPS位置并将其发送到远程数据库。它工作正常。问题是当我想停止服务时......它不会停止:S。logcat上也没有出现异常或错误......它根本不会停止。这是启动我的服务的代码(带有按钮):startService(newIntent(GPSLoc.this,MyService.class));//enciendoelservice这是我停止它的代码(在onactivityresult方法上):stopService(newIntent(GPSLoc.this,MyService.class));我已经调试了这个应用程序,并且

android - 调用 stopService 方法时服务不会停止

我目前有一个服务,当我启动它时运行良好,但是当我尝试使用stopService方法停止它时,它的onDestroy方法不会被调用。这是我用来尝试停止服务的代码stop_Scan_Button=(Button)findViewById(R.id.stopScanButton);stop_Scan_Button.setOnClickListener(newView.OnClickListener(){publicvoidonClick(Viewv){Log.d("DEBUGSERVICE","StopButtonpressed");Intentservice=newIntent(Cicer

android - 调用 stopService 方法时服务不会停止

我目前有一个服务,当我启动它时运行良好,但是当我尝试使用stopService方法停止它时,它的onDestroy方法不会被调用。这是我用来尝试停止服务的代码stop_Scan_Button=(Button)findViewById(R.id.stopScanButton);stop_Scan_Button.setOnClickListener(newView.OnClickListener(){publicvoidonClick(Viewv){Log.d("DEBUGSERVICE","StopButtonpressed");Intentservice=newIntent(Cicer

android - 如何从调用 Activity 类调用Service类的stopservice()方法

我正在尝试从我的Activity中调用我的服务类的stopService()方法。但我不知道如何从我的Activity类中访问stopservice方法。我有下面的代码,但它不工作............ThisisHomeScreenclass:publicvoidonCreate(BundlesavedInstanceState){super.onCreate(savedInstanceState);setContentView(R.layout.main);enablecheck=(CheckBox)findViewById(R.id.enablecheck);enableche

android - 如何从调用 Activity 类调用Service类的stopservice()方法

我正在尝试从我的Activity中调用我的服务类的stopService()方法。但我不知道如何从我的Activity类中访问stopservice方法。我有下面的代码,但它不工作............ThisisHomeScreenclass:publicvoidonCreate(BundlesavedInstanceState){super.onCreate(savedInstanceState);setContentView(R.layout.main);enablecheck=(CheckBox)findViewById(R.id.enablecheck);enableche
12