http://blog.csdn.net/wangliang198901/article/details/12342845

http://stackoverflow.com/questions/3856767/android-keeping-a-background-service-alive-preventing-process-death

http://www.cnblogs.com/cc-Cheng/p/3146143.html

调用

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.source_activity);
startService(new Intent(this, RunService.class));
}

定义

public class RunService extends Service {

@Override
public void onCreate() {
sendNotification();
}

private void sendNotification() {
Log.i("ss","____________________________sendNotification");
Notification notification = new Notification();
Intent notificationIntent = new Intent(this, ScreenRecorderActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
notification.setLatestEventInfo(this, "3DHome", "Welcome to 3DHome !", pendingIntent);
try {
startForeground(12314, notification);
} catch (Exception e) {

}
}
@Override
public void onDestroy() {
stopForeground(true);
}

@Override
public IBinder onBind(Intent intent) {
// TODO Auto-generated method stub
return null;
}
}

Android防止进程被第三方软件杀死的更多相关文章

  1. Android守护进程

    这几天,一位做Android的朋友和我探讨了一个问题:因为业务需求的原因,在自己的App长时间不使用被kill掉之后,如何让它再重新运行起来. 虽然,我本身很排斥这种做法,有点类似“流氓软件”的行为, ...

  2. Android内存进程管理机制

    参考文章: http://www.apkbus.com/android-104940-1-1.htmlhttp://blog.sina.com.cn/s/blog_3e3fcadd0100yjo2.h ...

  3. Android如何降低service被杀死概率

    http://www.jianshu.com/p/06a1a434e057 http://www.cnblogs.com/ylligang/articles/2665181.html Android应 ...

  4. Android的进程和线程(转)

    进程和线程 当一个应用程序第一次启动的时候,Android会启动一个Linux进程和一个主线程(即UI线程:主要负责处理用户的按键事件.触屏事件及屏幕绘图事件等).默认情况下,所有该程序的组件都将在该 ...

  5. 第11讲- Android中进程及其优先级

    第11讲Android中进程及其优先级 进程与线程: 进程:操作系统结构的基础,资源分配的最小单元,一个操作系统包括多个进程: 线程:线程存在于进程当中,是操作系统调试执行的最小单元,一个进程包括多个 ...

  6. android中跨进程通讯的4种方式

    转自:http://blog.csdn.net/lyf_007217/article/details/8542359 帖子写的很好.看来一遍,试了一遍,感觉太有意义.必须转过来! android中跨进 ...

  7. Android 跨进程启动Activity黑屏(白屏)的三种解决方案

    原文链接:http://www.cnblogs.com/feidu/p/8057012.html 当Android跨进程启动Activity时,过程界面很黑屏(白屏)短暂时间(几百毫秒?).当然从桌面 ...

  8. 【朝花夕拾】Android性能篇之(七)Android跨进程通信篇

    前言 只要是面试高级工程师岗位,Android跨进程通信就是最受面试官青睐的知识点之一.Android系统的运行由大量相互独立的进程相互协助来完成的,所以Android进程间通信问题,是做好Andro ...

  9. 怎样让你的APK跑在 com.android.phone 进程

    首先:为什么要跑在 com.android.phone 进程 这还用问,在同一个进程里就能够干非常多事情了这是黑客行为 为什么能跑在统一进程? Google 在设计 Dalivk 虚拟机的时候就考虑到 ...

随机推荐

  1. 【python】xsspider零碎知识点

    1.提取url信息 urlparse() from urlparse import urlparse url = "http://scrapy-chs.readthedocs.io/zh_C ...

  2. PHP时间类完整实例

    <?php header("Content-type:text/html;Charset=utf-8"); class time{ private $year;//年 pri ...

  3. hdu4605

    两颗线段树,分别维护向左走向右走的情况 线段树的结点维护区间有多少点被路径经过了 离线读入所有询问,dfs遍历树的每一个结点,访问到v时解决对v的所有查询,在dfs过程中只需要维护根节点到v的链,线段 ...

  4. cf1061D 贪心+multiset 好题!

    cf上的思维题真好! 本题是在模拟的基础上贪心即可:将n段时间按照左端点(右端点为第二关键字)从小到大排序,然后遍历每一个时间段. 对于每一个时间段[li,ri],先找到multiset中最靠近li但 ...

  5. python+selenium十:基于原生selenium的二次封装

    from selenium import webdriverfrom selenium.webdriver.support.wait import WebDriverWaitfrom selenium ...

  6. python接口自动化测试十八:使用bs4框架爬取图片

    # 爬图片# 目标网站:http://699pic.com/sousuo-218808-13-1.htmlimport requestsfrom bs4 import BeautifulSoupimp ...

  7. python 全栈开发,Day96(Django REST framework 视图,django logging配置,django-debug-toolbar使用指南)

    昨日内容回顾 1. Serializer(序列化) 1. ORM对应的query_set和ORM对象转换成JSON格式的数据 1. 在序列化类中定义自定义的字段:SerializerMethodFie ...

  8. 步步为营-71-asp.net的简单练习(图片处理)

    1 原有图片添加水印 1.1 封装一个类,用于获取文件路径 using System; using System.Collections.Generic; using System.IO; using ...

  9. 结构型模式之Adapter模式

    适配器模式把一个类的接口变换成客户端所期待的另一种接口. 在JDK中的体现 把一个接口或类变成另外一种. java.util.Arrays#asList()javax.swing.JTable(Tab ...

  10. ZOJ-3537

    题目大意:给你一个n (n<=300) 边形,给出它所有的顶点坐标,让你把它划分成n-2个三角形的花费最小值,顶点 a 和 b 相连的花费为 abs(a.x+b.x)*abs(a.y+b.y). ...