我想创建一个服务来获取短信并将其写入文件,而不会中断处理短信的本机过程。
2 回答
Can you be more specific? Do you want to create your own service? Do you want to receive SMS and write that SMS to a file?
1st approach
In you application register Broadcast in Manifest. Never unregister that broadcast.
Once you receive your broadcast in onreceive() write to a file.
2nd approach
Create a service and in that service register a broadcast Once you receive ur broadcast in onreceive() write to a file.
Note: don't unregister your broadcast in onDestroy() of your Service. Keep it alive.
You can check this link:
http://www.apriorit.com/our-company/dev-blog/227-handle-sms-on-android