Android 프로그래밍

본문 바로가기
사이트 내 전체검색


Android 프로그래밍
Android 프로그래밍

1. Android Immortal Service (죽지않는 서비스) 구현하기

페이지 정보

작성자 관리자 댓글 1건 조회 4,226회 작성일 19-09-17 19:46

본문

1. Android Immortal Service (죽지않는 서비스) 구현하기

Android의 죽지 않는 서비스는 일반적인 서비스를 startForeground로 실행하면 간단하게 구현 할 수 있다.

이 방법의 문제는 Notification을 이용하여 알림창에 표시해야만 한다는 것이다


이 내용들을 토대로 운영체제가 서비스를 죽이면 다시 실행하는 방법으로 죽지 않는 서비스를 구현하였다.

다시 실행시키는 방법은 알람(Alarm)을 이용한다.

서비스가 종료되면(onDestroy) 1초 뒤에 알람이 실행되게 하고,

알람에서 해당 서비스를 다시 실행한다.


Oreo 이후 버전은  Android에서 제공하는 죽지않는(Foreground) 서비스인 RestartService를 startForegroundService로 실행한다.


startForegroundService로 실행한 RestartService의 코드는 다음과 같다.

 

 

RestartService 의 코드는 Android에서 제공하는 죽지않는(Foreground) 서비스의 코드이다.

포그라운드(Foreground)로 실행되지만, Android 알림창에 표시되는 문제가 있다.

따라서, RestartService를 startForeground로 실행하고,

RealService를 실행한다 (startService).

그리고 실행된 RestartService를 stopForeground와 stopSelf를 실행하여 RestartService를 종료한다.

RestartService가 실행되고 종료되는 시간이 짧기 때문에 알림창에는 표시가 생기지 않는다.

 


이외에 부팅후 실행을 위한 코드(RebootRecever)도 있지만 알람과 동일한 코드라 생략한다.

 


이상의 죽지 않는 서비스를 구현하기 위해 필요한 2개의 서비스와 2개의 Recever를


AndroidManifest.xml 파일에 다음과 같이 등록해야 한다.

 

댓글목록

William님의 댓글

William 작성일

