Working with Google Map MyLocation

1. Issue. how to delete markers ?

Click on marker shows title and geolocation. Let’s say long click on a map and we’ll check for marker near that (within .02 for example). To delete marker I have to call Marker.clear() or remove(). I don’t have marker object… I can remove all markers and draw remaining ones.

a.  http://stackoverflow.com/questions/16236439/restoring-map-state-position-and-markers-of-google-maps-v2-on-rotate-and-on

this has good complete code

I found and implemented this code: drag marker to a trash icon. Used this for starting point;http://stackoverflow.com/questions/17460315/delete-map-marker-while-dragged-on-an-imageview-bounds

 

 

2. Issue. Long click starts drag action. However drag Start message has coordinates that are off from original position. I can’t use these coordinates to snap the marker back in place.
After reading I think I have to maintain HashMap of markers with a key that is key to database entries.

3. Other useful sources:

Bunch of sample code but not clear what for and what’s quality, have to download and see.

http://www.androidhive.info/2012/08/android-working-with-google-places-and-maps-tutorial/

 

4. Marker lifecycle collection of sources.
http://stackoverflow.com/questions/16236439/restoring-map-state-position-and-markers-of-google-maps-v2-on-rotate-and-on

http://stackoverflow.com/questions/13762150/how-to-persist-marker-from-google-api-android-v2/13816635

How to instantiate map after rotation etc
http://stackoverflow.com/questions/14114131/how-to-add-overlay-in-google-maps-api-v2-android

 

5. Overlays. Not sure if I have to use Overlays. Seems it’s V1. But I will collect sources
http://stackoverflow.com/questions/6295203/adding-multiple-marker-on-google-map-in-android?rq=1

6. Google sources
https://developers.google.com/maps/documentation/android/marker
https://developers.google.com/maps/documentation/android/reference/com/google/android/gms/maps/package-summary

7. Info Window. If I change content of info window during drag- nothing happens.
http://stackoverflow.com/questions/15503266/dynamic-contents-in-maps-v2-infowindow/15512984#15512984
This might help. InfoWindowAdapter.
Next, this is about creating multiple custom infoWindow . Lot of code.
http://stackoverflow.com/questions/13763545/android-maps-api-v2-with-custom-markers
Next, onMarkerClick show/hide window issues and animaring the camera
http://stackoverflow.com/questions/14055785/android-onmarkerclick-doesnt-call-after-infowindow-hiding-in-googlemap-google-m
Minor next: http://stackoverflow.com/questions/17154027/hide-infowindow-when-clicked-marker-second-time-google-map-android-api-v2 – post answer to return true if I can

8. Map extensions
https://code.google.com/p/android-maps-extensions/

9. Draggable marker example
http://android-er.blogspot.com/2013/01/google-maps-android-api-v2-example_7.html

10: cool code to animate the marker from one geopoint to another:
http://stackoverflow.com/questions/13728041/move-markers-in-google-map-v2-android

Getting started with Google Map APIs

Google Maps for Android

Google Maps for Android (Photo credit: Wikipedia)

New project has to do with placing markers on a map and managing these markers (add, retrieve, view, update, delete).

I never did a project with maps. So let’s get started.  Starting point is google documentation.

https://developers.google.com/maps/documentation/android/start#getting_the_google_maps_android_api_v2

1. Looks like I have to generate a key  that will be used during dev process. And later generate release key.

2. Followed instructions and received a 40 char key for using google map APIs v2 and geolocation API.  This involved creating a project and reading licenses.

https://code.google.com/apis/console/?noredirect&pli=1#project:940879255152:access

3. Next fundamental step is to read about MAP on google play services  http://developer.android.com/google/play-services/maps.html

My goal is to find a working running example that I can use as a starting point.

4. Before doing step 3 I have to do step  4. Setup google play services sdk

http://developer.android.com/google/play-services/setup.html

5. Downloaded sample project from google play API.  Running this project requires to put in my own key. 30 min after this still doesn;t run. Research.

HERE: in case of error with the key i have to uninstall and clear data from the device.  Learned hard (semi) way.

Ok, sample project is working. One glitch remains: My location is never initialized. I have to tap my location icon to make it to go where I am otherwise I am in (0, 0).

 

 

Using Home icon as a navigation back button

I’d like to enable clicking on the home icon. This click would take user one screen back. Maybe it should take user back to front screen.  For now, act as a back button.

Nothing more simple!

