Android防止进程被第三方软件杀死
2015-06-18 15:02
537 查看
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;
}
}
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任务、进程和线程
- AndroidStudio中的DDMS连不上真机
- 屏幕适配
- Android启动过程深入解析
- 更改Android Toast的显示位置
- Android_Service组件详解
- Android SDK打包
- Android总结Listview的notifyDataSetChanged与setSelection冲突
- Android开发中使用照相机功能 及其常见问题解法方法
- android staticlayout使用讲解
- android启动渐变效果,左至右消失
- Android KitKat Immersive Mode使用
- Android实现连续并排的若干个TextView单击改变背景颜色达到选项卡Tab栏切换效果
- Android 子线程中Toast的问题
- Android socket通信
- 在android apk中使用internal包
- Android_多媒体详解
- Android中IntentService与Service的区别
- android亮屏、黑屏、解锁事件的系统广播接收
- android亮屏、暗屏、解锁、关闭系统对话的监听事件