Do we get any event in the Activity when the activity gets re-sized?

by Dianne Hackborn » Thu, 17 Sep 2009 12:10:33 GMT


Sponsored Links
 As I said, the window gets resized, not the activity.  The activity doesn't
have a size.








-- 
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. looking for android games (source code + rights) to buy

Hi there,

I am looking for android games to buy, the rights and source code. Any
interested developers/game companies do drop me a message. Thanks!

Zee

-- 

2. Map Overlays Null Pointer Exception..pls help

Hello guys,
 i have written the code to find the GPS location , it was working
fine. later i have added one class for overlays but now its giving me
nullpointer exception on populate function.

the code is below

***************************************

package com.spsoft.lbs.gps;

import java.util.ArrayList;
import java.util.List;

import android.app.AlertDialog;
import android.content.Context;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.widget.Toast;

import com.google.android.maps.GeoPoint;
import com.google.android.maps.ItemizedOverlay;
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 GPSMapActivity extends MapActivity {
        private LocationManager lm;
        private LocationListener locationListener;

        private MapView mapView;
        private MapController mc;
        double lat;
        double lan;
        final long E6 = 1000000;
        private GeoPoint p;

        /** Called when the activity is first created. */
        @Override
        public void onCreate(Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);
                setContentView(R.layout.gps);

                // ---use the LocationManager class to obtain GPS locations---
                lm = (LocationManager) 
getSystemService(Context.LOCATION_SERVICE);

                locationListener = new MyLocationListener();

                lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 200, 
200,
                                locationListener);

                Log
                                .v(getClass().getName(),
                                                
"*********************************************after time
interval");

                mapView = (MapView) findViewById(R.id.mapview1);

                List<Overlay> mapOverlays = mapView.getOverlays();
                Drawable drawable =
this.getResources().getDrawable(R.drawable.icon);
                HelloItemizedOverlay itemizedoverlay = new HelloItemizedOverlay(
                                drawable);

                OverlayItem overlayitem = new OverlayItem(p, "Hi!", "I am 
here!");

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

                mc = mapView.getController();
        }

        @Override
        protected boolean isRouteDisplayed() {
                // TODO Auto-generated method stub
                return false;
        }

        private class MyLocationListener implements LocationListener {

                public void onLocationChanged(Location loc) {

                        // TODO Auto-generated method stub
                        if (loc != null) {
                                Toast.makeText(
                                                getBaseContext(),
                                                "Location changed : Lat: " + 
loc.getLatitude()
                                                                + " Lng: " + 
loc.getLongitude(),
                                                Toast.LENGTH_SHORT).show();

                                GeoPoint p = new GeoPoint((int) 
(loc.getLatitude() * 1E6),
                                                (int) (loc.getLongitude() * 
1E6));
                                mc.animateTo(p);
                                mc.setZoom(16);
                                mapView.invalidate();
                                Log.i("the values in GPS class are:", "lat:"
                                                + loc.getLatitude() + "lan:" + 
loc.getLongitude());
                        }
                }

                public void onProviderDisabled(String provider) {
                        // TODO Auto-generated method stub

                }

                public void onProviderEnabled(String provider) {
                        // TODO Auto-generated method stub

                }

                public void onStatusChanged(String provider, int status, Bundle
extras) {
                        // TODO Auto-generated method stub
                }
        }

        public boolean onCreateOptionsMenu(Menu menu) {
                MenuInflater inflater = getMenuInflater();
                inflater.inflate(R.menu.menu, menu);
                return true;
        }

        public boolean onOptionsItemSelected(MenuItem item) {

                switch (item.getItemId()) {
                case R.id.mapview:
                        performToggleMap();
                        break;
                case R.id.satelliteview:
                        performToggleSatellite();
                        break;
                case R.id.trafficview:
                        performToggleTraffic();
                        break;
                case R.id.findlocation:
                        Intent intent = new Intent(GPSMapActivity.this,
                                        SearchActivity.class);
                        intent.putExtra("lat", lat);
                        intent.putExtra("lan", lan);
                        Log.i("the values in find button click are:", "lat:" + 
lat + "lan:"
                                        + lan);

                        startActivity(intent);
                        break;
                }
                return true;

        }

        public boolean performToggleSatellite() {
                // Switch on the satellite images
                mapView.setSatellite(true);
                return true;
        }

        public boolean performToggleTraffic() {
                // Switch on traffic overlays
                mapView.setTraffic(true);
                Toast.makeText(getBaseContext(),
                                "Traffic info not available for this location ",
                                Toast.LENGTH_SHORT).show();
                return true;
        }

        public boolean performToggleMap() {
                // Switch on map overlays
                mapView.setSatellite(false);
                return true;
        }

        @Override
        protected void onDestroy() {
                // TODO Auto-generated method stub
                super.onDestroy();
        }

        @Override
        protected void onResume() {
                // TODO Auto-generated method stub
                super.onResume();
        }

        @Override
        protected void onRestart() {
                // TODO Auto-generated method stub
                super.onRestart();
        }

        @Override
        protected void onPause() {
                // TODO Auto-generated method stub
                super.onPause();
        }

        private class HelloItemizedOverlay extends ItemizedOverlay {
                private ArrayList<OverlayItem> mOverlays = new
ArrayList<OverlayItem>();
                Context mContext;

                public HelloItemizedOverlay(Drawable defaultMarker) {
                        super(boundCenterBottom(defaultMarker));
                }

                public void addOverlay(OverlayItem overlay) {
                        mOverlays.add(overlay);
                        populate();
                }

                @Override
                protected OverlayItem createItem(int i) {
                        // TODO Auto-generated method stub
                        return mOverlays.get(i);
                }

                @Override
                public int size() {
                        // TODO Auto-generated method stub
                        return mOverlays.size();
                }

                public HelloItemizedOverlay(Drawable defaultMarker, Context 
context)
{
                        super(defaultMarker);
                        mContext = context;

                }

                @Override
                protected boolean onTap(int index) {
                        OverlayItem item = mOverlays.get(index);
                        AlertDialog.Builder dialog = new AlertDialog.Builder(
                                        GPSMapActivity.this);
                        dialog.setTitle(item.getTitle());
                        dialog.setMessage(item.getSnippet());
                        dialog.show();
                        return true;
                }

        }

}
*****************************************

please solve my issues

-- 

3. IMAP Version in android

4. App freezes when the power key is pressed

5. Galaxy Tab vs Dell Streak vs iPad 3G 16GB

6. prevent user from clearing app data

7. OOT: SitraWiMAX