开发者

ActivityNotFoundException (MapActivity)

i have an MapActivity in my application. I included it at my manifest file but when i run the application , everything runs fine except the MapActivity, Whenever i try to start MapActivity by clicking a Button it gives the following errors,

07-02 18:06:39.752: ERROR/AndroidRuntime(354): FATAL EXCEPTION: main
07-02 18:06:39.752: ERROR/AndroidRuntime(354): android.content.ActivityNotFoundException: Unable to find explicit activity class {com.xtreme.iSenegal/java.util.Map}; have you declared this activity in your AndroidManifest.xml?
07-02 18:06:39.752: ERROR/AndroidRuntime(354):     at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1404)
07-02 18:06:39.752: ERROR/AndroidRuntime(354):     at android.app.ActivityThread.resolveActivityInfo(ActivityThread.java:2473)
07-02 18:06:39.752: ERROR/AndroidRuntime(354):     at android.app.LocalActivityManager.startActivity(LocalActivityManager.java:277)
07-02 18:06:39.752: ERROR/AndroidRuntime(354):     at com.xtreme.iSenegal.Activity1.replaceContentView(Activity1.java:28)
07-02 18:06:39.752: ERROR/AndroidRuntime(354):     at com.xtreme.iSenegal.Details$2.onClick(Details.java:94)
07-02 18:06:39.752: ERROR/AndroidRuntime(354):     at android.view.View.performClick(View.java:2408)
07-02 18:06:39.752: ERROR/AndroidRuntime(354):     at android.view.View$PerformClick.run(View.java:8816)
07-02 18:06:39.752: ERROR/AndroidRuntime(354):     at android.os.Handler.handleCallback(Handler.java:587)
07-02 18:06:39.752: ERROR/AndroidRuntime(354):     at android.os.Handler.dispatchMessage(Handler.java:92)
07-02 18:06:39.752: ERROR/AndroidRuntime(354):     at android.os.Looper.loop(Looper.java:123)
07-02 18:06:39.752: ERROR/AndroidRuntime(354):     at android.app.ActivityThread.main(ActivityThread.java:4627)
07-02 18:06:39.752: ERROR/AndroidRuntime(354):     at java.lang.reflect.Method.invokeNative(Native Method)
07-02 18:06:39.752: ERROR/AndroidRuntime(354):     at java.lang.reflect.Method.invoke(Method.java:521)
07-02 18:06:39.752: ERROR/AndroidRuntime(354):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
07-02 18:06:39.752: ERROR/AndroidRuntime(354):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
07-02 18:06:39.752: ERROR/AndroidRuntime(354):     at dalvik.system.NativeStart.main(Native Method)

What is wrong with my MapActivity? Why is it not found?

My MapActivity's Code:

import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;

import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;

import org.xml.sax.InputSource;
import org.xml.sax.XMLReader;

import android.content.Context;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.inputmethod.InputMethodManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RelativeLayout;

import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapController;
import com.google.android.maps.MapView;
import com.google.android.maps.Overlay;
import com.google.android.maps.OverlayItem;

