public class LocationService extends Service {
@Override
public void onStart(Intent intent, int startId) {
super.onStart(intent, startId);
startActivity(new Intent(this, activity.class));
}
}
We created a service that runs in the activity like this.
I'd like to call the activity if the conditions are met.
startService(new Intent(WozzonActivity.this, LocationService.class)); Activities cannot be called in the Location Service.
How do I get the context I'm currently working on in the service class?
android android-activity service
in the class of service.
Intent dialogIntent = new Intent(this, MyActivity.class);
dialogIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(dialogIntent);
This is how you do it.
© 2024 OneMinuteCode. All rights reserved.