I have google map displayed in a FragmentActitvity which implements And to open this activity I am start an intent from another activity(let's say Activity A) on click of a button.
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getApplicationContext(), MapActivity.class);
startActivity(intent);
}
});
And my MapActivity is like this:
public class MapActivity extends FragmentActivity implements GooglePlayServicesClient.ConnectionCallbacks,
GooglePlayServicesClient.OnConnectionFailedListener {
private GoogleMap googleMap;
private LocationClient locationClient;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_map);
if (googleMap == null) {
googleMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap();
googleMap.setMyLocationEnabled(true);
// check if map is created successfully or not
if (googleMap == null) {
Toast.makeText(getApplicationContext(), "Sorry! unable to create maps", Toast.LENGTH_SHORT).show();
}
}
locationClient = new LocationClient(this, this, this);
locationClient.connect();
mLocationRequest = LocationRequest.create();
mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
mLocationRequest.setInterval(5 * 1000);
mLocationRequest.setSmallestDisplacement(0.1f);
mLocationRequest.setFastestInterval(5 * 1000);
}
}
The MapActivity has other other implementation method of interfaces as well. But when I click on button to open MapActivity I get the error:
java.lang.IllegalArgumentException: Service Intent must be explicit: Intent { act=com.google.android.location.internal.GoogleLocationManagerService.START }
I searched on google and I found I need to create an explicit intent. But I am not sure how to do that in my case.