Posts

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.

Sireesha’s naming ceremony

Image
Here is the quick invite I had created using a Powerpoint template -

Mysore Trip – fulfilling promises

Trip to Mysore

passportindia site using weak public key?

I got this error in chrome but it happily went through in IE. Server has a weak ephemeral Diffie-Hellman public key This error can occur when connecting to a secure (HTTPS) server. It means that the server is trying to setup a secure connection but, due to a disastrous misconfiguration, the connection wouldn’t be secure at all! In this case the server needs to be fixed. Chrome won’t use insecure connections in order to protect your privacy.