Reputation: 619
I have application that have on her main screen map (v2) with buttons. These buttons after click run another application and this (main activity) is in stack. After in that another activity is called finish()
,main activity is back in front. But after this, map fragment is black and it's not working.
This is my fragment XML:
<fragment
android:id="@+id/mapFragment"
android:layout_width="100px"
android:layout_height="100px"
class="com.google.android.gms.maps.MapFragment" />
And the only thing I'm doing is setContentView(R.layout.new_main);
and nothing more.
This problem is almost like mine: Android MapView v2 Black screen, and also with no answer.
Upvotes: 5
Views: 4653
Reputation: 3625
Mine was really stupid reason.
I removed background
attribute from my xml
.
android:background="@android:color/black"
PS. I used FrameLayout
in xml
for SupportMapFragment
.
Upvotes: 0
Reputation: 196
Please try with the code which is given below:
@Override
public void onResume() {
super.onResume();
mapFragment.onResume();
}
Upvotes: 5
Reputation: 92
I Disable hardware acceleration at file manifest.xml, and my application doesnt show black map again in second load. i try it in emulator.
<application android:hardwareAccelerated="false">
...
</application
from this article: http://developer.android.com/guide/topics/graphics/hardware-accel.html
Upvotes: 3
Reputation: 1
I think that I have exactly the same problem since a week. When the mapfragment is destroy, it call onDestroyView()
@Override
public void onDestroyView() {
super.onDestroyView();
SupportMapFragment fragment = ((SupportMapFragment) getFragmentManager()
.findFragmentById(R.id.map));
if (fragment != null)
getFragmentManager().beginTransaction().remove(fragment).commit();
}
When the mapFragment is going to appear again, it's this code :
private void showFragment(final Fragment fragment) {
if (fragment == null)
return;
final FragmentManager fm = getSupportFragmentManager();
final FragmentTransaction ft = fm.beginTransaction();
// We can also animate the changing of fragment
ft.setCustomAnimations(android.R.anim.slide_in_left, android.R.anim.slide_out_right);
ft.replace(R.id.address_displayer, fragment);
ft.addToBackStack(null);
ft.commit();
}
The application doesn't crash but the map is black with still the zoom cursor and the icon for getting the current location of the device;
Perhaps important, i'm using the emulator.
Upvotes: 0