how to completely get rid of an activity's GUI (avoid a black screen)

前端 未结 3 1034
再見小時候
再見小時候 2021-02-03 15:07

I\'m trying to write a very simple app that will do just one very simple non-GUI action, then display a short message (using toast, on top of what was already on the screen, e.g

相关标签:
3条回答
  • 2021-02-03 15:41

    Sounds like a job for an IntentService. You send it an intent, and if it isn't running it starts, then it treats all received intents, then it stops. Short and simple.

    0 讨论(0)
  • 2021-02-03 15:53

    In <activity> in your manifest use

    android:theme="@android:style/Theme.NoDisplay"
    

    Note this assumes you will call finish() before returning from onResume(). If you are going to do more work after that (for example if you will be doing any networking or other such thing that can't be done quickly synchronously), you will probably want to start a service to take care of the work to tell the platform your process should continue running after the activity finishes.

    0 讨论(0)
  • 2021-02-03 15:54

    a service is not the answer to my problem

    Yes it is

    0 讨论(0)
提交回复
热议问题