I have two activity groups that contain a list that go to a detail view. The detail activty extends a mapactivity. Once I set the lat/long and add the point and center it everything works great. If I go to the other activity to do the same thing, both maps are changing with each lat/long change. The code and view xml are seperate, so why are both maps changing to the same lat/long?
If you look at the docs for MapActivity, it says: only one MapActivity is supported per process. Ignoring this causes all sorts of problems besides the ones you are experiencing. The workaround is to put one of the MapActivities in a separate process. To do this modify the manifest entry for one of your activities and add the android:process attribute, like:
<activity android:name="MapActivity2" android:process=":MapActivity2">
Note that there are downsides to putting one of the activities in a separate process.
Related
Good Day everyone.I have searched internet and hardly found that it can't be like that but i really can't believe.So i decided to ask here whether is it possible to inflate layout which will have its own activity i mean JAVA CLASS where i would type the code.So just for this case.Imagine we must have google maps on screen and as well as separate screen of list view people all nearby.So in that point we want to inflate the layout onto google maps view.But as i can logically think it will be horrible to write code all in one class by side of performance,so I'm looking for alternatives to inflating a layout,is somehow we can bring activity on main screen and don't lose that screen as well?This is all questions.Thank you very much beforehand!
If I have understood you right, you want to have two layouts in one Activity?
You should use Fragments for it purpose. You can add as many as you want in one Activity, and manage them dynamically. You can find solution here. Also, look at this solution.
I have been trying to find a way to get this done but keep running into issues.
I want to be able to have a map in a frame (it does not necessarily have to be a FrameLayout, i just want it framed so it only takes up 1/2 or 2/3 the screen) ontop of my current layout and to have the current activity still displayed behind it.
In a perfect world, i would like to attach this view to a button and animation so clicking the button causes this view to slide in from offscreen left and settle in the center of my current activity, while still being fully clickable and and the map being useable (can zoom, click, etc.)
I have tried doing this with a fragment, but the issue is that the Activity i am working in is already extending another class that is absolutely necessary, so i can not extend Fragment or FragmentActivity, so i cant use fragments (unless i am missing a work around to achieve this.)
The same goes for MapActivity and MapView, cant extend the MapActivity class so cant use MapView.
Any time i try to inflate a map view or anything i get runtime errors because my activity does not extend the pertinent class. Is there a work around for this?
Does anyone have a suggestion as to how i can get this map to display the way i am looking for?
This is easily achieved in iOS but i cant seem to figure it out in Android.
Thank you in advance
EDIT
I am not looking for code, unless you have a specific example in which case obviously code is very helpful, but i am looking for an idea as to how to achieve this -- a push in the right direction if you will -- so i can write the code myself.
Solved this by adding a frame layout to my "Main" activity. That frame layout's class was set to my Map class. The Map class extended FragmentActivity and its contentView is set to my map_fragment.xml. The map_fragment.xml contains only a fragment and that fragments name is set to com.google.android.....SupportMapFragment.
After setting up my project in this way as well as setting up the correct screen layouts and dimensions for sizing purposes as well as defining a GoogleMap in my Map class, i was able to display a fully usable and interactive map over my "Main" activity.
I overrode some Activity transition animations to the Map class and got my project working 100% how i want it to.
I didnt ask for code, so i will not supply any code, but this process is pretty straight-forward if you follow the same process as i have described above.
I've read the Google TV Design Patterns article and still can't figure out how to change the default "global" zone size/position or how to get more than one item to show up in it.
There are some vague (to me) statements. E.g.: "Because the global zone persists throughout the life of the application, you should not allow it to take up too much screen space.". (OK, how do I change it in the layout?)
It then states that the global zone "[...] holds all of the top-level 'global' items in your application hierarchy [...]". Then goes on to state "It also contains all the categories for your application [...]"
What is considered a global item? An activity with a "LAUNCHER" and "MAIN" <intent-filter> category and action? (Tried that and no joy)
What do "categories" mean? Categories as defined in each activity's <intent-filter> "category" manifest entry? (Tried that too and no joy)
I've run through the SDK's ApiDemos code relating to Fragments and it's not jumping out at me. I have successfully ported part of an existing app to extend Fragment and ListFragment but for the life of me can't figure this one out.
The global zone could be implemented by a fragment that is the size you wish it to be. There are no requirements that you use something else, like an ActionBar.
I have a mapview in one activity on which i drew a path, now i would transfer this mapview to another activity, how can i do?
You can't really transfer controls that way: you'd have to do a remove() to undo the root view bindings and then hope and pray that it works when you re-add it, and to complicate things the MapView mixes in with the MapActivity in complex ways so this will probably fail.
See http://code.google.com/android/add-ons/google-apis/reference/com/google/android/maps/MapActivity.html. Notice the line that says
Only one MapActivity is supported per
process. Multiple MapActivities
running simultaneously are likely to
interfere in unexpected and undesired
ways.
That means you probably can't do what you want.
This question actually has two parts.
The first part:
I've been developing my first app for a couple of weeks now. I have 5 screens and everything seems well. However, I'm considering changing the app's navigation to a TabView.
I haven't delved much into it, but I'm hoping someone can save me a little bit of time. It seems that people don't generally place Activities inside each tab. They simply point the tab content to a View. This is where my major setbacks are. 1) I already have Activity classes full of code and 2) I can't quickly guess how the structure of an app using TabView looks. For example, where do I put the handler code for clicking a button on a View? Does it all just get dumped into the TabView Activity somehow?
What I would like is if you could please give me a quick synopsis of what I'm looking at doing, answers to any questions you think I may have, and point me toward some resources for creating TabView applications. A quick Google search really just shows me how to create a TabView Activity and add a couple tabs to it. The code doesn't go any deeper. For example, say I have a layout xml to show in one of my tab's content pane, where does the code go for clicking a button I have in that layout?
The second part:
I've added a TabActivity to wrap the Activities I currently have in. At the moment I have Activities populating the content of my tabs (though ultimately I'd like to do this in the most efficient fashion, which doesn't seem to be having Activities be tab content). I've noticed something rather annoying. My MAIN Activity is an Activity I wrote for my user to log in to their account. After logging in, they are taken to my Tab Activity. Here is what happens:
When I am on my Tab Activity and I "minimize" the app by clicking the Home button and then launch it again, I don't get taken back to the Tab Activity. I get taken to my log in Activity. Why? I don't have the launchMode of my Tab Activity set to singleInstance... or is it singleInstance by default? How can I make the app re-launch showing the Tab Activity (ideally by setting some parameter, assuming I'm doing something wrong, and not having to save this data off somewhere and reading it and programmatically telling it what to go to)?
Thank you for all your time and help
I don't have a comment on the advisability avoiding the use of sub-activities in TabActivity. As for handlers -- if you aren't going to embed views instead of activities, then all the android:onclick type handler settings in your layout XML will call methods on the TabActivity. This is because they go to methods on the views' Context, which is the generally the nearest containing Activity. If you want to split your code up further without using Activities, I believe you'll have to use findViewById calls on the tab content views after you've set them up, and bind the handlers manually from there in your code.