Skip to Content

Category Archives: Blog

Android studio hangs “Waiting for ADB”

Written on October 10, 2014 at 12:24 pm, by

I have been getting android studio hangs intermittently (whole window frozen) and it looks to just be ADB hanging. Seems to happen a lot when my mac sleeps. The solution was just to restart adb using : adb kill-server; adb start-server Hopefully this will be fixed soon. the whole Android studio inferface shouldn’t hang just because ADB isn’t responding – it should be in a background task. Hope it helps someone.

Recover files from a non booting device

Written on October 7, 2014 at 4:24 am, by

This is for when you have not been able to boot your phone and need to get files off it. The device (a Nexus 4) turns on but never makes it past the loading screen. So it doesn’t finish booting – but mine had booted enough to have ADB running. To use this method you need to have ADB installed on the host. (e.g. install dev tools – see [1]) * To get the list we use ADB shell $ adb shell shell@mako:/ $ ls /sdcard/ … DCIM/ shell@mako:/ $ ls /sdcard/DCIM/ 100ANDRO/ Camera/ shell@mako:/ $ ls /sdcard/DCIM/Camera/ … (list files) * Take this list (select+copy) and paste to to a local file say picnames.txt * Then execute $ cat picnames.txt | xargs -I % adb pull /sdcard/DCIM/Camera/% 7003 KB/s (3677132 bytes in 0.512s) … This should copy the files to the local directory … phew! refs: [1] http://developer.android.com/sdk/index.html

Some great in depth turtorials and slide for Android tasks

Written on August 7, 2014 at 4:12 am, by

These are some great tutorial/slides I found recently: Threading: http://www.slideshare.net/andersgoransson/efficient-android-threading Loaders: http://www.slideshare.net/cbeyls/android-loaders-reloaded Android source: Android Source Code Guided Tour from Kevin McDonagh

Setting up Junit ServiceTestUnit tests with Application references

Written on March 15, 2014 at 12:18 pm, by

