Posts

Showing posts with the label Droid

Android UI Wireframing online tool

Anyone tried this Android UI wireframing online tool: http://www.fluidui.com/ Seems to be good. More details: http://www.androiduipatterns.com/2012/07/fluid-ui-wireframing-for-android.html

Interesting article on why we shouldn't use Task Killers on Android

http://lifehacker.com/5650894/android-task-killers-explained-what-they-do-and-why-you-shouldnt-use-them Not that I completely agree as per my observation, but interesting to read - especially the section which mentions:  "On Android, having your RAM nearly full is a  good  thing. It means that when you relaunch an app you've previously opened, the app launches quickly and returns to its previous state. So while Android actually uses RAM efficiently, most users see that their RAM is full and assume that's what's slowing down their phone. In reality, your CPU—which is only used by apps that are actually active—is almost always the bottleneck."

Android/Java Static Code Analysis Tools

Java/Android compilers in itself are very good and give very good warnings to inform about various issues/things done wrong. Just thought about trying free Static Code Analysis Tools and found the below: FindBugs PMD All have eclipse plugin urls, so you can add the URLs at the software site link and easily add the plugins. FindBugs Damn good tool. Install the plugin and then right click on a java/android project. You will find FindBugs Menu. Just click on FindBugs and it gives a very good overview of the review bugs in it's own perspective. Each of the bugs is categorized by the pattern (you can change the categorization in the toolbar) and it lists all the occurrence of that type in all files in the project under that.  Clicking on it, it gives a very very good description about what the error is and why that is considered to be an error. It indicates if its just a suggestion or performance issue or style issue.  Some of these were quite new f...

Copy logcat output

