Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/195.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 使用SupportMapFragment完成活动时发出致命信号11_Android_Google Maps_Android Fragmentactivity - Fatal编程技术网

Android 使用SupportMapFragment完成活动时发出致命信号11

Android 使用SupportMapFragment完成活动时发出致命信号11,android,google-maps,android-fragmentactivity,Android,Google Maps,Android Fragmentactivity,我有一个模型,我需要添加一个位置。为此,我将使用地图启动LocationPickerActivity,以便用户查找位置。有时,当退出活动时,我收到致命信号11,应用程序重新启动 设置: Mac OSX 10.9.5, Nexus S,谷歌API x86 API 19, API 19 4.4.2 我的大部分代码来自 位置选择器活性 活动\u位置\u picker.xml LogCat GoogleMap googleMap; MarkerOptions markerOptions;

我有一个模型,我需要添加一个位置。为此,我将使用地图启动LocationPickerActivity,以便用户查找位置。有时,当退出活动时,我收到致命信号11,应用程序重新启动

设置: Mac OSX 10.9.5, Nexus S,谷歌API x86 API 19, API 19 4.4.2

我的大部分代码来自

位置选择器活性

活动\u位置\u picker.xml

LogCat

    GoogleMap googleMap;
    MarkerOptions markerOptions;
    LatLng latLng;
    SupportMapFragment mapFragment;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_location_picker);

        mapFragment = (SupportMapFragment) 
                getSupportFragmentManager().findFragmentById(R.id.map);

        // Getting a reference to the map
        googleMap = mapFragment.getMap();

        // Getting reference to btn_find of the layout activity_main
        Button btn_find = (Button) findViewById(R.id.btn_find);

        // Defining button click event listener for the find button
        OnClickListener findClickListener = new OnClickListener() {         
            @Override
            public void onClick(View v) {
                // Getting reference to EditText to get the user input location
                EditText etLocation = (EditText) findViewById(R.id.et_location);

                // Getting user input location
                String location = etLocation.getText().toString();

                if(location!=null && !location.equals("")){
                    new GeocoderTask().execute(location);
                }
            }
        };

        // Setting button click event listener for the find button
        btn_find.setOnClickListener(findClickListener);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.location_picker, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {

        switch(item.getItemId()) {
            case R.id.action_accept: {
                updateLocation();
                return true;
            }
            case R.id.action_cancel: {
                finish();
                return true;
            }
            default:
                return super.onOptionsItemSelected(item);
        }
    }



    @Override
    protected void onDestroy() {
        googleMap = null;
        new GeocoderTask().cancel(true);
        //getSupportFragmentManager().beginTransaction().remove(mapFragment).commit();
        super.onDestroy();
    }

    private void updateLocation() {
        Bundle extras = new Bundle();
        extras.putString("ADDRESS", "test");
        extras.putDouble("LAT", 10.00);
        extras.putDouble("LNG", 20.00);

        Intent result = new Intent();
        result.putExtras(extras);

        setResult(RESULT_OK, result);
        finish();
    }


    // An AsyncTask class for accessing the GeoCoding Web Service
    private class GeocoderTask extends AsyncTask<String, Void, List<Address>>{

        @Override
        protected List<Address> doInBackground(String... locationName) {
            // Creating an instance of Geocoder class
            Geocoder geocoder = new Geocoder(getBaseContext());
            List<Address> addresses = null;

            try {
                // Getting a maximum of 3 Address that matches the input text
                addresses = geocoder.getFromLocationName(locationName[0], 3);
            } catch (IOException e) {
                e.printStackTrace();
            }           
            return addresses;
        }


        @Override
        protected void onPostExecute(List<Address> addresses) {         

            if(addresses==null || addresses.size()==0){
                Toast.makeText(getBaseContext(), "No Location found", Toast.LENGTH_SHORT).show();
            }

            // Clears all the existing markers on the map
            googleMap.clear();

            // Adding Markers on Google Map for each matching address
            for(int i=0;i<addresses.size();i++){                

                Address address = (Address) addresses.get(i);

                Log.d("SEARCH_RESULT", address.toString());

                // Creating an instance of GeoPoint, to display in Google Map
                latLng = new LatLng(address.getLatitude(), address.getLongitude());

                String addressText = String.format("%s, %s",
                        address.getMaxAddressLineIndex() > 0 ? address.getAddressLine(0) : "",
                        address.getCountryName());

                markerOptions = new MarkerOptions();
                markerOptions.position(latLng);
                markerOptions.title(addressText);

                googleMap.addMarker(markerOptions);

                // Locate the first location
                if(i==0) {
                    googleMap.animateCamera(CameraUpdateFactory.newLatLngZoom(latLng, 18));
                }

            }           
        }       
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:map="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    >    

    <RelativeLayout 
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >      

        <Button 
            android:id="@+id/btn_find"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" 
            android:text="Find" 
            android:layout_alignParentRight="true" />

        <EditText
            android:id="@+id/et_location"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"        
            android:inputType="text" 
            android:hint="Enter address"
            android:layout_toLeftOf="@id/btn_find" />

    </RelativeLayout>    

    <fragment
        android:id="@+id/map"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        class="com.google.android.gms.maps.SupportMapFragment" />

</LinearLayout>
11-16 00:10:14.386: D/(2161): HostConnection::get() New Host Connection established 0xb96ae060, tid 2213
11-16 00:10:14.416: D/USER_EVENTS(2161): Event: type=58, status: gl, data: |r=8|g=8|b=8|a=8|d=24|s=8|v=Google (NVIDIA Corporation)|i=OpenGL ES-CM 1.1 (2.1 NVIDIA-8.26.28 310.40.55b01)|c=Android Emulator OpenGL ES Translator (NVIDIA GeForce GT 650M OpenGL Engine)|e=t|
11-16 00:10:14.436: D/REQUEST(2161): Processing DataRequest: com.google.maps.api.android.lib6.b.d@b166eae0
11-16 00:10:14.436: D/REQUEST(2161): Processing DataRequest: com.google.maps.api.android.lib6.c.au@b166e0b0
11-16 00:10:14.436: D/REQUEST(2161): DRD(3): 62|147, <1s, <1kb
11-16 00:10:14.436: D/REQUEST(2161): Close
11-16 00:10:14.436: D/USER_EVENTS(2161): Event: type=22, status: fb, data: 111
11-16 00:10:14.436: D/USER_EVENTS(2161): Event: type=22, status: lb, data: 112
11-16 00:10:14.436: D/USER_EVENTS(2161): Event: type=22, status: flbs, data: fb=111|lb=112|s=16
11-16 00:10:14.456: I/ActivityManager(1262): Displayed hioa.andreas.discount/.LocationPickerActivity: +197ms
11-16 00:10:14.476: D/dalvikvm(2161): GC_FOR_ALLOC freed 1604K, 19% free 9439K/11584K, paused 13ms, total 23ms
11-16 00:10:14.536: D/REQUEST(2161): Add Data Request: 7
11-16 00:10:14.586: D/dalvikvm(2161): GC_FOR_ALLOC freed 824K, 19% free 9397K/11584K, paused 7ms, total 10ms
11-16 00:10:14.586: I/dalvikvm-heap(2161): Grow heap (frag case) to 10.241MB for 1048588-byte allocation
11-16 00:10:14.606: D/dalvikvm(2161): GC_FOR_ALLOC freed 2K, 18% free 10419K/12612K, paused 19ms, total 19ms
11-16 00:10:14.616: D/REQUEST(2161): Add Data Request: 108
11-16 00:10:14.636: D/REQUEST(2161): Connection opened to:https://clients4.google.com/glm/mmap/api
11-16 00:10:14.646: D/REQUEST(2161): Open Connection
11-16 00:10:14.756: D/REQUEST(2161): Processing DataRequest: com.google.maps.api.android.lib6.b.d@b1674420
11-16 00:10:14.766: D/REQUEST(2161): Processing DataRequest: com.google.maps.api.android.lib6.b.v@b13988b0
11-16 00:10:14.766: D/REQUEST(2161): Processing DataRequest: com.google.maps.api.android.lib6.gmm6.m.af@b14c4d08
11-16 00:10:14.796: D/USER_EVENTS(2161): Event: type=22, status: fb, data: 112
11-16 00:10:14.806: D/USER_EVENTS(2161): Event: type=22, status: lb, data: 144
11-16 00:10:14.806: D/USER_EVENTS(2161): Event: type=22, status: flbs, data: fb=112|lb=144|s=66021
11-16 00:10:14.806: D/REQUEST(2161): Sent 662, Loaded 66021 bytes.  Byte/Sec = 458479
11-16 00:10:14.806: D/REQUEST(2161): DRD(4): 62|7|108, <1s, 66kb
11-16 00:10:14.806: D/REQUEST(2161): Close
11-16 00:10:14.876: D/dalvikvm(2161): GC_FOR_ALLOC freed 1408K, 25% free 9532K/12612K, paused 23ms, total 23ms
11-16 00:10:14.946: D/dalvikvm(2161): GC_FOR_ALLOC freed 1414K, 25% free 9505K/12612K, paused 6ms, total 6ms
11-16 00:10:14.986: D/dalvikvm(2161): GC_FOR_ALLOC freed 1084K, 25% free 9511K/12612K, paused 6ms, total 6ms
11-16 00:10:19.586: D/dalvikvm(2161): GC_FOR_ALLOC freed 2000K, 25% free 9558K/12612K, paused 6ms, total 6ms
11-16 00:10:19.746: E/SoundPool(1262): error loading /system/media/audio/ui/Effect_Tick.ogg
11-16 00:10:19.746: W/AudioService(1262): Soundpool could not load file: /system/media/audio/ui/Effect_Tick.ogg
11-16 00:10:19.746: E/SoundPool(1262): error loading /system/media/audio/ui/Effect_Tick.ogg
11-16 00:10:19.746: W/AudioService(1262): Soundpool could not load file: /system/media/audio/ui/Effect_Tick.ogg
11-16 00:10:19.746: E/SoundPool(1262): error loading /system/media/audio/ui/Effect_Tick.ogg
11-16 00:10:19.746: W/AudioService(1262): Soundpool could not load file: /system/media/audio/ui/Effect_Tick.ogg
11-16 00:10:19.746: E/SoundPool(1262): error loading /system/media/audio/ui/Effect_Tick.ogg
11-16 00:10:19.746: W/AudioService(1262): Soundpool could not load file: /system/media/audio/ui/Effect_Tick.ogg
11-16 00:10:19.746: E/SoundPool(1262): error loading /system/media/audio/ui/Effect_Tick.ogg
11-16 00:10:19.746: W/AudioService(1262): Soundpool could not load file: /system/media/audio/ui/Effect_Tick.ogg
11-16 00:10:19.746: E/SoundPool(1262): error loading /system/media/audio/ui/KeypressStandard.ogg
11-16 00:10:19.746: W/AudioService(1262): Soundpool could not load file: /system/media/audio/ui/KeypressStandard.ogg
11-16 00:10:19.746: E/SoundPool(1262): error loading /system/media/audio/ui/KeypressSpacebar.ogg
11-16 00:10:19.746: W/AudioService(1262): Soundpool could not load file: /system/media/audio/ui/KeypressSpacebar.ogg
11-16 00:10:19.746: E/SoundPool(1262): error loading /system/media/audio/ui/KeypressDelete.ogg
11-16 00:10:19.746: W/AudioService(1262): Soundpool could not load file: /system/media/audio/ui/KeypressDelete.ogg
11-16 00:10:19.746: E/SoundPool(1262): error loading /system/media/audio/ui/KeypressReturn.ogg
11-16 00:10:19.746: W/AudioService(1262): Soundpool could not load file: /system/media/audio/ui/KeypressReturn.ogg
11-16 00:10:19.746: E/SoundPool(1262): error loading /system/media/audio/ui/KeypressInvalid.ogg
11-16 00:10:19.746: W/AudioService(1262): Soundpool could not load file: /system/media/audio/ui/KeypressInvalid.ogg
11-16 00:10:19.746: W/AudioService(1262): onLoadSoundEffects(), Error -1 while loading samples
11-16 00:10:19.806: W/EGL_emulation(2161): eglSurfaceAttrib not implemented
11-16 00:10:20.206: A/libc(2161): Fatal signal 11 (SIGSEGV) at 0x30133153 (code=1), thread 2213 (Thread-118)
11-16 00:10:20.336: I/DEBUG(924): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
11-16 00:10:20.336: I/DEBUG(924): Build fingerprint: 'generic_x86/google_sdk_x86/generic_x86:4.4.2/KK/1532129:eng/test-keys'
11-16 00:10:20.336: I/DEBUG(924): Revision: '0'
11-16 00:10:20.336: I/DEBUG(924): pid: 2161, tid: 2213, name: Thread-118  >>> hioa.andreas.discount <<<
11-16 00:10:20.336: I/DEBUG(924): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 30133153
11-16 00:10:20.476: I/DEBUG(924): memory map around fault addr 30133153:
11-16 00:10:20.476: I/DEBUG(924):     (no map below)
11-16 00:10:20.476: I/DEBUG(924):     (no map for address)
11-16 00:10:20.476: I/DEBUG(924):     a4c75000-a4c76000 --- 
11-16 00:10:20.516: I/BootReceiver(1262): Copying /data/tombstones/tombstone_01 to DropBox (SYSTEM_TOMBSTONE)
11-16 00:10:20.526: D/Zygote(927): Process 2161 terminated by signal (11)