Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8605047
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T02:43:39+00:00 2026-06-12T02:43:39+00:00

I have activity with MapView, TextView, 3 ImageButton and 1 simple Button. First call

  • 0

I have activity with MapView, TextView, 3 ImageButton and 1 simple Button. First call setContentView for this activity takes too much time (near 10 seconds). Here is my view code:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:gravity="center_horizontal"
    android:padding="0px" >

    <com.google.android.maps.MapView
        android:id="@+id/map_view"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_below="@+id/txt_route_info"
        android:apiKey="MyAPIKeyGoesHere"
        android:clickable="true"
        android:enabled="true" />

    <Button
        android:id="@+id/btn_accept"
        android:layout_width="fill_parent"
        android:layout_height="55dp"
        android:layout_alignParentBottom="true"
        android:layout_margin="2dip"
        android:enabled="false"
        android:text="@string/btn_accept" />

    <LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/textEdit"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:gravity="center_horizontal"
        android:padding="0px" >

        <TextView
            android:id="@+id/txt_route_info"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:gravity="center_horizontal" />
    </LinearLayout>

    <LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/textEdit"
        android:layout_centerHorizontal="true"
        android:gravity="center_horizontal"
        android:padding="0px" >

        <ImageButton
            android:id="@+id/btn_zoom_in"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:contentDescription="@string/btn_zoom_in_content_descriptor"
            android:src="@drawable/zoom_in" />

        <ImageButton
            android:id="@+id/btn_zoom_out"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:contentDescription="@string/btn_zoom_out_content_descriptor"
            android:src="@drawable/zoom_out" />

        <ImageButton
            android:id="@+id/btn_my_location"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:contentDescription="@string/btn_my_location_content_descriptor"
            android:src="@drawable/my_location" />
    </LinearLayout>

</RelativeLayout>

I have no idea what can slow activity loading so much. I’ve read this topic: setContentView taking long time (10-15 seconds) to execute
but i still can’t solve my problem. If you can give me any hint or idea, I would be thankful.

UPDATE:

onCreate method from my activity code:

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.google_map_view);
    mapView = (MapView) this.findViewById(R.id.map_view);
    mapView.setBuiltInZoomControls(false);

    locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
    if (locationManager == null) {
        this.finish();
        return;
    }

    final MyLocationOverlay myLocationOverlay = new MyLocationOverlay(this, mapView);
    myLocationOverlay.disableCompass();
    myLocationOverlay.enableMyLocation();

    acceptBtn = (Button) findViewById(R.id.btn_accept);
    final View.OnClickListener acceptBtnListener = new AcceptBtnListener();
    acceptBtn.setOnClickListener(acceptBtnListener);

    final ImageButton zoomInBtn = (ImageButton) findViewById(R.id.btn_zoom_in);
    final ImageButton zoomOutBtn = (ImageButton) findViewById(R.id.btn_zoom_out);
    myLocationBtn = (ImageButton) findViewById(R.id.btn_my_location);
    zoomInBtn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mapController.zoomIn();
        }
    });

    zoomOutBtn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mapController.zoomOut();
        }
    });

    myLocationBtn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            final GeoPoint myLocation = myLocationOverlay.getMyLocation();
            if (myLocation != null) {
                mapController.animateTo(myLocation);
                mapController.setCenter(myLocation);
            } else {
                progressDialog = ProgressDialog.show(GoogleMapActivity.this, "", getString(R.string.dlg_progress_obtaining_location), true);
            }
        }
    });

    mapController = this.mapView.getController();
    mapController.setZoom(MAP_ZOOM_LEVEL);

    final Intent intent = getIntent();
    isInRouteMode = intent.getBooleanExtra("isRouteMode", false);  //activity started to display route?
    if (isInRouteMode) {
        final String fromAddress = intent.getStringExtra("fromAddress");
        final String toAddress = intent.getStringExtra("toAddress");
        final GeoPoint fromPoint;
        final GeoPoint toPoint;
        try {
            fromPoint = getGeoPointByAddressString(fromAddress, this);
            toPoint = getGeoPointByAddressString(toAddress, this);
        } catch (IOException e) {
            Toast.makeText(this, getString(R.string.err_geocoder_not_available),
                    Toast.LENGTH_LONG).show();
            Log.e(CLASSTAG, e.getMessage());
            return;
        }
        new RouteCalculationTask().execute(fromPoint, toPoint);
    } else {  //activity started to select address
        addressItemizedOverlay = new AddressItemizedOverlay(getResources().getDrawable(R.drawable.red_pin));
        mapView.getOverlays().add(addressItemizedOverlay);
        mapView.getOverlays().add(myLocationOverlay);
        mapView.setOnTouchListener(new MapOnTouchListener());
    }
}

Priveous activity is simple activity with just four buttons so I belive it can’t slow down this activity.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T02:43:40+00:00Added an answer on June 12, 2026 at 2:43 am

    what kind of view are you coming from?

    The previous view/activity/fragment can slow things down, also the mapview can be slow especially when if GPS is trying to get a lock at the same time

    consider a loading dialog

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having awful problems with this. I have a MapView, in my activity I
I have this textbox in the other activity and a button which leads to
In my Android Application I have a Google MapView Activity and I am facing
I have an activity with the following layout. So in this screen, initally the
I have an activity with a spinner which loads a simpleCursorAdaptor. I call another
I have an Android Activity that displays Google Maps through MapView control and extending
I have a problem with mapView. This is code: Android Manifest: <uses-sdk android:minSdkVersion=8 />
I have this layout in xml. And when I run the activity at the
Possible Duplicate: Double Tap -> Zoom on Android MapView? I have an Activity that
I have an activity that extends MapActivity, and inside onCreate() I have this code

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.