https://www.nikesoutletstores.us.com/ Nike Outlet Online
https://www.jordan30.us/ Jordan 30
https://www.jordans28.us/ Jordan 28
https://www.wholesalenikeshoesclothing.us.com/ Cheap Wholesale Nike Shoes Free Shipping
https://www.nikeairmax270s.us.com/ Nike Air Max 270 Flyknit
https://www.toddlerbabyinfantjordans.us/ Baby Jordan
https://www.nikecanadashoesshop.ca/ Nike Canada
https://www.nikeairforces.us.com/ Nike Air Force
https://www.nike-outlets.us.com/ Nike Outlet Store
https://www.huaraches.us.org/ Huaraches
https://www.nikeairhuaraches.us.com/ Nike Huarache
https://www.nikefoampositeacghyperdunk.us.com/ Nike Foamposites
https://www.officialpandorarings.us/ Pandora Rings
https://www.pandorajewelryofficialsites.us/ Pandora Jewelry Official Site
https://www.nikeshoesformens.us.com/ Nike Shoes For Men
https://www.nikesnew.us.com/ Nikes
https://www.jordanswholesale.us.org/ Jordans Wholesale
https://www.jordan11lowretro.us/ Jordan Retro 11 Low
https://www.newnikesshoes.us.org/ New Nike Shoes
https://www.cheapadidasshoes.us.org/ Adidas Shoes
https://www.adidasyeezywebsite.us.org/ Yeezy
https://www.cheapjordansshoessale.us/ Cheap Jordan Shoes
https://www.pandorajewelrycz.us/ Pandora Jewelry
https://www.nikeairforceones.us.org/ Nike Air Force Ones
https://www.jordans34.us/ Jordan 34
https://www.foamposites.us.org/ Nike Foamposite
https://www.nikewholesale.us.org/ Wholesale Nike Shoes
https://www.jordan29.us/ Jordan 29
https://www.airjordans11retro.us/ Air Jordan 11 Retro
https://www.jerseysstore.ca/ NFL Jerseys
https://www.pandoraoutletsjewelry.us.com/ Pandora Charms Outlet
https://www.jordan27.us/ Jordan 27
https://www.newnikesneakers.us.org/ Nike Sneakers
https://www.newjordans.us.org/ New Jordans 2021
https://www.nikeairjordan.us.org/ Nike Jordans
https://www.jordan1.us.org/ Nike Air Jordan 1
https://www.pandorajewelryauthentic.us/ Pandora Jewelry
https://www.airmaxs.us.org/ Air Max
https://www.pandorajewelrycharmscanada.ca/ Pandora Earrings
https://www.nikejordan1.us.com/ Nike Jordan 1
https://www.air-maxs.us.com/ Air Max Shoes
https://www.jordan11concordshoes.us/ Jordan 11
https://www.airmax720.us.org/ Nike Air Max 720
https://www.pandorasjewelrycharms.us/ Pandora Jewelry
https://www.nikerunningshoes.us.org/ Best Nike Running Shoes
https://www.nikesbdunk.us.com/ Nike SB
https://www.nikeairzoom.us.com/ Nike Zoom
https://www.jordan6s.us/ Jordan 6s
https://www.cheapjordanswholesalefreeshipping.us/ Cheap Jordans
https://www.jewelryspandora.us.com/ Pandora Jewelry
https://www.pandorabracelet-clearance.us.com/ Pandora Bracelets Clearance
https://www.lebronsjamesshoes.us.com/ Lebron James Shoes
https://www.cheapshoeswholesalefreeshipping.us/ Cheap Nikes
https://www.jordan-12.us.org/ Jordan 12
https://www.pandorasbracelets.us/ Pandora Bracelets
https://www.nbastorecanada.ca/ Custom Jerseys Canada
https://www.pandorajewelryblackfriday.us.com/ Pandora Jewelry Black Friday
https://www.nikeoutletshoes.us.org/ Nike Outlet
https://www.jordans33.us/ Jordan 33
https://www.jordans14.us/ Jordan 14
https://www.jordan21.us/ Jordans 21
https://www.jordan18.us/ Jordan 18
https://www.airmax-outlet.us.com/ Air Max
https://www.jordan-aj1.us/ AJ1
https://www.jordan15.us/ Jordan 15
https://www.jordan24.us/ Air Jordan 24
https://www.jordan2s.us/ Jordan 2
https://www.nhljerseysstore.ca/ Cheap NHL Jerseys
https://www.jordans13shoes.us/ Jordans 13
https://www.nikesneakerss.us.com/ Nike Store
https://www.nikesoutletstore.us.com/ Nike Outlet Store
https://www.airjordans13.us/ Air Jordan 13
https://www.nikeoffwhite.us.org/ Off White Nike
https://www.jordanshoess.us.org/ Jordan Shoes
https://www.huaracheshoes.us.com/ Huaraches
https://www.nikeshoessale.us.org/ Nike Shoes For Men
https://www.nikemetcons.us.com/ Nike Metcons
https://www.nikefree.us.org/ Nike Free
https://www.christianslouboutin.us.org/ Christian Louboutin
https://www.nikeshoesoutletstoreonlineshopping.us.com/ Nike Outlet Store Online Shopping
https://www.nikeairmaxs.us.org/ Nike Air Max Women
https://www.pandoraa.us/ Pandora Jewelry
https://www.nikeshops.us.com/ Nike Shoes
https://www.nikeshoesstores.us.com/ Nike Shoes
https://www.wholesaleshoescheap.us/ Wholesale Shoes
https://www.wholesaleshoesclothing.us/ Wholesale Nike Shoes
https://www.pandorajewelryoutlets.us.com/ Pandora Outlet
https://www.nikewomensshoes.us.com/ Women's Nike Shoes
https://www.nikeoutlet-store.us.org/ Nike Outlet Online
https://www.jordan20.us/ Jordans 20
https://www.nikecortezshox.us.org/ Nike Shox
https://www.wholesalejordansfactory.us/ Wholesale Jordans
https://www.shoesstores.ca/ Nike Shoes
https://www.nflshoponline.ca/ NFL Shop Canada
https://www.jordan33.us.org/ Jordan 33
https://www.pandorajewelryshops.us.com/ Pandora Jewelry 70 Off Clearance
https://www.nike-clearance.us.org/ Nike Clearance Store
https://www.airmaxs97.us.com/ Air Max 97
https://www.jordan17.us/ Jordan 17
https://www.airjordan-retros.us/ Jordan Retros
https://www.nikerosheblazer.us.org/ Roshe
https://www.nikerosheblazers.us.com/ Nike Blazer
https://www.wholesaleadidas.us.com/ Adidas Wholesale
https://www.nmdr1.us.com/ NMD
https://www.cheapshoeswholesalefromchina.us/ Cheap Nike Shoes From China
https://www.nikesoutletfactory.us.com/ Nike Outlet
https://www.retro12.us/ Jordan 12 Retro
https://www.nikewholesalesuppliers.us.com/ Nike Wholesale Suppliers
https://www.nikeblackfridaycybermonday.us.org/ Nike Cyber Monday
https://www.nikeairforce1s.us.org/ Air Force 1s
https://www.charmspandoras.us.com/ Pandora Charms Sale Clearance
https://www.cheapjordanshoessuppliers.us.org/ Cheap Jordan Shoes For Men
https://www.nikeepicreactuptempo.us.org/ Nike React
https://www.jordans12.us/ Jordans 12
https://www.christianlouboutinshoess.us.com/ Christian Louboutin Shoes
https://www.jordan4.us.org/ Jordan 4
https://www.jordan11s.us.org/ Jordan Retro 11
https://www.shoeswholesalesuppliers.us/ Nike Wholesale Suppliers
https://www.jordan19.us/ Jordan 19
https://www.canadashoesoutlet.ca/ Nike Canada
https://www.cheapjerseyswholesale.ca/ Cheap Jerseys Wholesale
https://www.jordan31.us/ Jordans 31
https://www.nikeair-force1.us.org/ Nike Air Force 1 Women
https://www.airforce1s.us.org/ Air Force 1
https://www.air-max2019.us.org/ Nike Air Max
https://www.jordan16.us/ Jordan 16
https://www.nikefactory-store.us.com/ Nike Factory
https://www.jordan26.us/ Jordan 26
https://www.nikes.us.org/ Nike Outlet
https://www.diorjordans.us/ Dior Jordans
https://www.nikeshoesdeals.us.com/ Nike Shoes
https://www.officialpandorajewelry.us/ Pandora Jewelry
https://www.mlbjerseysshop.ca/ MLB Shop
https://www.wholesaleshoessneakers.us/ Wholesale Adidas
https://www.pandora-charmssale.us/ Pandora Charms Sale Clearance
https://www.ringspandora.us/ Rings Pandora
https://www.jordans32.us/ Jordan 32
https://www.nikeoutletstoreonlines.us.org/ Nike Outlet
https://www.airjordanretro.us.org/ Air Jordan
https://www.cheapjordansshoeswholesale.us.org/ Cheap Jordans
https://www.jordan5whatthe.us/ What The Jordan 5
https://www.pandora-jewelry-charms.us/ Pandora Jewelry Charms
https://www.yeezysboost350v2.us.org/ Yeezy Boost 350 V2
https://www.jordan35.us/ Jordan 35
https://www.nhlshops.ca/ NHL Shop
https://www.charmspandora.us.org/ Pandora Charms Sale Clearance
https://www.jordans23.us/ Jordan 23
https://www.jordan25.us/ Jordan 25
https://www.michaeljordan-shoes.us/ Michael Jordan Shoes
https://www.nikezoomshoes.us.com/ Nike Zoom
https://www.adidasstoreoutlet.us.com/ Adidas Outlet
https://www.airjordan33.us/ Air Jordan 33
https://www.kidsjordans.us/ Kids Jordans
https://www.redbottomslouboutinshoes.us.org/ Louboutin Shoes
https://www.nikerunningshoesforwomen.us.com/ Nike Running Shoes Women
https://www.nikess.us.com/ Nikes Shoes
https://www.pandora-jewelrysite.us/ Pandora Jewelry Official Site
https://www.nikeairmaxs-270.us.com/ Nike Air Max 270
https://www.jordan22.us/ Jordan 22
https://www.nikeair-max95.us.com/ Nike Air Max 95


개인정보취급방침 서비스이용약관 모바일 버전으로 보기 상단으로

TEL. 063-469-4551 FAX. 063-469-4560 전북 군산시 대학로 558
군산대학교 컴퓨터정보공학과

Copyright © www.leelab.co.kr. All rights reserved.