从一个服务StartActivityForResultStartActivityForResult

2023-09-04 08:42:22 作者:风云再起ゞ

我还想启用蓝牙像这个例子。

不过我的课心不是一个活动,而是一个服务,所以我不能叫startActivityForResult。我该如何解决这个问题?我知道有一些已经回答了类似的其他问题

However my class isnt a Activity but a Service and therefore I can't call startActivityForResult. How can i solve this problem?. I know there are other questions that have been answered like

http://stackoverflow.com/questions/2848775/use-startactivityforresult-from-non-activity

但这并没有解决我的问题,因为我的应用程序由服务而不是其他的。

but this doesn't solve my problem because my application consists of the service and nothing else.

推荐答案

不幸的是,你不能做到这一点。

Unfortunately you can't do that.

我发现的唯一的解决办法(黑客)是先打开活动一个对话框样式,然后做呼叫那里。

The only solution I found (hack) is to first open an Activity with a Dialog style and then do the call there.