Android Navigation System - java

I have been asked to create a navigation system from scratch, that is not using google maps.
I already have the map of the city that I need to create the navigation system in autocad format.
I need to use this map somehow to create a navigation system but I dont really know where to start.
Can anyone point me in the correct direction?
Edit:
The map that I have is just an autocad file, that is, there is no meta data. How do I generate the metadata for the map?
Secondly, the application must calculate the shortest path between two points and if the user does not respect the path, the system must re-calculate the path.
Thanks

This is interesting. Its practically the exact project I've been working on the last few months. Take a look at the README for the project. It details how to go about doing what you're asking.
https://github.com/NCM-Team/Navigating-Carnegie-Mellon

To start, you can create a custom SurfaceView
public class MyMap extends SurfaceView {...
Next add this to your main layout:
<com.example.android.MyMap
android:id="#+id/my_map"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
Lastly, in your main Activity's onCreate(...) method, add the line
MyMap map = (MyMap) findViewById(R.id.my_map);
You can now draw your map to this SurfaceView's Canvas.

Related

How to update content of the activity without creating new Activity?

I'm trying to make an app and I have made a blueprint for a specific activity, but I don't know how to implement it. The layout contains few buttons at the top of the activity, and each button features some information, which is displayed inside the view. The view which needs to be updated is present under the buttons. I don't want the activity to be changed, instead it should update the contents of the View, which is different for each category/button.
By doing some research I have realised that the "Tab Layout" can be used to achieve my requirements, but I don't want the tabs and I need some stylish buttons as a replacement.
I know I'm not the best at describing, so I have looked upon Dribble and found one design which is 100% similar to blueprint.
I want to achieve this using XML and Java using Android Studio! Every suggestion will be a great support foy my app.
Thanks a lot.
As far as I know, you could achieve that by using fragments (which is the same concept you would have used on TabLayout). I don't really know how much knowleadge you have on Android, but if you know what a Fragment is, it should be easy for you to recreate the idea.
You have 3 buttons for 3 different fragments, so you must design every fragment by separate and change it depending the button you click.

Is it okay to define same ids in Android?

I know that if we define different ids it is easy for us to find it in future. I found many answers but they're not what i'm looking for. I've a java function which is bit lengthy and will be used in many java activities. So it won't be possible for me to change ids for every java and xml activity. So is it okay to have same ids in different XML and JAVA files? Or could they make app crash in any way? IDs example :
XML ACTIVITY ONE :
<TextView android:id="#+id/resultview" />
JAVA ACTIVITY ONE :
printresult = (TextView) findViewById(R.id.resultview);
XML ACTIVITY TWO :
<TextView android:id="#+id/resultview" />
JAVA ACTIVITY TWO :
printresult = (TextView) findViewById(R.id.resultview);
As you can see above there are different XML and JAVA but ids are same.
Yes it is okay to use same id in different in different XML files. The point to be considered here is that the activity inflates the particular layout and the findViewById method finds the view using the id in that particular layout that you inflated. Yes, this doesn't introduce bugs however it is a bad practice.
You can refactor the id's via android studio's refactor function. So if you change your id here android studio will search the usages of that particular id and change them for you.
Right click on the id you want to change.
Click on refactor
Click on rename
You will see the following dialog appear
Then you can change the way of refactor by changing the scope and other things at your comfort.
You will not have problem because the components are in different XMLs. But it's better to put different names for them, you will be more comfortable yourself. For example:
<TextView android:id="#+id/resultview1" />
<TextView android:id="#+id/resultview2" />
there is no problem to give one id to many views but:
the views should be in different layout files
it is not a good practice
There is no problem for duplicated IDs until they used in same file. But it is NOT a good practice.

Possible implementation of game screen concept for an android game

I want to develop an android app, but I'm still not that great at using xml or the eclipse wysiwyg editor to make scalable and robust interfaces!
Below is a quick concept I drew up on word of what my main game screen will consist of:
I'm currently thinking a vertical linear frame first, with a frame that doesn't change for my important stats etc., then a frame in the middle which is switched by the buttons, but I'm stuck on how to implement this.
For the centre button screen, the map screen, I am hoping to add an image of a map which can be moved around, and somehow attach invisible button objects to points in this picture, maybe with an array of squares or something?
I understand this is a pretty open question and might be difficult to answer, but if you think you can help in anyway please do.
Thanks!
There is a log of possibilities, but you can use a LinearLayout with android:orientation="vertical" and include your stats in top. For the changing screens with buttons you can use a FragmentTabHost and create different Fragment for each of your views.
Check this example with a implementation.
Regarding the map, I think the easiest option is to use Google Maps Android API v2. Here is a example to use the maps v2 and a example of how to add markers to the map.

View different images depending on what item in my list view I click

I'm fairly new to Android programming and I've got this project I need to finish and I'm currently stuck.
I've got a standard listview in a Menu class with an array containing around 20 different elements. So what I want to do is load images in an imageview depending on which item in the listview I click, and since I'm a beginner the only idea I had was to make a new activity for each imageview which seems like a pretty bad way to do it since I'd need about 20-30 new activities..
To sum things up what I want is:
Code for making ONE activity that will display a different image depending on which item in the listview I click, probably pretty basic coding I want as simple solution as possible.
If possible I'm also looking for a solution that includes an SQLite database that stores the URL of an image and then display it in a single activity, also depending on which item I press in my current listview.
(I hope you understand my needs, and if you need I can also post my current code for the Menu class if it helps you help me) Or you can just show me a different way to make this work, I appreciate every answer! Thanks in advance!
NOTE
And please keep in mind, I'm a noob at Java and Android so keep it rather simple or at least explain what you do.
When you click on a list item, display the image in another view in the same layout, unless you want the image to take up the entire screen real estate. If you want it in the entire screen, go to a new Activity by sending the activity an Intent.
Activities are the "controller" of your application. They interact with the visible UI and the input from the user. You don't need a separate activity for each image, just an activity that's associated with a "place" in the UI (an ImageView) where you'll display the image.
I'd start by adding the images as resources under res/drawable before going on to databases.
You are going to have to do most of this yourself. There really isn't any substitute for taking the time to learn Java and Android. There are several tutorials and Android University classes under the Resources tab in the Developers Guide; I suggest you do all of them.

Help needed with multiple itemized overlays on a mapview

I am looking for some help....
Firstly I have a database server side with a numerous amount of locations(longs +lats)
Now there are upto a 1000 for one city alone. At the moment, my android device all the information at once. I then create 1000 itemized overlays and add them to the map view.
This in turn makes my emulator and phone run slow.
One idea I had was to zoom in on a location and then download and place a subset of the overlays on the map view.
Trouble I have with this
1. When I scroll on the map I don't know what event to register a listener to.
2. When the user zooms out I will still create the large number of itemised overlays.
My question to you guys is,
How could I overcome these problems? Or how would you go about doing this?
The solution Would be something similar to how google maps works. U c a not so detailed map when u zoom out, but when u zoom in it shows you a detailed map that reloads as you move around
I then create 1000 itemized overlays and add them to the map view.
Ummmm... please tell me that this is a typo, and you meant "1000 OverlayItems", not "1000 ItemizedOverlays".
1000 OverlayItems might be bad enough -- ItemizedOverlay isn't really designed for that many points.
When I scroll on the map I don't know what event to register a listener to.
I don't think there is a straightforward solution here. I think others have kinda reverse-engineered the touch events and are listening on those. See Android Maps get Scroll Event for more.
When the user zooms out I will still create the large number of itemised overlays.
Use a prioritization scheme. What you see with Google Maps is that only the top N items are shown, where "top" is based on some sort of priority mechanism.

Categories