0

I want my app to silently start in the backgorund, without showing any activity on the screen. It has a service which needs to perform 2 upload tasks.

I'm learning about service, but all boot-up launch of apps talks about showing the activity.

I need no activity to be shown.

Is that permitted after Oreo?

C Forge
  • 215
  • 1
  • 8

1 Answers1

0

You didn't say what should trigger your app from background. I presume some kind of an Intent. As far as I know there is no way to start service in the background since android O without showing anything to the user. You should start your service using startForegroundService(), then show notification, perform your 2 uploads and turn off the app (hidding notification too). If those uploads aren't huge, it will be pretty quick, and in most cases user won't even see the notification.

Karzel
  • 928
  • 9
  • 24
  • in light of Android Oreo Background Execution Limits video https://www.youtube.com/watch?v=Pumf_4yjTMc that I just saw, you answer makes a lot of sense to me. Thanks. The trigger is, if there are new files in 2 particular folders. It's more like an ongoing service, to sync the new files in those folders to the server. – C Forge Nov 05 '18 at 20:39
  • I realize, i need the trigger to be a call hangup action. Since otherwise I think the app will upload the unfinished chunks of the call. Call recording is one part of the module. is there an efficient way to listen to call hangup event? – C Forge Nov 05 '18 at 20:43
  • I think what you are looking for is `PHONE_STATE` Intent :) https://developer.android.com/reference/android/telephony/TelephonyManager#ACTION_PHONE_STATE_CHANGED Don't forget to ask for a permission when you want to listen for that Intent. Also, there are problems with triggering app through BroadcastReceiver on some devices. More about that and solution for resolving it you can read here: https://stackoverflow.com/a/52377967/8713068 – Karzel Nov 06 '18 at 06:01