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 8347681
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T07:26:24+00:00 2026-06-09T07:26:24+00:00

In my Top Half of the Android Screen, I am showing Google Map and

  • 0

In my Top Half of the Android Screen, I am showing Google Map and in the Bottom Half of the Android Screen, I am showing TextBox.

Problem Statement-

As currently I am showing google map on the top half of the Android Screen, so whole google map is getting shown on the Top Half of the Android Screen but I need to focus my Current Location on the Top Half of the Android Screen with the image current_user.png that I have in my drawable folder. So question here is-

  1. Show the Current Location with the image current_user.png on the Top Half of the Android Screen.

Below is my Java Code that I am using to show the current location on Top Half of the Android Screen. But it is giving me exception and my application is getting forced closed every time. Is there anything wrong I am doing here?

public class MainActivity extends MapActivity {    
public static final String TAG = "GoogleMapsActivity";
private MapView mapView;
private LocationManager locationManager;
Geocoder geocoder;
Location location;
LocationListener locationListener;
CountDownTimer locationtimer;
MapController mapController;
MapOverlay mapOverlay = new MapOverlay();



/** Called when the activity is first created. */
@Override
protected void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    setContentView(R.layout.activity_main);
    initComponents();
    mapView.setBuiltInZoomControls(true);
    mapView.setSatellite(true);
    mapController = mapView.getController();
    mapController.setZoom(16);
    locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
    if (locationManager == null) {
        Toast.makeText(getApplicationContext(),
                "Location Manager Not Available", Toast.LENGTH_SHORT)
                .show();
        return;
    }
    location = locationManager
    .getLastKnownLocation(LocationManager.GPS_PROVIDER);
    if (location == null)
        location = locationManager
        .getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
    if (location != null) {
        double lat = location.getLatitude();
        double lng = location.getLongitude();
        Toast.makeText(getApplicationContext(),
                "Location Are" + lat + ":" + lng, Toast.LENGTH_SHORT)
                .show();
        GeoPoint point = new GeoPoint((int) (lat * 1E6), (int) (lng * 1E6));
        mapController.animateTo(point, new Message());
        mapOverlay.setPointToDraw(point);
        List<Overlay> listOfOverlays = mapView.getOverlays();
        listOfOverlays.clear();
        listOfOverlays.add(mapOverlay);
    }
    locationListener = new LocationListener() {
        @Override
        public void onStatusChanged(String arg0, int arg1, Bundle arg2) {
        }

        @Override
        public void onProviderEnabled(String arg0) {
        }

        @Override
        public void onProviderDisabled(String arg0) {
        }

        @Override
        public void onLocationChanged(Location l) {
            location = l;
            locationManager.removeUpdates(this);
            if (l.getLatitude() == 0 || l.getLongitude() == 0) {
            } else {
                double lat = l.getLatitude();
                double lng = l.getLongitude();
                Toast.makeText(getApplicationContext(),
                        "Location Are" + lat + ":" + lng,
                        Toast.LENGTH_SHORT).show();
            }
        }
    };
    if (locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER))
        locationManager.requestLocationUpdates(
                LocationManager.GPS_PROVIDER, 1000, 10f, locationListener);
    locationManager.requestLocationUpdates(
            LocationManager.NETWORK_PROVIDER, 1000, 10f, locationListener);
    locationtimer = new CountDownTimer(30000, 5000) {
        @Override
        public void onTick(long millisUntilFinished) {
            if (location != null)
                locationtimer.cancel();
        }

        @Override
        public void onFinish() {
            if (location == null) {
            }
        }
    };
    locationtimer.start();
}

public MapView getMapView() {
    return this.mapView;
}

private void initComponents() {
    mapView = (MapView) findViewById(R.id.mapView);
}

@Override
protected boolean isRouteDisplayed() {
    return false;
}

class MapOverlay extends Overlay {
    private GeoPoint pointToDraw;

    public void setPointToDraw(GeoPoint point) {
        pointToDraw = point;
    }

    public GeoPoint getPointToDraw() {
        return pointToDraw;
    }

    @Override
    public boolean draw(Canvas canvas, MapView mapView, boolean shadow,
            long when) {
        super.draw(canvas, mapView, shadow);

        Point screenPts = new Point();
        mapView.getProjection().toPixels(pointToDraw, screenPts);

        Bitmap bmp = BitmapFactory.decodeResource(getResources(),
                R.drawable.current_user);
        canvas.drawBitmap(bmp, screenPts.x, screenPts.y - 24, null);
        return true;
    }
}

}

Below is my XML file

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="vertical" > 

    <com.google.android.maps.MapView 
        android:id="@+id/mapView" 
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent" 
        android:layout_weight="1" 
        android:apiKey="0vAX8Xe9xjo5gkFNEEIH7KdHkNZNJWNnsjUPKkQ" 
        android:clickable="true" 
        android:enabled="true" /> 

    <TextView 
        android:id="@+id/textView" 
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent" 
        android:layout_weight="1" 
        android:text="TextView" /> 

</LinearLayout> 

Exception I am getting-

java.lang.RuntimeException: Unable to start activity 
ComponentInfo{com.example.circlemapandroid/com.example.circlemapandroid.MainActivity}: 
java.lang.IllegalArgumentException: requested provider network doesn't exisit
  • 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-09T07:26:26+00:00Added an answer on June 9, 2026 at 7:26 am

    You have to check if network provider is enabled like you did with the GPS provider:

    if (locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER)){
        locationManager.requestLocationUpdates(
            LocationManager.NETWORK_PROVIDER, 1000, 10f, locationListener);
    }
    

    Also the following permission have to be present in your manifest:

    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Currently I am showing Google Map in Android phone using Java on the whole
I am trying to show Google Map on the Top Half of the Android
I have a website which splits the screen into two frames; the top half
I want to create a RichTextField at the bottom half of the screen, while
Problem Statement:- I am working on the android project in which I need to
I'm trying to work with 3 SurfaceViews on one screen, one on top half
I'm trying to display only the top half of an image and the bottom
I need to create a view where the top half of the screen has
This is the top half of the class that hosts the dialog. import android.app.Activity;
Top of the morning to ye people on various surfaces of earth. The problem:

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.