I have been setting up unit testing for an existing project of late and when testing services I ran into problems setting up the application and base context references. Searching around – I wasn’t able to find a way to do this, hence I am noting it down to make it (hopefully) easier for you.. Setting the Application context in the test unit setUp() enabled me to get the Application object but many other calls did not work (e.g. getPackageName()). To properly setup the application object we need to set the Base Context for the application object. This can be done by overriding attachBaseContext(Context base) in the application object and making it public. Of course you shouldn’t really have to change your source to run tests – but in practice it happens anyways (e.g. making methods public to call them from the test). Application This method is added to the application object it overrides the default from ContextWrapper @Override public void attachBaseContext(Context base) { super.attachBaseContext(base); } DownloadServiceTest public class DownloadServiceTest extends ServiceTestCase<DownloadService> { DownloadService _downloadService; public DownloadServiceTest() { super(DownloadService.class); } public DownloadServiceTest(Class<DownloadService> activityClass) { super(activityClass); } protected void setUp() throws Exception { super.setUp(); MyPODApplication myPODApplication = new MyPODApplication();// the application object // the overrided method to attach the context – we pass the Context provided by getSystemContext(); myPODApplication.attachBaseContext(getSystemContext()); setApplication(myPODApplication); getApplication().onCreate(); setContext(getApplication()); Intent i = new Intent(getSystemContext(),DownloadService.class); i.setAction(Globals.INTENT_START_DOWNLOADS); Log.d(DownloadService.class.getSimpleName(), “dl svc started”); startService(i); // should use a service binder here _downloadService = getService(); } // more test methods here }

Using CSS precedence

Written on February 23, 2014 at 12:37 pm, by

I have been coming back to HTML / CSS lately and I came across errors where my CSS would not be overridden. Then I found this very good article on CSS Precedence by Steven Bradley. http://www.vanseodesign.com/css/css-specificity-inheritance-cascaade/ This article gives a thorough understanding of CSS Precedence, and is well considered looking at the comments … The thing I got from it was that it is probably better to design your HTML with pseudo tags, as those styles will always give the lowest precedence. Then base styles can then be overridden more easily by giving class (0 0 1 0) or id (0 1 0 0) attributes to elements. This should give the greatest flexibility in correcting errors, and creating re-useable CSS. Using !important should not be necessary in well designed CSS. They can be handy in a quick spot I guess – but long term they just make the CSS harder to edit. W3 ref: http://www.w3.org/TR/CSS2/cascade.html

Fixing performance issues in Ubuntu 12.10

Written on June 19, 2013 at 6:01 am, by

I bought a new computer last year and it has been running rather slow since install. Just wanted to go through the journey which has been a relief to get fixed. Finding a good profiler I found “System profiler and benchmark” (http://hardinfo.berlios.de/HomePage). Which found some interesting results for CPU performance (the command line tool lscpu does the same thing). The processor is a quad core 3.4GHz processor so the intro screen looks fine. But the processors section shows that the processors aren’t running at full speed (the second image below). Intro screen Processor info Processor info This is confirmend using lscpu $lscpu Architecture: x86_64 CPU op-mode(s): 32-bit, 64-bit Byte Order: Little Endian CPU(s): 8 On-line CPU(s) list: 0-7 Thread(s) per core: 2 Core(s) per socket: 4 Socket(s): 1 NUMA node(s): 1 Vendor ID: GenuineIntel CPU family: 6 Model: 42 Stepping: 7 CPU MHz: 1600.000 BogoMIPS: 6784.14 Virtualisation: VT-x L1d cache: 32K L1i cache: 32K L2 cache: 256K L3 cache: 8192K Solution – Granola After a bit of searching around I found this post). Which points me to Granola some nice power saving software which controls CPU frequencies. The client software monitors how much power is being used (below). And give an overview of power savings – this data feeds into the project website to show how much power the software is saving globally. Installation Installation is quite simple, the instructions are for Quantal : Check you are running Quantal (The links below are for that release – 12.10 Quantal) (running Read more…

Weekly issues of interest

Written on May 25, 2013 at 5:28 pm, by

These were some of the bugfixes I had this week – that took a little while the get around, just because they were a bit less obvious. Dont re-use RemoteViews in widgets This causes each action applied to applied each time – for a RemoteViews object in a widget create a new instance each time – I had some large memory leaks due to strings being held in a re-used RemoteViews object. https://groups.google.com/forum/?fromgroups#!topic/android-developers/qQ4SV5wL7uM Making a StateListDrawable: ordering the states are added is important. When making a StateListDrawable in code, the order that the states are added determines the evaluation order – the statelist drawable then sets the first state it sees above or equal to the level of the state. In the two examples examples, the top one works, but below the drawable will always display enabled (1) if the enabled drawable is added first (i.e. it appears not to reflect the states at all). The code below displays the states correctly: StateListDrawable sld = new StateListDrawable(); sld.addState(new int[] { android.R.attr.state_selected },mSelectedDrawable); sld.addState(new int[] { android.R.attr.state_pressed }, mPressedDrawable); sld.addState(new int[]{android.R.attr.state_enabled}, mEnabledDrawable);// enabled (1) sld.addState(new int[]{-android.R.attr.state_enabled}, mDisabledDrawable);//disabled The next code below always displays the enabled state, as the enabled level is low(1), but is added first in the execution order. Presumably the states are added to an internal array and so the first state that satisfies the StateListDrawable’s current state is used (i.e. even if its selected it is also enabled and because enabled is added before the selected state, the Read more…

Flyin menu using offsetLeftAndRight not preserving after a layout

Written on November 27, 2012 at 2:09 pm, by

While making the flyout menu for the new MyPOD I encountered a little bug that I couldn’t find an answer for. The problem .. I was using offsetLeftAndRight to hold the flyout “open” after the animation finishes (simply using fillAfter on the animation produces and annoying flicker). This method takes a "relative" amount to move (i.e. the amount to offset the view from it’s current position). So this container hold whatever content might be in the front screen. But the problem was that whenever a child in this container called requestLayout. the offset would be wiped, and so the flyout would appear to suddenly close. The API >10 solution HoneyComb added the onLayoutChangeListener which makes it really easy to restore the old value, it is just provided in the method call. if (Build.VERSION.SDK_INT>10) { _contentContainer.addOnLayoutChangeListener(new OnLayoutChangeListener() { @Override public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) { _contentContainer.offsetLeftAndRight(oldLeft); } }); } And for the rest … API

MyPOD re-write, vector graphics improvements & DroidCon

Written on September 26, 2012 at 5:44 pm, by

MYPOD re-write is on The MyPOD re-write has started in earnest – we are working with some high caliber UX / UI specialists to make this full upgrade something special. We have been putting out feelers with some users about the new design and the feedback has been great. So watch this space for some great news over the next couple of months. This re-write will address the usability bugs that some have complained about, as well as strengthen & make the app features easier to find and use. Vectoroid SVG improvements As part of the MyPOD re-write there have been a number of improvements in the Vectoroid library. Those pesky Arc’s are fully functional, and support will be in the upcoming release (0.83) in a couple of weeks. Also coming in the next version are SVG drawables – These can be used in any android component that takes a drawables (which is anything). There are still a few kinks to iron through – but it works, and they are crisp … No more will I make 4 versions of each icon. DroidCon London http://uk.droidcon.com/ The 2012 DroidCon is almost upon us. It is really getting bigger every year and this year looks to be no different. Talks on Android x86, AndEngine, AI, Animations, Custom components and Google TV are the subjects that I am looking at. I may even sneak in a BarCamp talk on Vectoroid. Hope to see you there.

Patenting tap to zoom is like patenting DNA

Written on August 25, 2012 at 3:23 pm, by

Yes, Apple you won. I would say that a number of people told me that they bought a galaxy S2 cos it looked "a bit" like and iPhone. So there is some merit to that aspect … But, where are we heading? Using these patents to wage war with – they are so basic if companies and patent trolls let rip with some of these then we are all in trouble… Tech evolves quickly. In some ways there is a lot of evidence that the first mover is not always the ultimate winner. But Android AND Apple have created cultures and to subject actual users to limits on these simple functions isn’t an option – it all about getting da monay. Weather they like to acknowledge it or not, they are creating a space together – people passionate about iPhone – people passionate about Android. This, right here, is the danger of software patents. When obvious things (that generally come up in user testing – i.e. testing what feels *natural* to a user). Denying tap to zoom (and pinch to zoom? not sure on this) as a natural part of tech progression is in some ways like patenting DNA because they were just testing what feels natural for the user – probably other testing found the same thing – just because Apple did it a bit before shouldn’t give them global rights to it. Some of the knowledge captured in these patents should possibly be public domain as it relates Read more…