[Android Q&A, Help & Troubleshooting] letolkki:
OS: Ice Cream Sandwich

Device: Motorola Xoom

I am having issues with a simple service not running correctly.

The logcat shows some force stopping on the installed apk. Also the broadcast receiver should listen to android.intent.action.ACTION_POWER_CONNECTED but it is not. Any insight?

This all worked on froyo 2.2 on a samsung galaxy tab.

Here is the snippet from logcat when I do an 'adb install testService.apk:

D/AndroidRuntime(15251):
D/AndroidRuntime(15251): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
D/AndroidRuntime(15251): CheckJNI is OFF
D/AndroidRuntime(15251): Calling main entry com.android.commands.pm.Pm
I/ActivityManager( 153): Start proc com.android.defcontainer for service com.android.defcontainer/.DefaultContainerService: pid=15261 uid=10010 gids={1015, 2001}
W/PackageManager( 153): Couldn't get low memory threshold; no free limit imposed
W/ActivityManager( 153): No content provider found for permission revoke: file:///data/local/tmp/testService.apk
W/ActivityManager( 153): No content provider found for permission revoke: file:///data/local/tmp/testService.apk
I/PackageManager( 153): Running dexopt on: com.example.testservice
D/dalvikvm(15275): DexOpt: load 4ms, verify+opt 1ms
I/ActivityManager( 153): Force stopping package com.example.testservice uid=10014
D/PackageManager( 153): New package installed in /data/app/com.example.testservice-1.apk
D/PackageManager( 153): generateServicesMap(android.accounts.AccountAuthenticator): 3 services unchanged
D/PackageManager( 153): generateServicesMap(android.content.SyncAdapter): 11 services unchanged
I/ActivityManager( 153): Start proc com.android.voicedialer for broadcast com.android.voicedialer/.VoiceDialerReceiver: pid=15276 uid=10037 gids={3002}
W/ResourceType( 153): Failure getting entry for 0x7f060000 (t=5 e=0) in package 0 (error -75)
D/dalvikvm( 153): GC_CONCURRENT freed 1216K, 16% free 9901K/11783K, paused 3ms+7ms
D/dalvikvm(15276): Debugger has detached; object registry had 1 entries
D/BackupManagerService( 153): Received broadcast Intent { act=android.intent.action.PACKAGE_ADDED dat=package:com.example.testservice flg=0x10000010 (has extras) }
V/BackupManagerService( 153): addPackageParticipantsLocked: com.example.testservice
I/ActivityManager( 153): Start proc com.android.musicfx for broadcast com.android.musicfx/.Compatibility$Receiver: pid=15289 uid=10022 gids={3003, 3002}
I/ActivityManager( 153): Start proc com.svox.pico for broadcast com.svox.pico/.VoiceDataInstallerReceiver: pid=15303 uid=10025 gids={1015}
I/ActivityThread(15303): Pub com.svox.pico.providers.SettingsProvider: com.svox.pico.providers.SettingsProvider
I/ActivityManager( 153): Start proc com.google.android.partnersetup for broadcast com.google.android.partnersetup/.RlzPingBroadcastReceiver: pid=15318 uid=10049 gids={3003}
I/ActivityManager( 153): No longer want com.google.android.googlequicksearchbox (pid 1229): hidden #16
I/ActivityThread(15318): Pub com.google.android.partnersetup.rlzprovider: com.google.android.partnersetup.RlzProvider
I/ActivityThread(15318): Pub com.google.android.partnersetup.rlzappprovider: com.google.android.partnersetup.RlzAppProvider
D/dalvikvm( 153): GC_EXPLICIT freed 538K, 17% free 9866K/11783K, paused 2ms+11ms
D/AndroidRuntime(15251): Shutting down VM
I/AndroidRuntime(15251): NOTE: attach of thread 'Binder Thread #3' failed
D/dalvikvm(15251): GC_CONCURRENT freed 101K, 83% free 457K/2560K, paused 1ms+0ms
D/jdwp (15251): Got wake-up signal, bailing out of select
D/dalvikvm(15251): Debugger has detached; object registry had 1 entries
I/ActivityManager( 153): Start proc com.google.android.googlequicksearchbox for broadcast com.google.android.googlequicksearchbox/.SourceUpdateReceiver: pid=15333 uid=10048 gids={3003}
I/ActivityManager( 153): No longer want com.android.bluetooth (pid 1661): hidden #16
W/ActivityManager( 153): Scheduling restart of crashed service com.android.bluetooth/.pbap.BluetoothPbapService in 5000ms
W/ActivityManager( 153): Scheduling restart of crashed service com.android.bluetooth/.opp.BluetoothOppService in 14999ms
I/ActivityThread(15333): Pub com.google.android.googlequicksearchbox.shortcuts: com.google.android.googlequicksearchbox.WebHistoryProvider
I/ActivityThread(15333): Pub com.google.android.googlequicksearchbox.google: com.google.android.googlequicksearchbox.google.GoogleSuggestionProvider
I/ActivityManager( 153): No longer want com.google.android.apps.uploader (pid 3836): hidden #16
I/ActivityManager( 153): Start proc com.android.bluetooth for service com.android.bluetooth/.pbap.BluetoothPbapService: pid=15354 uid=10003 gids={3003, 3002, 3001, 1015}
I/ActivityThread(15354): Pub com.android.bluetooth.opp: com.android.bluetooth.opp.BluetoothOppProvider
I/ActivityManager( 153): No longer want com.android.browser (pid 1455): hidden #16
I/BtOppRfcommListener(15354): Accept thread started on channel 12
W/PowerUI ( 225): unknown intent: Intent { act=android.intent.action.ACTION_POWER_CONNECTED flg=0x10000010 }
D/dalvikvm( 225): GC_CONCURRENT freed 384K, 61% free 7755K/19399K, paused 6ms+4ms
W/PowerUI ( 225): unknown intent: Intent { act=android.intent.action.ACTION_POWER_CONNECTED flg=0x10000010 }
D/dalvikvm( 153): GC_CONCURRENT freed 781K, 17% free 9810K/11783K, paused 8ms+5ms
D/Smack ( 298): [SSLXMPPConnection@1091877224] create socket connection(mtalk.google.com, 5228)

Here is my broadcastReciever.

package com.example.testservice;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;

public class myApplicationReceiver extends BroadcastReceiver {

@Override
public void onReceive(Context context, Intent intent) {
// TODO Auto-generated method stub
Log.i("TESTING-receiver",intent.getAction());
}

}

and here is my manifest:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.testservice"
android:versionCode="1"
android:versionName="1.0">

<uses-sdk android:minSdkVersion="15" android:targetSdkVersion="15" />

<application android:label="@string/app_name"
android:icon="@drawable/ic_launcher"
android:theme="@style/AppTheme">
<receiver android:name="myApplicationReceiver">
<intent-filter>
<action android:name="android.intent.action.ACTION_POWER_CONNECTED"/>
</intent-filter>
</receiver>

</application>

</manifest>