Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Android app dev, background downloader as service or best practice

Discussion in 'Android' started by JDMulti, Aug 13, 2018.

  1. JDMulti

    JDMulti

    Joined:
    Jan 4, 2012
    Posts:
    384
    I'm working on a mobile VR project for Oculus Go and GearVR and this might sound it fits more on the VR forums part, but I've a more Android specific question.

    I send my Beta app to the store and I found out that the app needs a native Android background downloader which is a service started by the unity app and runs until the downloads are done. I'm experienced with Unity development but when it comes to native Android or iOS I need to completely dive into this.

    This weekend I've been picking up some documentation on how to create an native Android class into a java one and use that within Unity and that works fine.
    However usually you write scripts in Unity, test the game and when error's are found you can fix them straight away. However now I need to develop within Android Studio a plugin that creates an Android service background downloader, but I can't run it within the editor as it's a plugin and not a whole app. So I need to write code, build a class, import in unity, build to android and then I can test it. This is how far I know I need to do this, but is there a way I can test it directly into Android Studio including if things are downloading trough the plugin class?

    Another problem I found is that the service is being started trough Unity, but when the download manager of android is done, how does unity know that as it main thread is paused, how does this work?

    I know many people develop Android apps and I see this service popup in many Unity made apps but I can't find any resource that writes in details how such a thing can be setup and what is the best way to develop Android plugins for Unity. I do find resources about setting up a download service but nothing from within Unity and how communication goes between them or how to ease development of Android plugins for Unity.
    I was wondering if any of you know good resources and can shed a light on this. Right now my workflow is code something in android up to publish with unity to test a plugin, but it's a horrible workflow and incredible slow if you don't know anything about Android development but eager to learn it.