Getting Android emulator working with Google Maps API Key
I was trying to get an Android app that uses Google Maps API to display a MapView running on the emulator. It took quite a bit of hair pulling to finally get it working.
First, I tried using a self-signed keystore instead of the the debug.keystore provided through the Android SDK. I created my keystore using keytool -genkey from JDK. Then I switch the app from using the default, debug.keystore, to my-new-self-signed.keystore. Using keytool -list, I got the MD5 of the certificate that is needed to obtain a Google Map API key. Then the API key was put into the MapView android:apikey attribute. When I brought up the app in the emulator, I got a blank map grid screen. The reason I wanted to use the self-signed keystore instead of the debug keystore is so I don't have to obtain a new Map API key and change the code to reflect this upon releasing the app.
So, I decided to go with the debug.keystore and that worked fine. Here is what I had to do.
-
$ keytool -list -alias androiddebugkey -keystore <path_to_debug_keystore>.keystore -storepass android -keypass android
- Copy that MD5 and goto http://code.google.com/android/maps-api-signup.html
- Signup for an API key
- In my xml file that has the views for the activity, add
<com.google.android.maps.MapView android:layout_width="fill_parent" android:layout_height="fill_parent" android:enabled="true" android:clickable="true" android:apiKey="example_Maps_ApiKey_String" />
- In the Manifest.xml file, add the permissions needed
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"></uses-permission> - In the Manifest.xml file, add the maps library
<uses-library android:name="com.google.android.maps" />
within the application tag - The entire Manifest.xml looks like this
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.informationideas.mapapp"
android:versionCode="1"
android:versionName="1.0.0">
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"></uses-permission>
<application android:icon="@drawable/icon" android:label="@string/app_name">
<uses-library android:name="com.google.android.maps" />
<activity android:name=".ShowDesktop"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest> - The default activity file should look like this
package com.informationideas.mapapp;
import android.os.Bundle;
import com.google.android.maps.MapActivity;public class ShowDesktop extends MapActivity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);}
@Override
protected boolean isRouteDisplayed() {
// TODO Auto-generated method stub
return false;
}
}
Now off to building cool things with the map!
PHP header redirect
Something to remember when using header location to redirect a page from a server-side script. The output is redirected to the new page, but the logic on the original file will continue to execute. Therefore, if there are database calls the changes to the data will still be made even though a header redirect was issued.
To solve the problem, make sure to issue an exit() command after a header location command.
Google Earth / Map Implementation Problem
One thing that was not documented fully at Google for integrating Google Earth into Google Map is that the function, getEarthInstance, is only available in the newest version of the Map API. I could not find exactly which version so the best way is to use v=2.x like in "http://maps.google.com/maps?file=api&v=2.x&key=yourkey" instead of specifying an exact version. Have fun with this new feature.
.NET Error “The password provided is invalid. Please enter a valid password value.”
Using the SqlMembershipProvider, you may encounter the error message, "The password provided is invalid. Please enter a valid password value. ", which is not very clear as to the exact problem. Apparently, the default setting in the .net membership configuration requires a password with a minimum of eight character and at least one non alpha numeric character such as "!@#$%^&*()".
asp:HyperLink With Dynamic URLs
Much headache to get this to work. The following format will allow dynamic url with multiple variables in the query string in a itemtemplate.
<asp:HyperLink ID="HyperLink1" runat="server"
Text="Link Text"
Target="_blank"
NavigateUrl='<%# "~/mypage.aspx?var1="+ Eval("Var1") + "&var2=" + Eval("var2")%>'>
</asp:HyperLink>
NOTE: Make sure any literal between <%# and %> uses double quotes NOT single quotes.
Zencart and Ultimate URL – 1054 Unknown column ‘c.parent_id’ in ‘on clause’
Configuration:
Linux
Apache 1.3
Mysql 5
PHP 5
Zencart 1.3.5
Chemo Ultimate URL for Zencart 1.3.5
Problem:
After installation, the error message
1054 Unknown column 'c.parent_id' in 'on clause'
shows up on any page in the catalog.
Fix:
Make the following change to /include/classes/seo.url.php
Original:
SELECT c.categories_id as id, c.parent_id, cd.categories_name as cName, cd2.categories_name as pName
FROM ".TABLE_CATEGORIES." c,
".TABLE_CATEGORIES_DESCRIPTION." cd
LEFT JOIN ".TABLE_CATEGORIES_DESCRIPTION." cd2
ON c.parent_id=cd2.categories_id AND cd2.language_id='".(int)$this->languages_id."'
WHERE c.categories_id=cd.categories_id
AND cd.language_id='".(int)$this->languages_id."'";
Change:
"SELECT c.categories_id as id, c.parent_id, cd.categories_name as cName, cd2.categories_name as pName
FROM
".TABLE_CATEGORIES_DESCRIPTION." cd,
".TABLE_CATEGORIES." c
LEFT JOIN ".TABLE_CATEGORIES_DESCRIPTION." cd2
ON c.parent_id=cd2.categories_id AND cd2.language_id='".(int)$this->languages_id."'
WHERE c.categories_id=cd.categories_id
AND cd.language_id='".(int)$this->languages_id."'";
Zen Cart New Product Type Using Ultimate SEO URL Package
This post is to help those who are using Zen Cart and are using new product types with Ultimate SEO URL package installed. There are a couple of things to change in order to make everything work together as it took me a couple of hours to figure out. I hope this will help others save these couple of hours of hair pulling.
Prerequisite:
Zen Cart installed
New product type added
Ultimate SEO URL package installed
Goal:
Have the URLs for the products using the new product type show URLs in this format.
http://www.domain.com/[product name]-p-[product id].html
Changes Required:
NOTE: [handler_name] is the new product type name added.
- File - seo.url.php
Original:
$seo_pages = array(
FILENAME_DEFAULT,
FILENAME_PRODUCT_INFO,
FILENAME_POPUP_IMAGE,
FILENAME_PRODUCT_REVIEWS,
FILENAME_PRODUCT_REVIEWS_INFO,
);Result:
$seo_pages = array(
FILENAME_DEFAULT,
FILENAME_PRODUCT_INFO,
FILENAME_POPUP_IMAGE,
FILENAME_PRODUCT_REVIEWS,
FILENAME_PRODUCT_REVIEWS_INFO,
FILENAME_[handler name]_INFO
); - File - seo.url.php
Original:
$this->reg_anchors = array(
'products_id' => '-p-',
'cPath' => '-c-',
'manufacturers_id' => '-m-',
'pID' => '-pi-',
'products_id_review' => '-pr-',
'products_id_review_info' => '-pri-',Result:
$this->reg_anchors = array(
'products_id' => '-p-',
'cPath' => '-c-',
'manufacturers_id' => '-m-',
'pID' => '-pi-',
'products_id_review' => '-pr-',
'products_id_review_info' => '-pri-',
'[handler name]_id' => '-pji-',
- File - seo.url.php -> function parse_parameters
Find "case 'products_id':"
Within this case statement, add the following.case ($page == FILENAME_[handler name]_INFO):
$url = $this->make_url($page, $this->get_product_name($p2[1]), '[handler_name]_id', $p2[1], '.html', $separator);
break; - File - [webroot]/includes/filenames.php
Add the following definition.define('FILENAME_[handler name]_INFO', '[handler name]_info'); - File - [webroot]/.htaccess
Add the following rewrite rule.RewriteRule ^(.*)-pji-(.*).html$ index\.php?main_page=[ handler_name]_info&products_id=$2&%{QUERY_STRING} [L]
Fatal error: Cannot use string offset as an array in …
PHP5 Error message that is caused by attempting to assign a value to an array element of a variable that is declared as a string.
Example that generates error:
$foo='bar';
$foo[0]='bar';
Get error message Fatal error: Cannot use string offset as an array in ...
Explanation
$foo was declared as a string in $foo='bar'.
$foo[0] is trying to append an element onto a string variable.
Example that does not generate error:
$foo[0]='bar';
$foo='bar';
Does NOT generate error.
Explanation
$foo[0]='bar' instantiates variable $foo as array since it has not been instantiated. Then assigns 'bar' to element $foo[0].
$foo='bar' implicitly re-declares $foo as a string and assigns 'bar' to it.
Example that does not generate error:
$foo='bar';
$foo=array();
$foo[0]='bar';
Explanation
$foo='bar' implicitly declares $foo as a string variable then assigns 'bar' as the value.
$foo=array() explicitly re-declares $foo as an array.
$foo[0]='bar' can now be executed as $foo is declared as an array.
Let me know if this helped you or if I am not clear on anything. Thanks.