Tag: 服务

Oracle tnsnames.ora中SID与服务名称的区别

为什么我需要两个? 当我必须使用这个或另一个?

Python脚本作为linux服务/守护进程

你好, 我试图让一个Python脚本作为服务(守护进程)在(Ubuntu的)Linux上运行。 在networking上有几个解决scheme,如: http://pypi.python.org/pypi/python-daemon/ 一个行为良好的Unix守护进程是很难得到的,但是对于每个守护进程来说,所需的步骤都是相同的。 DaemonContext实例保存程序的行为和configuration的进程环境; 使用该实例作为上下文pipe理器来进入守护进程状态。 http://www.jejik.com/articles/2007/02/a_simple_unix_linux_daemon_in_python/ 但是,因为我想要集成我的python脚本专门与Ubuntu的Linux我的解决scheme是一个init.d脚本的组合 #!/bin/bash WORK_DIR="/var/lib/foo" DAEMON="/usr/bin/python" ARGS="/opt/foo/linux_service.py" PIDFILE="/var/run/foo.pid" USER="foo" case "$1" in start) echo "Starting server" mkdir -p "$WORK_DIR" /sbin/start-stop-daemon –start –pidfile $PIDFILE \ –user $USER –group $USER \ -b –make-pidfile \ –chuid $USER \ –exec $DAEMON $ARGS ;; stop) echo "Stopping server" /sbin/start-stop-daemon –stop –pidfile $PIDFILE –verbose ;; […]

当应用程序被终止时,Android后台服务正在重新启动

我正在开发一个应用程序,其中创build后台服务来收集传感器数据。 我从我的活动开始服务: startService(new Intent(this, MyService.class)); 我创build的服务,所以如果应用程序被销毁,后台服务仍然继续收集数据。 我尝试了这个,并在一定程度上起作用。 我的问题是,当我杀了应用程序,服务似乎重新启动,因为onCreate()服务和onStart()方法被调用。 请问有什么办法可以使服务不重启吗? 更新: 正如下面的答案中所build议的,我在服务中添加了以下方法,但没有运气。 @Override public int onStartCommand(Intent intent, int flags, int startId) { return START_NOT_STICKY; }

获取广播接收器/或服务中的GPS位置以广播接收器数据传输

我是新来的android。 我想在广播接收机中获取GPS位置,但是显示错误。 我的代码是: public void onReceive(Context context, Intent intent) { LocationManager locManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); // errors in getSystemService method LocationListener locListener = new MyLocationListener(); locManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locListener); Location loc = locManager .getLastKnownLocation(LocationManager.GPS_PROVIDER); Log.d(" **location**", " location" + loc.getLatitude()); } 问题: 广播接收机可以获取GPS位置数据吗? 另一种我迄今试过的方法是使用广播接收机调用的服务。 该服务可以获得GPS数据,但我怎样才能得到它在广播接收机?

Android语音识别连续服务

我试图创build一个服务来运行Android 4.2中的连续语音识别。 使用这个链接( Android语音识别作为Android 4.1和4.2的服务)的答案,我创build了一个从一个Activity运行的服务。 我的问题是,在handleMessage方法中访问mTarget.mAudioManager或mTarget.mSpeechRecognizerIntent时,我得到空例外。 目标(和从它创build的mTarget对象) 不是null ,但它里面的所有对象都是。 我在这里做错了什么? 相关的活动代码(从activity中调用的静态方法,activityContext是调用此方法的活动): public static void init(Context context) { voiceCommandService = new VoiceCommandService(); activityContext = context; } public static void startContinuousListening() { Intent service = new Intent(activityContext, VoiceCommandService.class); activityContext.startService(service); Message msg = new Message(); msg.what = VoiceCommandService.MSG_RECOGNIZER_START_LISTENING; try { voiceCommandService.mServerMessenger.send(msg); } catch (RemoteException e) { e.printStackTrace(); } […]

Android BroadcastReceiver,设备重启后自动运行服务

你好我正在写一个应用程序,这是当手机重新启动,服务将自动启动,而不是点击应用程序。 这是我的代码 BootCompleteReceiver.java package com.example.newbootservice; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; public class BootCompleteReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { Intent service = new Intent(context, MsgPushService.class); context.startService(service); } } MsgPushService.java package com.example.newbootservice; import android.app.Service; import android.content.Intent; import android.os.IBinder; import android.widget.Toast; public class MsgPushService extends Service { @Override public void onCreate() […]

如何从ServletFilter的ServletResponse中获取HTTP状态码?

我试图报告从我的webapp返回的每个HTTP状态代码。 但是,状态码似乎不能通过ServletResponse访问,或者即使我将其转换为HttpServletResponse。 有没有办法在ServletFilter中获得这个值?

通知服务的活动

我试图从我的Activity开始一个Service ,寻找在网页上的变化,这是一个私人的应用程序,所以我不打扰电池寿命… 但我想从我的Service传递数据到我的Activity …我似乎无法find一种方法来从我的Service调用Activity 。 我怎样才能做到这一点?

使用服务来运行后台并创build通知

我希望我的应用程序在单击button时启动服务,并且服务应该在后台运行,以在一天中的特定时间显示通知。 我有以下代码来做到这一点。 但它显示我不明白的错误。 我是Android的新手,这是我使用服务的第一个应用程序。 任何帮助,将不胜感激。 提前致谢。 AndroidManifest.xml中 <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.newtrial" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="18" /> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name="com.example.newtrial.CreateNotificationActiviy" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name="com.example.newtrial.ResultActivity" android:label="@string/title_activity_result" > </activity> <service android:enabled="true" android:name=".UpdaterServiceManager" /> </application> </manifest> CreateNotificationActiviy.java package com.example.newtrial; import android.os.Bundle; […]

Spring Boot应用程序即服务

如何configuration良好的Spring Boot应用程序打包为可执行的jar作为一个服务在Linux系统? 这是推荐的方法,或者我应该转换这个应用程序的战争,并安装到Tomcat? 目前我可以从screen会话运行Spring启动应用程序,什么是好的,但需要手动启动服务器重新启动后。 我正在寻找的是一般的build议/方向或示例init.d脚本,如果我的方法与可执行jar是正确的。