public class Map extends MapActivity {

ArrayList<ListCellInfo> mapsearchresults=new ArrayList<ListCellInfo>();

MapView mapView;
List<Overlay> mapOverlays;
MapController myMapController;

MyXMLHandler myXMLHandler = new MyXMLHandler();

public static int flag=0;

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

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.map);

    final EditText SearchForMap = (EditText) findViewById(R.id.editTextmap);

    Button bckbtn = (Button) findViewById(R.id.retourmap);
    bckbtn.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {

            if (Details.back_activity_flag == 1) {

                InputMethodManager mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
                mgr.hideSoftInputFromWindow(SearchForMap.getWindowToken(), 0);
                Intent myIntent = new Intent(v.getContext(), Details.class);
                Activity1.group.replaceContentView("Details", myIntent);

            }
            else if (Details.back_activity_flag == 2) {

                InputMethodManager mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
                mgr.hideSoftInputFromWindow(SearchForMap.getWindowToken(), 0);
                Intent myIntent = new Intent(v.getContext(), Details.class);
                Activity2.group.replaceContentView("Details", myIntent);

            }
            else if (Details.back_activity_flag == 3) {

                InputMethodManager mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
                mgr.hideSoftInputFromWindow(SearchForMap.getWindowToken(), 0);
                Intent myIntent = new Intent(v.getContext(), Details.class);
                Activity3.group.replaceContentView("Details", myIntent);

            }

        }
    });

    mapView = (MapView) findViewById(R.id.mapview);
    mapView.setBuiltInZoomControls(true);

    mapOverlays = mapView.getOverlays();
    Drawable drawable = this.getResources().getDrawable(R.drawable.black_pin_img);
    MapItemizedOverlay itemizedoverlay = new MapItemizedOverlay(drawable,this);

    /*Log.v("Details Lattitude",(int)(Details.lattitude* 1e6)+"");
    Log.v("Details Longitude",(int)(Details.longitude* 1e6)+"");*/

    GeoPoint point = new GeoPoint((int)(Details.lattitude* 1e6),(int)(Details.longitude* 1e6));

    mapView.setFocusable(true);
    myMapController = mapView.getController();
    myMapController.animateTo(point);
    myMapController.setZoom(18);
    myMapController.setCenter(point);

    OverlayItem overlayitem = new OverlayItem(point, Details.name, "");

    itemizedoverlay.addOverlay(overlayitem);
    mapOverlays.add(itemizedoverlay);

    mapView.setStreetView(true);


    RelativeLayout relativelayout = (RelativeLayout) findViewById(R.id.relativeLayoutmap);
    relativelayout.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {

            InputMethodManager mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
            mgr.hideSoftInputFromWindow(SearchForMap.getWindowToken(), 0);

        }
    });

    final MapItemizedOverlay itemizedoverlay1=itemizedoverlay;

    Button searchBtn = (Button) findViewById(R.id.searchbuttonmap);
    searchBtn.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {

            InputMethodManager mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
            mgr.hideSoftInputFromWindow(SearchForMap.getWindowToken(), 0);

            String getSearchText = SearchForMap.getText().toString();

            if(getSearchText.length()!=0){

                String[] fav=getSearchText.split(",");

                try {

                    /** Handling XML */
                    SAXParserFactory spf = SAXParserFactory.newInstance();
                    SAXParser sp = spf.newSAXParser();
                    XMLReader xr = sp.getXMLReader();

                    /** Send URL to parse XML Tags */

                    InputStream inputFile;

                    SharedPreferences flag = getSharedPreferences(iSenegal.Flag, MODE_PRIVATE);
                    String getFlag = flag.getString("Flag", "");

                    if(getFlag.equals("0"))
                        inputFile = getResources().openRawResource(R.raw.alldata);
                    else
                        inputFile = new BufferedInputStream(new FileInputStream("/sdcard/alldata.xml"));

                    xr.setContentHandler(myXMLHandler);
                    xr.parse(new InputSource(inputFile));

                } catch (Exception e) {
                    System.out.println("XML Pasing Excpetion = " + e);

                }

         开发者_StackOverflow社区       for(int i=0;i<fav.length;i++){

                    for(int j=0;j<myXMLHandler.results.size();j++){

                        if(myXMLHandler.results.get(j).getSearchTag().toLowerCase().contains(fav[i].toLowerCase()))
                          mapsearchresults.add(myXMLHandler.results.get(j));

                    }
                }
                myXMLHandler.results.clear();

                if(!mapView.getOverlays().isEmpty()) 
                { 
                    mapOverlays.clear();
                    itemizedoverlay1.mOverlays.clear();
                    mapView.invalidate();

                }

                if(mapsearchresults.size()>0){

                    GeoPoint cpoint = new GeoPoint((int)(14.745335 * 1e6),(int)(-17.42157 * 1e6));

                    mapView.setFocusable(true);
                    myMapController = mapView.getController();
                    myMapController.animateTo(cpoint);
                    myMapController.setZoom(7);
                    myMapController.setCenter(cpoint);

                    for(int k=0;k<mapsearchresults.size();k++){

                        GeoPoint point1 = new GeoPoint((int)((mapsearchresults.get(k).getLatitude())* 1e6),(int)((mapsearchresults.get(k).getLongitude())* 1e6));
                        OverlayItem overlayitem1 = new OverlayItem(point1, mapsearchresults.get(k).getName(), "");

                        itemizedoverlay1.addOverlay(overlayitem1);
                        mapOverlays.add(itemizedoverlay1);

                    }
                    mapView.invalidate();
                    mapsearchresults.clear();

                }

            }

        }
    });

}

}

