Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
169 views
in Technique[技术] by (71.8m points)

java - StartActivityForResult from a Service

Id like to enable bluetooth like in this example.

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

use startActivityForResult from non-activity

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I know this is an older question, but I've run into a similar challenge, and my solution was to create an activity with android:theme="@android:style/Theme.NoDisplay", and then call startActivityForResult() from that. That creates an invisible activity that can both request and receive the intents, before writing data somewhere and then finishing itself.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...