Showing posts with label quick tip. Show all posts
Showing posts with label quick tip. Show all posts

Tuesday, August 23, 2011

Android ActivityNotFoundException

This article briefly describes how you can solve an Android ActivityNotFoundException.

One type of error that you may encounter while programming in Android is the "activity not found" exception. This error can be particularly perplexing at first, because as you look through your source files you will see no compilation errors.

Screenshot of the logcat output showing an ActivityNotFound exception

The solution is to modify the manifest for the Android application. The manifest includes all sorts of information about the application, included a list of defined activities that run in the application.

Update the manifest to include information about the activity that it couldn't find, and run your program again. You should not experience this error anymore.

Listed below is an example of a line of code you can add to your manifest to declare an activity.

<activity android:name="CatalogActivity"></activity>

Tuesday, July 5, 2011

Change Anroid Emulator Soft Keyboard

This is a short tutorial that explains how you can change the Android Emulator soft keyboard to display in English.

For Some Reason...

At least twice when I have created Android Emulators, the system is set to display in English, but the soft keyboard that shows up contains Japanese characters. This can be a problem if you need to test specific inputs and don't know Japanese (sadly, I don't).

Have no, fear. This is a simple problem to fix.

If your Android Emulator Keyboard Looks Like This...

Emulator with Japanese soft keyboard

And you would like it to display an English based soft keyboard, then...

Friday, April 22, 2011

Get More Downloads for your Android Apps

More Apps button
 
One of the most frustrating things about the Android Market is making sure that your app is visible. That is making sure that people can find it and download it.

If you have multiple apps in the Android market, you can use your apps to advertise for your other apps. Doing so is extremely simple.

You can use the following code snippet to open up the Android market to a page that displays all of your available apps.

Intent viewIntent = new Intent("android.intent.action.VIEW", Uri.parse("market://search?q=pub:\"PUBLISHING NAME\""));  
startActivity(viewIntent);


Make sure to replace "PUBLISHING NAME" with the name that you publish your apps under, otherwise the search will come up blank.

Although this feature is already built in to the Android Market with the "More Apps by this Publisher" button, adding the link in your App can be helpful. After a user downloads your application, they may never return the App Page in the Android market.

After using your app or game, the user may decide that they like it enough that they want to check out your other products. Adding a button to link them to the Android Market makes this easier for them.

Wednesday, February 23, 2011

Quick Tip: Simple Debugging Android Apps with Logcat

Simple Debugging

The Android Debug Bridge (adb) is included as part of the Android SDK. One of the most powerful tools it features is the ability to view log messages from the Android Operating System and various android applications.

As part of setting up the Android sdk, you should already have ADB in your path variable. To use logcat, simply open up a terminal window, and type the following

adb logcat

You are now presented with continuously updating output of the most recently logged data. Pressing Ctrl+C will exit the logcat application.

Screenshot of adb logcat running in Windows

If an application is crashing, force closing, often times you can use the logcat information to find out what went wrong.

If you want to log custom information for your app, just use the following code.

Log.w(String tag, String message)

and be sure to include the following import at the top of your file:


import android.util.Log;




One Final Tip

Sometimes it is easy for a message to get lost in the log. If you really want to make a message stand out, you can surround it by several newlines. The following code shows this technique

Log.w("MyAPP", "\n\n  Important message \n\n");