1

I am newbie to android. I am creating file sharing application. When user1 asks to user2 for file, user2 will get notification and further upload and download process will execute.

Question: How can I implement such task which will keep track about some one has asked for file? I have created database in which entry will be done when someone asks for file. But how android device can constantly check that entry?

I want such mechanism which is used by gmail to check every time for email. When mail comes, it shows notification.

Please help me to create such a background processing. Any help appreciated. Thanks in advance.

Jaimin
  • 171
  • 1
  • 1
  • 11
  • I think gmail uses push notifications (but that requires a server to send them) See http://stackoverflow.com/questions/1378671/push-notifications-in-android-platform You could use AlarmManager to wake up something that checks. Have a look at http://stackoverflow.com/questions/4459058/alarm-manager-example – Jerry Jeremiah Feb 27 '17 at 21:01

2 Answers2

1

I think what you are looking for is a Service.

A Service is an application component that can perform long-running operations in the background, and it does not provide a user interface. Another application component can start a service, and it continues to run in the background even if the user switches to another application. Additionally, a component can bind to a service to interact with it and even perform interprocess communication (IPC). For example, a service can handle network transactions, play music, perform file I/O, or interact with a content provider, all from the background.

Read more about services here

Prajnan Bhuyan
  • 415
  • 3
  • 11
  • I have already created services but it gets stopped when I clear background process explicitly by pressing long press on home button and removing all apps. I checked that by making process clear, Gmail's background process doesn't stop at all. – Jaimin Feb 28 '17 at 06:32
0

I got an answer. I will have to use Google FCM push notification. I was unaware about that before. At last I found solution. Thanks for help..

Jaimin
  • 171
  • 1
  • 1
  • 11