HTC seemed to want to install Sync in order to get the USB driver. So I downloaded an older driver from here:
http://downloads.unrevoked.com/HTCDriver3.0.0.007.exe
Opening a Command Prompt and running adb devices showed that the USB driver was working.
C:\Program Files\AppInventor\commands-for-Appinventor>adb devices
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
List of devices attached
HT155TJ03448 device
Conversion to Dalvik format failed with error 1
Usually I close/restart Eclipse to clear this error.
On this occasion I tried "Clean / Rebuild" and that also worked - and more quickly than an Eclipse restart.
Minimum required to get started with Google Maps
1) Obtain key for debug version of app.
The default location where the MD5 certificate is stored for the Debug version of the app:
The keytool.exe is here:
The command to get the debug certificate is:
Enter the MD5 cetificate output by the keytool command into the Google Maps signup page: http://code.google.com/android/maps-api-signup.html
2) Add the highlighted lines to AndroidManifest.xml
3) Create an Activity that extends MapActivity otherwise LogCat reports this error:
4) Create a layout (mapview.xml) in this example
5) Remember to add the MyMapView activity to the project's AndroidManifest.xml
6) Using the project's Properties dialog, select Android and choose the target as Google APIs
7) Using the AVD Manager create a new AVD that targets Google APIs
The default location where the MD5 certificate is stored for the Debug version of the app:
C:\Users\<your windows user>\.android\debug.keystore
The keytool.exe is here:
C:\Program Files\Java\jdk1.6.0_14\bin
The command to get the debug certificate is:
keytool -list -alias androiddebugkey -keystore C:\Users\<your windows user>\.android\debug.keystore -storepass android -keypass android
Enter the MD5 cetificate output by the keytool command into the Google Maps signup page: http://code.google.com/android/maps-api-signup.html
2) Add the highlighted lines to AndroidManifest.xml
<application android:icon="@drawable/icon" android:label="@string/app_name">
...
<uses-library android:name="com.google.android.maps" />
...
</application>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
...
<uses-library android:name="com.google.android.maps" />
...
</application>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
3) Create an Activity that extends MapActivity otherwise LogCat reports this error:
09-06 07:44:23.269: ERROR/AndroidRuntime(868): Caused by: java.lang.IllegalArgumentException: MapViews can only be created inside instances of MapActivity.
package xxx.yyy;
import android.os.Bundle;
import com.google.android.maps.MapActivity;
public class MyMapView extends MapActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.mapview);
}
@Override
protected boolean isRouteDisplayed() {
return false;
}
}
import android.os.Bundle;
import com.google.android.maps.MapActivity;
public class MyMapView extends MapActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.mapview);
}
@Override
protected boolean isRouteDisplayed() {
return false;
}
}
4) Create a layout (mapview.xml) in this example
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content" android:layout_height="wrap_content">
<com.google.android.maps.MapView
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:apiKey="the key received from Google" />
</LinearLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content" android:layout_height="wrap_content">
<com.google.android.maps.MapView
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:apiKey="the key received from Google" />
</LinearLayout>
5) Remember to add the MyMapView activity to the project's AndroidManifest.xml
6) Using the project's Properties dialog, select Android and choose the target as Google APIs
7) Using the AVD Manager create a new AVD that targets Google APIs
Make a TextView look like an EditText
<TextView
style="@android:style/Widget.EditText"
android:id="@+id/TextView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</TextView>
style="@android:style/Widget.EditText"
android:id="@+id/TextView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</TextView>
List the InputMethods
InputMethodManager inputManager = (InputMethodManager) getSystemService(Context.
INPUT_METHOD_SERVICE);List<InputMethodInfo> inputMethodInfoList = inputManager.getEnabledInputMethodList();
for (InputMethodInfo i : inputMethodInfoList) {Log.d(
"INPUT-DEBUG", i.getServiceName());Log.d(
"INPUT-DEBUG", i.getPackageName());Log.d(
"INPUT-DEBUG", i.getSettingsActivity());}
Defining and Using Menus in XML
Create an .xml file in the res/menu folder, for example:
res/menu/editpreferences_menu.xml
and populate it with some menu definitions, something like this:
Then inflate the XML menu using the onCreateOptionsMenu in the Activity:
res/menu/editpreferences_menu.xml
and populate it with some menu definitions, something like this:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/menu_done" android:title="@string/menu_done"
android:icon="@android:drawable/ic_menu_save" />
<item android:id="@+id/menu_revert" android:title="@string/menu_revert"
android:icon="@android:drawable/ic_menu_revert" />
<item android:id="@+id/menu_help" android:title="@string/menu_help"
android:icon="@android:drawable/ic_menu_help" />
</menu>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/menu_done" android:title="@string/menu_done"
android:icon="@android:drawable/ic_menu_save" />
<item android:id="@+id/menu_revert" android:title="@string/menu_revert"
android:icon="@android:drawable/ic_menu_revert" />
<item android:id="@+id/menu_help" android:title="@string/menu_help"
android:icon="@android:drawable/ic_menu_help" />
</menu>
Then inflate the XML menu using the onCreateOptionsMenu in the Activity:
public class EditPreferences extends Activity {
...
@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
getMenuInflater().inflate(R.menu.editpreferences_menu, menu);
return true;
}
}
...
@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
getMenuInflater().inflate(R.menu.editpreferences_menu, menu);
return true;
}
}
Attaching the debugger
I've spent months tediously closing my app, setting my breakpoints and then relaunching with the debugger.
There is an easier way.
From the Devices view (in the Debug perspective) highlight your process and click the "debug" button (it looks like a green bug on the Devices titlebar).
Much better.
Subscribe to:
Posts (Atom)