Maps not rendering when used as child in activity group

Put problem concerning MapActivities, MapViews, Overlays and GPS in this forum.

Maps not rendering when used as child in activity group

Postby herge » Fri Oct 23, 2009 7:52 am

Hi!

I have a slight problem with my android application. My thought was to re-use as many acitivites as possible in different places so I thought an activity group would be the best shot for me to use in some places and hence I would be able to re-use my map and a couple of ListActivities

On one screen I have a "standalone" map, that is, a map ativity shown over the entire screen and that works just fine. The problem comes when I try to add tjis map activity to an ActivityGroup just below a ListAcitivity. The list works just as it should be the map just refuses to render! Even though it doesn't show the map itself I can still se how the map keeps switching position when i click something in my list (tells it to move to the adress specified in the list). I really don't get it, there must be something I forgot to do when adding the MapActivity to the ActivityGroup!?

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2.  
  3.  
  4. // create new LinearLayout and
  5.  
  6. LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
  7.  
  8.                                 LinearLayout.LayoutParams.FILL_PARENT,
  9.  
  10.                                 LinearLayout.LayoutParams.WRAP_CONTENT);
  11.  
  12. LinearLayout l = new LinearLayout(this);
  13.  
  14. l.setLayoutParams(lp);
  15.  
  16. l.setOrientation(LinearLayout.VERTICAL);
  17.  
  18.  
  19.  
  20. LocalActivityManager localActivityManager = this
  21.  
  22.                                 .getLocalActivityManager();
  23.  
  24.  
  25.  
  26. // our 2 different intents to be started.
  27.  
  28. Intent map = new Intent(this, ShowMapActivity.class);
  29.  
  30. Intent hallplatser = new Intent(this,ListaHallplatserINarhetenActivity.class);
  31.  
  32.  
  33.  
  34. // start the activities
  35.  
  36. View mapview = localActivityManager.startActivity(KARTA_ID, map )
  37.  
  38.                                 .getDecorView();
  39.  
  40. View hallplatsview = localActivityManager.startActivity(HALLPLATS_ID,
  41.  
  42.                                 hallplatser).getDecorView();
  43.  
  44.  
  45.  
  46. WindowManager w = getWindowManager();
  47.  
  48. Display d = w.getDefaultDisplay();
  49.  
  50. int width = d.getWidth();
  51.  
  52. int height = d.getHeight();
  53.  
  54. map view.setLayoutParams(new ViewGroup.LayoutParams(
  55.  
  56.                                 ViewGroup.LayoutParams.FILL_PARENT, height / 2));
  57.  
  58. hallplatsview.setLayoutParams(new ViewGroup.LayoutParams(
  59.  
  60.                                 ViewGroup.LayoutParams.FILL_PARENT, height / 2));
  61.  
  62.  
  63.  
  64. // add the both views to the linearlayout and set it as the contentview
  65.  
  66. l.addView(hallplatsview);
  67.  
  68. l.addView(mapview);
  69.  
  70.  
  71.  
  72. setContentView(l);
  73.  
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  
  80.  
Parsed in 0.035 seconds, using GeSHi 1.0.8.4


As I said before, the ShowMapActivity works just fine on it's own but not when added to this activity group, any suggestions? :)
Best Regards
Ulf
------------------------------------
http://blogherge.blogspot.com/
herge
Freshman
Freshman
 
Posts: 5
Joined: Mon Oct 05, 2009 7:03 am
Location: Sweden

Top

Postby herge » Wed Oct 28, 2009 9:27 am

Really couldn't get it to work :(

The workaround was to use implement my own list (not extending ListActivity) and then let the class extend MapActivity. The map now renders nicely. However this means i can't re-use my old activites, that would have been extremly nice. Will consider to report it as a bug.
Best Regards
Ulf
------------------------------------
http://blogherge.blogspot.com/
herge
Freshman
Freshman
 
Posts: 5
Joined: Mon Oct 05, 2009 7:03 am
Location: Sweden

Postby padde » Wed Oct 28, 2009 9:43 am

this isnt a bug.. its written in the docs that only classes extending mapactivity can display maps.
padde
Master Developer
Master Developer
 
Posts: 443
Joined: Wed Apr 08, 2009 4:52 pm

Postby herge » Mon Nov 02, 2009 10:33 am

Yes the documentation clearly states so but that doesn't make any sense in this case if you ask me. Ofcourse the childactivity which is supposed to show the map extends MapActivity and as I said before it works then using it "stand alone". I can see the zoom-controls, and the background grid but the graphics (the map itself so to say) doesn't show, sounds lika a bug to me!

Maybe I wasn't clear enough about the problem.
Best Regards
Ulf
------------------------------------
http://blogherge.blogspot.com/
herge
Freshman
Freshman
 
Posts: 5
Joined: Mon Oct 05, 2009 7:03 am
Location: Sweden

Postby padde » Tue Nov 03, 2009 7:10 pm

Well.. is till think its working as intended. Even though the intention to force this behaviour
is incomprehensible to me. If you report this as a bug please keep this thread updated with
the response from the android team :)
padde
Master Developer
Master Developer
 
Posts: 443
Joined: Wed Apr 08, 2009 4:52 pm

Top

Return to Map Problems

Who is online

Users browsing this forum: No registered users and 3 guests