service

Unable to start receiver : Not allowed to start service Intent ; App is in background

馋奶兔 提交于 2020-04-30 08:46:22
问题 So I made an app that upon a button click sets up a repeating task using an Alarm Manager. In on create: Intent alarmIntent = new Intent(this, AlarmReceiver.class); servicePendingIntent = PendingIntent.getBroadcast(this, 0, alarmIntent, 0); On the button click: alarmManager = (AlarmManager)getSystemService(Context.ALARM_SERVICE); firingCal= Calendar.getInstance(); firingCal.setTimeInMillis(System.currentTimeMillis()); firingCal.set(Calendar.HOUR_OF_DAY, 1); // At the hour you want to fire the

startService与bindService的区别

こ雲淡風輕ζ 提交于 2020-04-24 03:32:21
Android执行Service有两种方法,一种是startService,一种是bindService。下面让我们一起来聊一聊这两种执行Service方法的区别。 1、生命周期上的区别 执行startService时,Service会经历onCreate->onStartCommand。当执行stopService时,直接调用onDestroy方法。调用者如果没有stopService,Service会一直在后台运行,下次调用者再起来仍然可以stopService。 执行bindService时,Service会经历onCreate->onBind。这个时候调用者和Service绑定在一起。调用者调用unbindService方法或者调用者Context不存在了(如Activity被finish了),Service就会调用onUnbind->onDestroy。这里所谓的绑定在一起就是说两者共存亡了。 多次调用startService,该Service只能被创建一次,即该Service的onCreate方法只会被调用一次。但是每次调用startService,onStartCommand方法都会被调用。Service的onStart方法在API 5时被废弃,替代它的是onStartCommand方法。 第一次执行bindService时,onCreate和onBind方法会被调用

Laravel5(Lumen)创建服务提供者Service Providers