My Manifest File's Code:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.x.iSenegal"
  android:versionCode="1"
  android:versionName="1.0">
<uses-sdk android:minSdkVersion="8" />

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.INTERNET"/> 
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>

<application android:icon="@drawable/icon" android:label="@string/app_name">

    <uses-library android:name="com.google.android.maps" />

    <activity android:name=".iSenegal"
              android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
              android:label="@string/app_name"
              android:configChanges="keyboardHidden|orientation" android:screenOrientation="portrait">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

    <activity android:configChanges="keyboardHidden|orientation" android:screenOrientation="portrait" android:name="Activity1" android:theme="@android:style/Theme.NoTitleBar.Fullscreen"></activity>
    <activity android:configChanges="keyboardHidden|orientation" android:screenOrientation="portrait" android:name="Activity2" android:theme="@android:style/Theme.NoTitleBar.Fullscreen"></activity>
    <activity android:configChanges="keyboardHidden|orientation" android:screenOrientation="portrait" android:name="Activity3" android:theme="@android:style/Theme.NoTitleBar.Fullscreen"></activity>
    <activity android:configChanges="keyboardHidden|orientation" android:screenOrientation="portrait" android:name="Activity4" android:theme="@android:style/Theme.NoTitleBar.Fullscreen"></activity>
    <activity android:configChanges="keyboardHidden|orientation" android:screenOrientation="portrait" android:name="Activity5" android:theme="@android:style/Theme.NoTitleBar.Fullscreen"></activity>
    <activity android:configChanges="keyboardHidden|orientation" android:screenOrientation="portrait" android:name="Categories" android:theme="@android:style/Theme.NoTitleBar.Fullscreen"></activity>
    <activity android:configChanges="keyboardHidden|orientation" android:screenOrientation="portrait" android:name="Results" android:theme="@android:style/Theme.NoTitleBar.Fullscreen"></activity>
    <activity android:configChanges="keyboardHidden|orientation" android:screenOrientation="portrait" android:name="Details" android:theme="@android:style/Theme.NoTitleBar.Fullscreen"></activity>
    <activity android:configChanges="keyboardHidden|orientation" android:screenOrientation="portrait" android:name="Favoris" android:theme="@android:style/Theme.NoTitleBar.Fullscreen"></activity>
    <activity android:configChanges="keyboardHidden|orientation" android:screenOrientation="portrait" android:name="Recherche" android:theme="@android:style/Theme.NoTitleBar.Fullscreen"></activity>
    <activity android:configChanges="keyboardHidden|orientation" android:screenOrientation="portrait" android:name="SearchResults" android:theme="@android:style/Theme.NoTitleBar.Fullscreen"></activity>
    <activity android:configChanges="keyboardHidden|orientation" android:screenOrientation="portrait" android:name="Map" android:theme="@android:style/Theme.NoTitleBar.Fullscreen"></activity>


</application>


are you using google add-on for map activity(for maps you should use google add-on),check whether you are using it or not.If you are using check do u have the line "import com.google.android.maps.MapActivity;" in your source code instead "java.util.Map",Map and MapActivity both are different.can you post code snippet for more information.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