Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get context from onStartCommand

Tags:

android

I have a service and I need to get access to context from the service onStartCommand.

How could I do that. I'm new to Android.

like image 659
user836026 Avatar asked Nov 04 '25 17:11

user836026


2 Answers

You can use ServiceName.this to get Context, Service extends Context

like image 74
nandeesh Avatar answered Nov 07 '25 09:11

nandeesh


Service is a Context. You can use this.

like image 36
cheng yang Avatar answered Nov 07 '25 10:11

cheng yang