How to launch an Activity without a UI?

后端 未结 11 1661
失恋的感觉
失恋的感觉 2020-11-30 17:48

Is it in any way possible to launch an activity from the main function without having a UI? i.e. is there a way to create a sort of \"wrapper\" around another activity, i.e.

11条回答
  •  情歌与酒
    2020-11-30 18:35

    Just in case you are using Android 6.0+ or Target SDK is 23+, having a theme android:theme = "@android:style/Theme.NoDisplay" will lead to a crash with error did not call finish() prior to onResume() completing. This in fact is a bug recognised by Google developers here.

    So it is recommended to use an activity with following theme as a workaround.

    android:theme = "@android:style/Theme.Translucent.NoTitleBar"

提交回复
热议问题