I am looking into displaying an activity when the service is first started so i created a new class put some code an xml but the R.id references are not beeing resolved and what can i do next ?
Asked
Active
Viewed 147 times
-2
-
can u please put the code.... clean the project and run again or there might a error in the manifest file .. but not sure about it – Pavan Mar 22 '12 at 12:47
-
so, you're starting the service first and then you want to start an Activity from within your Service? as far as I know, this would not work... why don't you do it the other way round? – herom Mar 22 '12 at 12:47
-
Do you want to start an activity from service? – Praveenkumar Mar 22 '12 at 13:16
1 Answers
2
Something like this...
public class TestService extends Service {
@Override
public void onStart(Intent intent, int startId) {
super.onStart(intent, startId);
Intent dialogIntent = new Intent(getBaseContext(), myActivity.class);
dialogIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
getApplication().startActivity(dialogIntent);
}
}