半腔热情 提交于 2020-04-18 04:01:12
在搞新浪SAE的时候,把Lumen装上,需要实现Memcahce和Storage的实现,就用到了Lumen的服务提供者,看了下官方文档和查阅了一些资料,记录一下。(本文在Lumen中实现,Laravel中实现几乎差不多) 1、app\Http\文件夹下面新建Models文件夹,在Models文件夹下面新建Example.php文件,将app\Http\Models加入到composer.json文件中的autoload类自动加载 "autoload": { "psr-4": { "App\\": "app/", "App\\Http\\Models\\": "app/Http/Models/" } }, Example.php文件创建一个example类 <?php /* * example演示类 */ namespace App\Http\Models; class Example extends \Illuminate\Database\Eloquent\Model { public function sayHello() { echo "hello,this is a model say"; } } 2、app\Providers\文件夹中创建一个服务提供者ExampleServiceProvider.php。并注册Models中的example类 <?php /** *

How to make a synchronous call in angular 5?

蹲街弑〆低调 提交于 2020-04-10 09:17:27
问题 So, I was trying to get the solution of this problem. But, somehow I am unable to do so, May be because of the lack of knowledge in angular 5. This is my service: GetCurrentUserData(): Observable<ResponseData> { return this.http.get<ResponseData>(ApplicationURLS.GetCurrentUserInformation) .map(response => { return response; }); //.catch(error => this.handleError(error)); } This is my component: public GetCurrentUserInformation(): any { return this.loginService.GetCurrentUserData().subscribe

Kubernetes部署服务

橙三吉。 提交于 2020-04-07 07:24:12
基本流程为: 做image 并且push到private registry 创建replication controller 创建service 搭建nginx代理 测试 下面详述: 1. 制作image java基础image: FROM dockerimages.yinnut.com:15043/centos:7 MAINTAINER xuelun-infra morgan.wu@yinnnut.com ADD jdk-8u60-linux-x64.tar.gz /usr/local/ ENV JAVA_HOME /usr/local/jdk1.8.0_60 ENV PATH $JAVA_HOME/bin:$PATH Friend-Service镜像: FROM dockerimages.yinnut.com:15043/yinnut-java:0.1 MAINTAINER xuelun-infra morgan.wu@yinnnut.com ADD FriendService.war / ADD jetty-runner.jar / WORKDIR / VOLUME ["/var/log"] 2. 创建Replication Controller rc.yaml文件, 创建了2个friend的pod,设置replicas为2 apiVersion: v1 kind:

eclipse 搭建 spring 环境

谁都会走 提交于 2020-04-06 19:10:18
一、下载 Spring 下载地址: http://repo.spring.io/libs-release-local/org/springframework/spring 下载zip压缩包: 并解压。 二、在 Eclipse 呀 myEclipse 中开发 Spring 应用 1. 新建 java project 项目命名为 myspring 2. 为该项目增加 Spring 支持。添加用户库 spring4.0.6 和 common-logging 添加方法如下图: commons-logging-1.1.3.jar 3. 定义一个 Spring 管理容器中的 Bean (POJO) src\hsl\service\PersonService.java 代码如下: [java] view plain copy package hsl.service; public class PersonService { private String name; // name属性的setter方法 public void setName(String name) { this.name = name; } // 测试Person类的info方法 public void info() { System.out.println( "此人名为:" + name); } } 注: spring

System.DirectoryServices

隐身守侯 提交于 2020-04-01 07:47:59
可以的,ADSI, WMI, System.Directory, ABO等四种方式都可以操作 具体可以查看一下MSDN里的Web Development\Server Technologies\Internet Information Services SDK\IIS Programmatic Administration SDK\Using IIS Programmatic Administration,里面有很多例子。 不过你要确保访问A服务器上的asp.net的应用程序具有B服务器的IIS的管理权限。 下面这个是用System.DirectoryServices创建site和vitual directory的例子 Internet Service Providers (ISPs) that provide Web hosting services to customers, need to configure their IIS servers frequently. Some ISPs use forms to programmatically enroll new customers and add a new Web site or virtual directory for them. The new site or virtual directory can be

openstack实验环境搭建

巧了我就是萌 提交于 2020-03-31 12:06:18
Openstack实验文档 一、 base节点 1.1配置网络 vim /etc/sysconfig/network-scripts/ifcfg-eth0 1.2关闭防火墙和selinux systemctl stop firewalld systemctl disabled firewalld vim /etc/sysconfig/selinux ---------------------------将enforcing改为disabled 1.3搭建时间同步服务器 vim /etc/chrony.conf server ip地址 ##服务器地址 local stratum 10 ##取消注释 allow 网段地址 ##允许的网段 systemctl restart chronyd ##重启服务 systemctl enable chronyd ##自启服务 1.4搭建DNS服务 yum -y install bind ##安装软件 vim /etc/named.conf ##修改配置文件 options { listen-on port 53 { any; }; directory "/var/named"; allow-query { any; }; }; zone "." IN { type hint; file "named.ca"; }; zone "xiaoai

Spring 事务回滚机制

不想你离开。 提交于 2020-03-26 16:35:38
3 月,跳不动了?>>> 异常回滚示例 捕获异常,不抛出, 事物不能回滚!!! if(userSave){ try { userDao.save(user); userCapabilityQuotaDao.save(capabilityQuota); } catch (Exception e) { logger.info("能力开通接口,开户异常,异常信息:"+e); } } 2.捕获异常,抛出运行时异常,回滚。当一个方法出错,另一个方法必然回滚 if(userSave){ try { userDao.save(user); userCapabilityQuotaDao.save(capabilityQuota); } catch (Exception e) { logger.info("能力开通接口,开户异常,异常信息:"+e); throw new RuntimeException(); } } 3.捕获异常,手动回滚 if(userSave){ try { userDao.save(user); userCapabilityQuotaDao.save(capabilityQuota); } catch (Exception e) { logger.info("能力开通接口,开户异常,异常信息:"+e); TransactionAspectSupport

Unreliable ScheduledExecutorService in Service

自古美人都是妖i 提交于 2020-03-25 18:46:28
问题 I created a ScheduledExecutorService in my Service that shuold run a runnable regulary. During debuging all it´s working fine. But on the smartphone the runnable is executed much later and the Service crashes occasionaly. The runnable is scheduled every 8-30 minutes. What can I do to make the Service more reliable? Are there better ways to realize this plan? (before I was using Thread and ExecutorService with nearly the same results). Here my current code: public class MyService extends