Senin, 28 Februari 2011

Tip: Installed Application Not Installed Error

Have you ever loaded up an application, ready to debug, but then seen a message along the lines of, "Application Not Installed" display? This usually has an accompanying LogCat error:
ActivityManager: java.lang.SecurityException: Permission Denial: starting Intent
The cause and solution are very simple:
  • This error is most likely caused by a duplicate Activity class entry in the manifest file. 
 <activity  
android:name=".MainActivity"
android:label="@string/app_name">
<intent-filter>
<action
android:name="android.intent.action.MAIN" />
<category
android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!-- lots of stuff -->
<activity
android:name="MainActivity"></activity>
The solution should be clear by now:
  • Remove the duplicate tag from the AndroidManifest.xml file 
  • Build the application again
  • Reload the application
This is quite the opposite of forgetting to add an Activity class to the manifest file. And, yet, it leads to a failure just the same. Proper maintenance of the manifest file is important. It's not a file to mess around with.

Happy Android Coding!

Jumat, 11 Februari 2011

Contacts Contract: Intro and Getting Started

If you've been using Android awhile, and have used the Contacts feature at all, you may have noticed that when you push your SDK forward a few versions, many of the calls are now listed as deprecated.

This is because the Android project revamped how the contacts system works in Android 2.0 (API Level 5). The updated system is much more flexible, while also taking a bit more code to use properly. Over at Mobiletuts+, we wrote an article quite a while back that has a quick overview of using the new APIs in context of using the contact picker. Android Essentials: Using the Contact Picker demonstrates how the queries are now often broken up due to increase in the number of internal tables used (or, that's mostly likely the cause).

You can also directly view the open source code for this tutorial.

Kamis, 03 Februari 2011

Tip: New Layout Editor Exceptions

Does your Android Eclipse layout editor look like Figure 1? Does it show "Missing theme." or perhaps an error in the logs (perhaps something to do with "com.android.ide.eclipse.editors.layout.LayoutEditor")? These are frequent occurrences on the very latest Android SDK Tools.
Figure 1
Layout Editor errors
 (Click for large view)
If you're having these types of issues, the solution may be simple. See that empty dropdown on the far right? Perhaps it's not empty, but shows the Android version? Yeah, the one highlighted in Figure 2 shown below... Click on this dropdown and pick one of the options.
Figure 2
Layout Editor Drop Down
(Click for large view)
Does your layout editor now look like Figure 3? If so, you're all set. If not, you'll need more than just this tip.
Figure 3
Layout Editor, no errors
(Click for large view)
Why the new dropdown? We believe that it will show what a layout should look like on various versions of Android platform. So, presumably, you'll want to pick your Target SDK most of the time and if, during testing, you find a problem outside the target SDK, this drop down may help speed up layout debugging.

Happy Android Coding!

Selasa, 01 Februari 2011

New Feature: Book Code Downloads

Many readers have found it difficult to access the book code downloads from the official publisher site. After some discussion with our editor, we are pleased to inform you that we now have them hosted separately and available for easy, direct download. (No login should be needed and certainly no verification that you own the book. But you already bought it, right? :) )

In addition to providing a new source for downloading the files, we have also provided a single download for all of the code for each book.

The download link is convenient found right next to the Home link above, under "Book Code Downloads."

Happy Android Coding!
ANDROID BOOK © 2008 Template by:
SkinCorner