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;
}
}

更多相关文章

  1. 自定义VIEWGROUP的一个用法
  2. Android(安卓)图片选择器
  3. Android(安卓)Menu(Context Menu,Options Menu,SubMenu)实例
  4. 调用所有的 android activity 的实现
  5. Android的NDK开发(1)————Android(安卓)JNI简介与调用流程
  6. android md5加密
  7. Android(安卓)- 获取控件(包括状态栏与标题栏)宽高
  8. android 调用相机拍摄照片视频
  9. Android使用OpenGL(GLSurfaceView)视频画面抖动解决办法

随机推荐

  1. Android(安卓)Gesture 手势识别使用实例
  2. android 测试读取LEB数据的函数
  3. Android 实现文件的下载
  4. android 格式化SD卡
  5. Android跨进程通信IPC之15——Binder之na
  6. android pm 和 install 选项 命令
  7. 转:android 调用系统的接口
  8. Android第二十一课 Jni日志打印以及注意
  9. android 引用工程作为类库
  10. Android URL中参数的获取、拼接及修改