If you want to copy the message from logcat and not the other fields like Time, pid, Tag etc, then you can use the command line option. (Eclipse doesn't allow copy of the messages column alone). ./adb -s logcat -v raw raw removes all the information except the messages and prints it out.

Unknown error on eclipse android console

Not sure what the below means: local emulator[343] : kCGErrorIllegalArgument: CGSGetDisplayBounds (display 2b3c4d11) Googling doesn't return any worthwhile links too.

Eclipse: Removing Todo: Auto-Generated comments

When you use Eclipse menus to create new class, constructor, method or even add a try/catch, typically it not only generates the functionality but also adds a TODO. This is good to indicate that the comment has to be replaced with a proper functionality. However in a team environment, it's not easy to make people delete the line and add the code. Task remains and it becomes difficult to delete it at the end. To remove the auto addition of that comment line, you have to follow the below steps: Goto Window -> Preferences -> Java -> Code Style -> Code Templates Click on Method Body. Click Edit. Remove the commented line. (Something like: // ${todo} Auto-generated method stub) Click Apply. Repeat the steps for other elements. Click save.

Reference: Blog post on Identifying App Installations

Different mechanisms but nothing concrete yet: Identifying App Installations

Warning on app launch in emulator in MAC

Every time I try to launch my android app on emulator, i get the below warning: Warning once: This application, or a library it uses, is using NSQuickDrawView, which has been deprecated. Apps should cease use of QuickDraw and move to Quartz. Looks like this can be safely ignored as it's the problem with the emulator using deprecated api. Link: http://groups.google.com/group/android-developers/browse_thread/thread/f10995f2a829229d

Deleting user database

DBOpenHelper or SQLiteDatabase doesn't have functions to delete the database. Looks like there are people who are using file delete by going to the database location and deleting the file programmatically. The easier solution is : Android does provide the mechanism to delete the file. It's available in ApplicationContext though. You would do something like this: InstantReturn app = (InstantReturn) getApplicationContext(); // dbHelperInstance.close(); // dbInstance.close(); if (app.deleteDatabase(DatabaseOpenHelper. DB_NAME )) { Log.d(ViewConstant. APPLICATION_NAME , "deleteDatabase(): database deleted." ); } else { Log.d(ViewConstant. APPLICATION_NAME , "deleteDatabase(): database NOT deleted." ); }

WebView loading external browser

If your webview loads external browser and doesn't display the contents inside the webview, do check if the page is doing any redirects. Redirects are by default launched in external browser.

Finding app heap availability

VMRuntime was a great class provided in Android SDK to find and alter information about the VM used by your application. http://developer.android.com/sdk/api_diff/5/changes/dalvik.system.VMRuntime.html However, this has been deprecated since version 5 mentioning this was only intended for Internal usage and not for public usage. That;s sad since we cannot find useful functions elsewhere. If you do want to find memory consumption of the system, you can use: ActivityManager actvityManager = (ActivityManager) this.getSystemService( ACTIVITY_SERVICE ); ActivityManager.MemoryInfo mInfo = new ActivityManager.MemoryInfo (); actvityManager.getMemoryInfo( mInfo ); Log.i(TAG, " minfo.availMem " + mInfo.availMem); Log.i(TAG, " minfo.lowMemory " + mInfo.lowMemory); Log.i(TAG, " minfo.threshold " + mInfo.threshold); If you are looking for information for your app, you can use the java provided Runtime methods: Log.i("AvailableHeapMemory", " Runtime.g...

Adjusting webview contents to fit

I assumed that the webview controller would automatically fit the html contents horizontally and would allow only vertical scrolling. But that doesn’t seem to be the way. You can ofcourse set the below values to make it horizontally fit: (available from 2.1) webview.getSettings().setLoadWithOverviewMode(true); webview.getSettings().setUseWideViewPort(true);   webview.getSettings().setLayoutAlgorithm(LayoutAlgorithm.SINGLE_COLUMN); should be an easier option, but it’s not working on 2.1. There was a bug raised ( link ) was fixed in 2.2 only.

Device ID in GUID format

You can use Secure.Android_Id for getting unique id of the device. But if you need to pass it to as GUID like deviceId in iPhone, there doesn’t seem to be an easy way. The basic code I wrote for the conversion is something like this : String android_id = getAndroidId(); long leastSignificantBits = 0; long mostSignificantBits = 0; UUID uuid = null;     if (android_id != null) {         String asciiConvertedText = "";         int len = android_id.length();         for (int i = 0; i < len; i++) {             asciiConvertedText += "" + ((short) android_id.charAt(i));         }         len = asciiConvertedText.length();         if (len > 16) {           ...

Launch cancelled error

You might run into this issue when connecting to the Android emulator/device: Failed to upload <<apk_name>>.apk on device <<device_name>> java.net.ConnectException: Connection refused: connect Launch canceled! 1. Start command prompt and try running the command adb kill-server && adb start-server. (you should cd to the androidsdk\tools directory OR should have added those to the path). 2. If that doesn’t work – kill any instances of adb.exe running, from the task manager. Then restart the adb as told above.

Android crash handling

Image
Was searching for better ways to handle unhandled exceptions/crashes in android apps and my colleague found this project on google code: acra . Basically a simple handler which sends crash reports to google docs. Has additional features but somehow feel there should be better ways of handling it. Will update this blog as I research more but if you have any ideas, do post it in comments.

Emulator Error: user data image is used by another process

I frequently encountered the below error: emulator: ERROR: the user data image is used by another emulator. aborting   Once I get this error, I typically restart the emulator and that works most of the times. Sometimes I have to do wipe data for it to start connecting. However searching on google, returned me this link: http://stackoverflow.com/questions/1740834/emulator-problem-in-android The easiest solution that worked for me is to invoke the command below. Best part is you need not restart the emulator, adb kill-server && adb start-server adb executable is part of the tools in your android sdk.

AVD Emulator not connecting to Internet

I have run into this problem frequently and the below 2 suggestions worked for me: 1. Start AVD with command prompt – with administrator privileges 2. Just restart the AVD from eclipse :)

Changing linked gmail account with Android Phones

Was searching for a mechanism to remove the linked gmail account with my office android phone. As per the link below – only solution looks to be to reset the complete mobile by clicking on Factory Data Reset! :(…. Not sure why this restriction has been placed. Why can’t I change my gmail id? http://androidcommunity.com/forums/f29/is-it-possible-to-change-your-linked-gmail-account-or-do-you-have-to-do-a-phone-reset-5718/

Welcome to my blog!

http://droid-notes.blogspot.com/ A place to share all my learning on developing apps for Android and using a Android phone. My last status update in FB related to this: Getting a blog address in blogspot seems to be real tough. Though there are no sites like http://droidtalk.blogspot.com or http://droidnotes.blogspot.com - It throws non-available. I understand http://droid.blogspot.com might be reserved but why the others? Luckily droid-notes was made available :)