Skip to Content

Page 1
Earlier »
spacer spacer

Blog

Archives | Tags
  • October 2014 (2)
  • August 2014 (1)
  • March 2014 (1)
  • February 2014 (1)
  • June 2013 (1)
  • May 2013 (1)
  • November 2012 (1)
  • September 2012 (1)
  • August 2012 (1)
  • July 2012 (2)
  • June 2012 (3)
  • May 2012 (2)
  • April 2012 (3)
  • March 2012 (1)
  • January 2012 (1)
  • December 2011 (1)
  • November 2011 (1)
  • October 2011 (4)
  • September 2011 (2)
  • July 2011 (1)
  • June 2011 (1)
  • May 2011 (1)
  • March 2011 (2)
  • November 2010 (2)
  • October 2010 (1)
  • September 2010 (6)
  • August 2010 (1)
  • June 2010 (1)
  • April 2010 (1)
  • October 2009 (1)
  • August 2009 (2)
appz codez designz eventz extraz funz mypod newz opinionz phonez prez probz silenttimer suprcards tabz tvz vectoroid
Tweet
10th October 2014 by admin. 0 Comments.

Android studio hangs “Waiting for ADB”

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.
Tweet
7th October 2014 by admin. 0 Comments.

Recover files from a non booting device

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] developer.android.com/sdk/index.html
Tweet
7th August 2014 by admin. 0 Comments.

Some great in depth turtorials and slide for Android tasks

These are some great tutorial/slides I found recently:

Threading:
www.slideshare.net/andersgoransson/efficient-android-threading

Loaders:
www.slideshare.net/cbeyls/android-loaders-reloaded

Android source:
Android Source Code Guided Tour from Kevin McDonagh

Tweet
15th March 2014 by admin. 0 Comments.

Setting up Junit ServiceTestUnit tests with Application references

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
}
Tweet
23rd February 2014 by admin. 0 Comments.

Using CSS precedence

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.

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: www.w3.org/TR/CSS2/cascade.html
Tweet
19th June 2013 by admin. 1 Comment.

Fixing performance issues in Ubuntu 12.10

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” (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

spacer

Processor info

spacer

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.

spacer

Installation

Installation is quite simple, the instructions are for Quantal :

  1. Check you are running Quantal (The links below are for that release – 12.10 Quantal) (running lsb_release -a)
  2. Download the DEBs: granola_5.0.15-0quantal1_amd64.deb, granola-gui_5.0.15-0quantal1_amd64.deb
  3. Install the debs, I just click on them but you can use sudo dpkg -i granola_5.0.15*.deb in the download directory to install form the command line).
  4. To start granola run it as root (sudo granola)
  5. You can launch the GUI program which is installed in Accessories > Granola
  6. Edit > Preferences > Switch to “Highest Power” (see screen below)

Unfortunately to fix my problem I need to set my computer to highest power – which isn’t really in the spirit of the project – but the GUI tool and associated software do give the the option to change the settings at will. So as long as I remember to switch over then there are still contributions to be made.

spacer

Afterwards, lscpu shows a better result:

$ 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:               3401.000
BogoMIPS:              6784.14
Virtualisation:        VT-x
L1d cache:             32K
L1i cache:             32K
L2 cache:              256K
L3 cache:              8192K
NUMA node0 CPU(s):     0-7

Not using swap space?

https://help.ubuntu.com/community/SwapFaq

checking memory type

www.crucial.com/store/listmodule/DDR3/list.html $ sudo dmidecode –type memory # dmidecode 2.11 # SMBIOS entry point at 0xbab5ed98 SMBIOS 2.6 present. Handle 0x000F, DMI type 16, 15 bytes Physical Memory Array Location: System Board Or Motherboard Use: System Memory Error Correction Type: None Maximum Capacity: 8 GB Error Information Handle: Not Provided Number Of Devices: 2 Handle 0x0011, DMI type 17, 28 bytes Memory Device Array Handle: 0x000F Error Information Handle: Not Provided Total bits Data bits Size: No Module Installed Form Factor: DIMM Set: None Locator: DIMM1 Bank Locator: BANK0 Type: Unknown Type Detail: Synchronous Speed: Unknown Manufacturer: A1_Manufacturer0 Serial Number: A1_SerNum0 Asset Tag: A1_AssetTagNum0 Part Number: Array1_PartNumber0 Rank: Unknown Handle 0x0013, DMI type 17, 28 bytes Memory Device Array Handle: 0x000F Error Information Handle: Not Provided Total bits Data bits Size: 4096 MB Form Factor: DIMM Set: None Locator: DIMM3 Bank Locator: BANK2 Type: DDR3 Type Detail: Synchronous Speed: 1333 MHz Manufacturer: Samsung Serial Number: 232E6316 Asset Tag: A1_AssetTagNum1 Part Number: M378B5273DH0-CH9 Rank: 2
Tweet
25th May 2013 by admin. 0 Comments.

Weekly issues of interest

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 enabled drawable is used)

StateListDrawable sld = new StateListDrawable();
sld.addState(new int[]{android.R.attr.state_enabled},  mEnabledDrawable);// enabled (1)
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}, mDisabledDrawable);//disabled

Tweet
gipoco.com is neither affiliated with the authors of this page nor responsible for its contents. This is a safe-cache copy of the original web site.