Sunday 21 December 2014

Calling an Activity from Service

To call an activity from service class through intent, write the code as below:


Intent intent=new Intent(UpdateWidgetService.this, Main.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);

where

"UpdateWidgetService" is the service class from where you are calling activity.
"Main" is the name of activity class.

No comments:

Post a Comment