Android : Android startActivity don't call the target activity

on Thursday, March 19, 2015


I'm having a problem using the startActivity to change from a activity to another. When I click in a button it should call another activity, and it does this, but it's not the activity that I wanted


My code:


This is the click action of a button, after do startActivity, it opens a white screen.



public void initiateRoute(View view) {
// I have a breakpoint on the line below and it comes here
Intent i= new Intent(this,GMapsActivity.class);
startActivity(i);
}


This is my target activity xml



<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="fill_parent">
<fragment
android:id="@+id/map"
android:layout_above="@+id/footer"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment"
tools:layout="@layout/abc_action_bar_title_item" />
<LinearLayout
android:id="@+id/footer"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_alignParentBottom="true">

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Pausar Rota"
android:layout_weight="0.5"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Parar captura de Rota"/>
</LinearLayout>
</RelativeLayout>


And this is my Activity class:



public class GMapsActivity extends Activity {

private GoogleMap mMap;

@Override
public void onCreate(Bundle savedInstanceState, PersistableBundle persistentState) {
// I have another breakpoint on the line below and it never comes here
super.onCreate(savedInstanceState, persistentState);
setContentView(R.layout.map_activity);
createMap();
}

private void createMap() {
mMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
mMap.setMapType(GoogleMap.MAP_TYPE_SATELLITE);
final LatLng CIU = new LatLng(35.21843892856462, 33.41662287712097);
Marker ciu = mMap.addMarker(new MarkerOptions()
.position(CIU).title("My Office"));
}
}


I did a lot of searches in stackoverflow, and in the google, and I didn't find nothing that can help me.


Thanks in advance.


0 comments:

Post a Comment