1. @Override

public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.menu_drill, menu);
// enable home icon to be a button
ActionBar actionBar = getActionBar();
actionBar.setDisplayHomeAsUpEnabled(true);
return true;

 

2.

@Override

public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {

case android.R.id.home:
onBackPressed();
return true;

}

}

Simple. Little arrow to the left is drawn next to the icon. I didn’t have to create an image.

TravelMeds app is released!

We put the app into Google Play, it’s live!!

Our project team at Moodro and at Galanda are very excited to present TravelMeds app.

Short ad:

Travel safely and protect your loved ones. Make sure your family’s allergy information, medication information and medical conditions are with you on your smart phone when you travel to foreign countries and can be translated to foreign languages.

 

Dear Followers and Readers. I’d appreciate hearing from you. Go ahead, download the app. Give the feedback for the UI and for functionality. We believe the app is high quality and well crafted. To find, enter “TravelMeds” in the Google Play store search bar.

 

TravelMeds512

We strive for the 5 star rating. If any issues identified – I would be glad to work on it and write about overcoming these problems.

App is advertisement supported. Explore the ads, you might find an interesting product or a deal.

Take care!

–Galina a.k.a. galanda

Smartphone Configuration for Social Media Mark...

Smartphone Configuration for Social Media Marketing in Frederick MD (Photo credit: Frederick Md Publicity)

About calling finish() in activity

Now, my new activity layout file is constructed with using “include” for a sections of a screen that I expect to use at least twice.

This is a details activity screen, I expect user to enter couple fields and I save data in content provider. Simple, happens in many apps. But it’s a first one for me.

Problem: Save button is pressed, I call save() and I call finish(), expecting activity to be switched to a previous one. Data apparently is saved correctly but no, instead of exiting this activity some other stuff is happening. What??

Let’s read about it.

1. Lean every day. : ) Any statement written after finish() will get executed. Interesting,  but I don’t have any other statements after finish (just break, return etc).

2. OnDestroy() is a last call that activity will see before being destroyed.  I guess it’s a good place to put code for back button pressed if you don’t feel like writing onBackPressed() .

3. android:noHistory = “true”. Can play with that.

"Ruby Hilton, Lynn Gardens, Kingsport, Te...

“Ruby Hilton, Lynn Gardens, Kingsport, Tennessee. Another view of the super-finish operation calling for the spraying… – NARA – 532749 (Photo credit: Wikipedia)

I see, any code that comes after finish() is executed.

Oh, that’s right! found additional code.  Finish() is not necessarily the end, more “activity” happens after the finish. Makes a joke.

Take care!

 

 

ListView: onListItemClick and On Touch

My app starts with an empty list and user has to click “Add” to create a first item.  First time users can’t figure out the Add (plus sign) button and they smack the finger on a blank screen, maybe something will come up to guide. Ok that’s a task: when user touches empty area on a list we want to treat it as Add button was clicked. 

My activity already implements onListItemClick and it’s void call

There is onTouch which is boolean. Let’s try

@Override
public boolean onTouch(View arg0, MotionEvent event) {

Log.d(TAG, “onTouch list”);

boolean ret=false;
return ret;
}

Simple enough though this is called 3 times when I touch once. 

Reading. I see, there are 3 event. I’ll handle the Action Up.

switch(event.getAction())
{
case MotionEvent.ACTION_DOWN:
//code
break;
case MotionEvent.ACTION_MOVE:
// code
break;
case MotionEvent.ACTION_UP:
if (lView.getAdapter().getCount()<=0){
startEditActivity(-1);
ret=true;
}
break;
}

This sounds simple but I spent some time figuring what the condition is for me to return true and when to return false, so that onListItemClick is still called. Ended up limiting this feature to a condition when list has no items. 

Good enough. 

Take care.

Going to read release procedures next. 

Please Don't Touch

Please Don’t Touch (Photo credit: Wikipedia)

 

 

In App Advertisements

Google has AdSense and AdWords

There is MoPub that people use and talk about. Only experience can tell (or do You?) what is better.

I had code sample for MoPub, let’s try it out.

1. MoPub Integration part1

http://help.mopub.com/customer/portal/articles/285186

This crashes at runtime…

Though I used MoPub successfully earlier (in sprint). Spent 2-3 and then switched to AdMob.

I have low tolerance to now this works now it doesn’t game.

2. AdMob by google. Easy to integrate, seem to be working well so far.