Conversion to Dalvik format failed with error 1
Minimum required to get started with Google Maps
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
...
<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:
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
<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
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
res/menu/editpreferences_menu.xml
and populate it with some menu definitions, something like this:
<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:
...
@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
getMenuInflater().inflate(R.menu.editpreferences_menu, menu);
return true;
}
}
Attaching the debugger
Service Permissions
</service>
and gave this runtime error:
Permission Denial: Accessing service ComponentInfo{com.powerplain/com.powerplain.MyInputService} requires android.permission.BIND_INPUT_METHOD
whereas this technique did work:
</service>
<uses-permission android:name="android.permission.BIND_INPUT_METHOD" />
Android Source Code
Landscape Values
I wonder if the same applies to drawables-land and menus-land?
Cursor Error
G1 Upgrade to 1.5
I found this on a blog (somewhere). It worked perfectly for me, although the 43mb download took quite a long time - 2 hours or so.
Here is how to do it if you do the same thing I did.
- First, have AnyCut installed if you don't already
- Next, Create a new shortcut on your phone's desktop. Select "AnyCut" and then select "Activity"
- Select "Device Info" as your activity. I can't find any other way to get to this activity on the phone
- Press the new shortcut icon you have created.
- Scroll to the bottom and find the "Check for Updates" button. Click it. You may have to a few times for it to succeed.
- Once the "checkin" has succeeded, exit back to your home screen and you will be prompted to install the update.
Simple Custom Control Template
super(context, attrs);
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
inflater.inflate(R.layout.zzzzzzz, this);
}
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal" android:layout_width="wrap_content" android:layout_height="wrap_content">
<!-- Put your controls here -->
</LinearLayout>
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
AsyncTask
new LoadDataTask().execute(this, transactionSortOrder, dateFilter);
}
private class LoadDataTask extends AsyncTask<Object, Integer, ArrayList<SeauTransaction>> {
@Override
protected ArrayList<SeauTransaction> doInBackground(Object... params) {
this.activity = (Activity) params[0];
return getData(activity, transactionSortOrder, dateFilter);
}
protected void onPostExecute(ArrayList<SeauTransaction> result) {
fillAdapter(activity, result);
}
}
private ArrayList<SeauTransaction> getData(Context activity, TransactionSortOrder transactionSortOrder,
AbstractDateFilter dateFilter) {
return dbAdapter.getSeauTransactionList(transactionSortOrder, dateFilter);
}
private void fillAdapter(Activity activity, ArrayList<SeauTransaction> seauTransactionList) {
transactionAdapter = new SeauTransactionAdapter(activity, seauTransactionList);
setListAdapter(transactionAdapter);
}
Defining Sub-Menus in XML
<item title="menu header 1" ...<menu ...<item title="sub menu item1" ...<item title="sub menu item2" ...<item title="sub menu item3" ...</menu></item>
BitmapDrawable
baseLine.setGravity(Gravity.BOTTOM | Gravity.LEFT);
/* base */0, 3, lineEnd, 3,
/* starttick */0, 1, 0, 5,
/* endtick */lineEnd, 1, lineEnd, 5 };
Empty ListView
Log.d(getClass().getSimpleName(), "onCreate");
requestWindowFeature(Window.FEATURE_NO_TITLE);
super.onCreate(savedInstanceState);
<TextView android:text="@string/welcome_heading"></TextView>
<TextView android:text="@string/welcome_text"></TextView>
View emptyView = inflater.inflate(R.layout.buckets_list_empty, null);
Handy ListView attribute
Aligning LinearLayout
android:layout_centerHorizontal
="true"Removing hard coded dimensions
<
<dimen name="numkey_width">60px</dimen>
</
resources>android:layout_marginLeft="@dimen/numkey_margin"
RelativeLayout
<linearlayout id=amountLayout android:layout_alignParentTop="true" >
<linearlayout id=numberLayout android:layout_alignParentBottom="true" >
<linearlayout
android:layout_below="@id/amountLayout"
android:layout_above="@id/numberLayout"
>
<listview ........./>
The documentation says:
"For the sake of efficiency, the relations between views are evaluated in one pass, so if view Y is dependent on the position of view X, make sure the view X comes first in the layout."
So I layout out the top & bottom fixed elements then place the scrolling list in between them.
Soft Numeric Keyboard
Input type numberSigned|numberDecimal
it will popup the keyboard when that field takes the focus.
Also, you can create a string resource of characters that can be input into the Digits property
in strings.xml:
onLocationChanged event fires only one in the Emulator
The last post I saw on this was 1.5_r3 31st July
GPS GeoLocation Navigation Information
- latitude, the angle north or south of the equator
- longitude, the angle east or west of the Prime Meridian aka International Date Line
Emulator Telnet
telnet localhost 5554
Android Console: type 'help' for a list of commands
OK
help
Android console command help:
help|h|? print a list of commands
event simulate hardware events
geo Geo-location commands
gsm GSM related commands
kill kill the emulator instance
network manage network settings
power power related commands
quit|exit quit control session
redir manage port redirections
sms SMS related commands
avd manager virtual device state
window manage emulator window
try 'help <command>' for command-specific help
I used window scale .6 to make the emulator window roughly the size of a real phone.
NinePatch Images
Four small things that caught me out:
1) you can't have two images with the same root name e.g. abc.png and abc.9.png
2) when you reference them in Java the .9 element is not present (related to issue 1) e.g. R.drawable.abc would automatically reference the abc.9.png image
3) The border has to be white with the "stretchable" elements in black
4) When you change the content of an image you have to hit F5 to refresh the \res folder - even though the filename hadn't changed - in order for the new content to appear in the application.
Finally, don't bother looking at the nine-patch images in the XML Editor in Layout mode - they don't stretch properly.
NinePatch Resources
NinePatch Tools
Focusable View inside ListView item won't be clickable
Date: Mon, 10 Nov 2008 08:34:23 -0800
Subject: Re: [android-developers] no callback to onItemClick() on clicking my ListView
If you put a focusable View inside a list item, then the list item
will not be clickable. You would have to set a click listener on the
button for instance.