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

  • Home
  • SEARCH
  • 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 8313013
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T20:21:15+00:00 2026-06-08T20:21:15+00:00

I don’t know what is wrong in my code because I tried everything. I

  • 0

I don’t know what is wrong in my code because I tried everything. I created Alert Dialog and all of the web I’ve seen that Alert dialog appears for everybody else. My app doesn’t show dialog. This is Main.java:

package com.natasam.mapstwo;

import java.util.List;

import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.MotionEvent;

import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;
import com.google.android.maps.Overlay;



public class Main extends MapActivity {
    MapView map;
    long start;
    long stop;


    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        map= (MapView)findViewById(R.id.mvMain);
        map.setBuiltInZoomControls(true);   

        Touch t= new Touch();
        List<Overlay>  overlayList = map.getOverlays();
        overlayList.add(t);

    }

    @Override
    protected boolean isRouteDisplayed() {

        return false;
    }

    class Touch extends Overlay{
        public boolean OnTouchEvent(MotionEvent e, MapView v){
            if(e.getAction()== MotionEvent.ACTION_DOWN){
              start=e.getEventTime();

          }
          if(e.getAction()== MotionEvent.ACTION_UP){
              stop=e.getEventTime();
          }
          if(stop- start > 1500){
            Builder alert=new AlertDialog.Builder(Main.this);

              alert.setTitle("pick an option");
              alert.setMessage("You must pick an option");
              alert.setPositiveButton("option 1", new DialogInterface.OnClickListener() {


                public void onClick(DialogInterface dialog, int which) {
                    // TODO Auto-generated method stub

                }
            });
              alert.setNegativeButton("pick address", new DialogInterface.OnClickListener() {

                    public void onClick(DialogInterface dialog, int which) {
                        // TODO Auto-generated method stub
                    }
                });
              alert.setNeutralButton("option 3", new DialogInterface.OnClickListener() {

                    public void onClick(DialogInterface dialog, int which) {
                        // TODO Auto-generated method stub

                    }
                });



              alert.create();
              alert.show();
              return true;
          }
            return false;

        }
    }
}

And this is .xml file:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

   <com.google.android.maps.MapView
          android:id="@+id/mvMain"
                 android:layout_width="fill_parent"
                 android:layout_height="fill_parent"
                 android:enabled="true"
                 android:clickable="true"
                 android:apiKey="a valid key" />


</RelativeLayout>

And Manifest:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.natasam.mapstwo"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="15" />
<uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
         android:theme="@android:style/Theme.NoTitleBar">
        <uses-library android:name="com.google.android.maps" />
        <activity
            android:name=".Main"
            android:label="@string/title_activity_main" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

What is wrong? It shows map but not alert dialog…

  • 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-08T20:21:17+00:00Added an answer on June 8, 2026 at 8:21 pm

    You are implementing OnTouchEvent, not onTouchEvent.

    Try this instead:

    @Override // Yes, use @Override
    public boolean onTouchEvent(MotionEvent e, MapView v){
    

    Once you’ve changed it, use android.util.Log.i(...); or System.out.println(...); to ensure your touch event is even getting called.

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

Sidebar

Related Questions

Don't dismiss this as a newbie question! It's not, I'm not, I've tried everything,
I don't know why, but this code worked for me a month ago... maybe
Don't know what's wrong here, when I run the application it says Specified method
Don't know if it's I'm doing it wrong or if there's a bug (I
Don't yell at me! i have seen many threads claiming that HTML cannot be
Don't know if there is a better way to do this, so that is
don't know better title for this, but here's my code. I have class user
Don't know how to frase this but I found this code wich works as
don't know if the title describes anything about what I'm trying to say but
don't know what happened in my jcrop selection. I think I pressed some keys

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.