2012-12-13 49 views
1

在這裏,我的清單?是一個明顯的問題?花了很多時間來發現問題...是一個按意圖啓動課程的服務(使用警報管理器)。如果沒有清單問題,那麼問題是什麼?無法啓動服務Intent {flg = 0x4 cmp = mypackage/.AlarmReceiver(has extras)}:找不到

感謝您的幫助!

startService(new Intent(this, UnUsedService.class)); 

UnUsedService

public class UnUsedService extends Service { 

//private PendingIntent pendingIntent; 

@Override 
public IBinder onBind(Intent intent) { 
return null; 
} 
@Override 
public void onCreate() { 
super.onCreate(); 
Toast.makeText(this, "Service Created", Toast.LENGTH_LONG).show(); 

//startService(new Intent(this, UnUsedService.class)); 
} 
@Override 
public void onDestroy() { 
super.onDestroy(); 
Toast.makeText(this, "Service Destroyed", Toast.LENGTH_LONG).show(); 
} 

private PendingIntent pendingIntent; 

@SuppressWarnings("deprecation") 
@Override 
public void onStart(Intent intent, int startId) { 

// super.onStart(); 
super.onStart(intent, startId); 

Toast.makeText(this, "Service Started", Toast.LENGTH_LONG).show(); 

Calendar calendar = Calendar.getInstance(); 
calendar.set(Calendar.HOUR_OF_DAY, 23); 
calendar.set(Calendar.MINUTE, 32); 
calendar.set(Calendar.SECOND, 0); AlarmManager am = (AlarmManager)  getApplicationContext().getSystemService (Context.ALARM_SERVICE); 
PendingIntent pi = PendingIntent.getService(getApplicationContext(), 0, new Intent(getApplicationContext(),  AlarmReceiver.class),  PendingIntent.FLAG_UPDATE_CURRENT); 
am.setRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(),  AlarmManager.INTERVAL_DAY, pi); 
am.setRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis()+1000,  AlarmManager.INTERVAL_DAY, pi); 

}}; 

接收器:

<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
    package="com.example.mypackage" 
    android:versionCode="1" 
    android:versionName="1" > 

    <uses-sdk 
     android:minSdkVersion="8" 
     android:targetSdkVersion="17" /> 
    <application 
     android:allowBackup="true" 
     android:icon="@drawable/ic_launcher" 
     android:label="@string/app_name" 
     android:theme="@style/AppTheme" android:name="CrashReports"> 

     <service android:name="UnUsedService"> 
     <intent-filter> 
     <action 
     android:name="org.gortcloud.startatboot.UnUsedService" /> 
     </intent-filter> 
     </service> 

     <receiver android:name="AutoStart"> 
     <intent-filter> 
     <action 
     android:name="android.intent.action.BOOT_COMPLETED" /> 
     <category android:name="android.intent.category.HOME" /> 
     </intent-filter> 
     </receiver> 

     <receiver android:name="AlarmReceiver" android:process=":remote"/> 

     <activity 
      android:name="com.example.mypackage.MainActivity" 
      android:label="@string/app_name" > 
      <intent-filter> 
       <action android:name="android.intent.action.MAIN" /> 
       <category android:name="android.intent.category.LAUNCHER" /> 
      </intent-filter> 
     </activity> 
     <service android:enabled="true" android:name=".SobService"/> 

     <activity android:name="Index"></activity> 
     <activity android:name="SendText"></activity> 

    </application> 
</manifest> 

logcat的

E/ThrottleService( 149): problem during onPollAlarm: java.lang.IllegalStateException: problem parsing stats: java.io.FileNotFoundException: /proc/net/xt_qtaguid/iface_stat_all: open failed: ENOENT (No such file or directory) 
D/dalvikvm( 149): GC_CONCURRENT freed 637K, 13% free 8307K/9479K, paused 25ms+12ms, total 142ms 
D/AndroidRuntime(14611): 
D/AndroidRuntime(14611): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<< 
D/AndroidRuntime(14611): CheckJNI is ON 
D/dalvikvm(14611): Trying to load lib libjavacore.so 0x0 
D/dalvikvm(14611): Added shared lib libjavacore.so 0x0 
D/dalvikvm(14611): Trying to load lib libnativehelper.so 0x0 
D/dalvikvm(14611): Added shared lib libnativehelper.so 0x0 
D/AndroidRuntime(14611): Calling main entry com.android.commands.pm.Pm 
W/ActivityManager( 149): No content provider found for permission revoke: file:///data/local/tmp/MainActivity.apk 
D/dalvikvm(2860): GC_CONCURRENT freed 457K, 14% free 5292K/6087K, paused 17ms+4ms, total 75ms 
W/ActivityManager( 149): No content provider found for permission revoke: file:///data/local/tmp/MainActivity.apk 
D/dalvikvm( 149): GC_CONCURRENT freed 614K, 12% free 8360K/9479K, paused 22ms+30ms, total 125ms 
D/dalvikvm( 149): GC_FOR_ALLOC freed 282K, 13% free 8265K/9479K, paused 69ms, total 70ms 
D/dalvikvm( 149): GC_FOR_ALLOC freed 234K, 13% free 8267K/9479K, paused 86ms, total 87ms 
D/dalvikvm( 149): GC_FOR_ALLOC freed 239K, 13% free 8270K/9479K, paused 68ms, total 68ms 
I/PackageManager( 149): Removing non-system package:org.gortcloud.perledisaggezza 
I/ActivityManager( 149): Force stopping package org.gortcloud.perledisaggezza uid=10044 
I/ActivityManager( 149): Killing proc 10610:org.gortcloud.perledisaggezza/u0a44: force stop 
W/ActivityManager( 149): Force removing ActivityRecord{411fe0f0 org.gortcloud.perledisaggezza/.MainActivity}: app died, no saved state 
W/InputDispatcher( 149): channel '412b50c0 org.gortcloud.perledisaggezza/org.gortcloud.perledisaggezza.MainActivity (server)' ~ Consumer closed input channel or an error occurred. events=0x9 
E/InputDispatcher( 149): channel '412b50c0 org.gortcloud.perledisaggezza/org.gortcloud.perledisaggezza.MainActivity (server)' ~ Channel is unrecoverably broken and will be disposed! 
I/WindowState( 149): WIN DEATH: Window{412b50c0 org.gortcloud.perledisaggezza/org.gortcloud.perledisaggezza.MainActivity paused=false} 
W/InputDispatcher( 149): Attempted to unregister already unregistered input channel '412b50c0 org.gortcloud.perledisaggezza/org.gortcloud.perledisaggezza.MainActivity (server)' 
I/Choreographer( 149): Skipped 75 frames! The application may be doing too much work on its main thread. 
I/WindowManager( 149): WINDOW DIED Window{412b50c0 org.gortcloud.perledisaggezza/org.gortcloud.perledisaggezza.MainActivity paused=false} 
I/Choreographer( 258): Skipped 238 frames! The application may be doing too much work on its main thread. 
I/PackageManager( 149): Package org.gortcloud.perledisaggezza codePath changed from /data/app/org.gortcloud.perledisaggezza-2.apk to /data/app/org.gortcloud.perledisaggezza-1.apk; Retaining data and using new 
W/InputMethodManagerService( 149): Got RemoteException sending setActive(false) notification to pid 10610 uid 10044 
I/PackageManager( 149): Running dexopt on: org.gortcloud.perledisaggezza 
D/dalvikvm(14630): DexOpt: load 129ms, verify+opt 643ms, 962252 bytes 
W/PackageManager( 149): Code path for pkg : org.gortcloud.perledisaggezza changing from /data/app/org.gortcloud.perledisaggezza-2.apk to /data/app/org.gortcloud.perledisaggezza-1.apk 
W/PackageManager( 149): Resource path for pkg : org.gortcloud.perledisaggezza changing from /data/app/org.gortcloud.perledisaggezza-2.apk to /data/app/org.gortcloud.perledisaggezza-1.apk 
D/dalvikvm( 149): GC_FOR_ALLOC freed 320K, 13% free 8281K/9479K, paused 72ms, total 73ms 
I/ActivityManager( 149): Force stopping package org.gortcloud.perledisaggezza uid=10044 
D/PackageManager( 149): New package installed in /data/app/org.gortcloud.perledisaggezza-1.apk 
W/PackageManager( 149): Not granting permission android.permission.READ_LOGS to package org.gortcloud.perledisaggezza (protectionLevel=50 flags=0x8be46) 
I/ActivityManager( 149): Force stopping package org.gortcloud.perledisaggezza uid=10044 
D/dalvikvm( 204): WAIT_FOR_CONCURRENT_GC blocked 0ms 
D/dalvikvm( 258): WAIT_FOR_CONCURRENT_GC blocked 1ms 
D/dalvikvm( 204): GC_EXPLICIT freed 216K, 62% free 5881K/15367K, paused 8ms+19ms, total 155ms 
D/dalvikvm( 258): GC_EXPLICIT freed 409K, 39% free 7423K/12103K, paused 8ms+22ms, total 156ms 
D/dalvikvm( 323): WAIT_FOR_CONCURRENT_GC blocked 0ms 
D/dalvikvm( 323): GC_EXPLICIT freed 177K, 10% free 5564K/6151K, paused 8ms+9ms, total 88ms 
I/InputReader( 149): Reconfiguring input devices. changes=0x00000010 
D/PackageManager( 149): generateServicesMap(android.accounts.AccountAuthenticator): 2 services unchanged 
D/PackageManager( 149): generateServicesMap(android.content.SyncAdapter): 4 services unchanged 
D/BackupManagerService( 149): Received broadcast Intent { act=android.intent.action.PACKAGE_REMOVED dat=package:org.gortcloud.perledisaggezza flg=0x8000010 (has extras) } 
D/dalvikvm( 149): WAIT_FOR_CONCURRENT_GC blocked 0ms 
I/AccountTypeManager( 367): Loaded meta-data for 1 account types, 0 accounts in 53ms(wall) 5ms(cpu) 
D/dalvikvm( 149): GC_EXPLICIT freed 503K, 15% free 8140K/9479K, paused 65ms+21ms, total 204ms 
I/InputReader( 149): Reconfiguring input devices. changes=0x00000010 
D/PackageManager( 149): generateServicesMap(android.accounts.AccountAuthenticator): 2 services unchanged 
D/PackageManager( 149): generateServicesMap(android.content.SyncAdapter): 4 services unchanged 
D/BackupManagerService( 149): Received broadcast Intent { act=android.intent.action.PACKAGE_ADDED dat=package:org.gortcloud.perledisaggezza flg=0x8000010 (has extras) } 
V/BackupManagerService( 149): removePackageParticipantsLocked: uid=10044 #1 
V/BackupManagerService( 149): addPackageParticipantsLocked: #1 
W/InputMethodManagerService( 149): Found no subtypes in a system IME: com.android.inputmethod.pinyin 
I/AccountTypeManager( 367): Loaded meta-data for 1 account types, 0 accounts in 11ms(wall) 7ms(cpu) 
I/Choreographer( 258): Skipped 533 frames! The application may be doing too much work on its main thread. 
D/dalvikvm( 149): WAIT_FOR_CONCURRENT_GC blocked 0ms 
D/dalvikvm( 367): GC_CONCURRENT freed 403K, 12% free 5471K/6215K, paused 100ms+14ms, total 174ms 
W/RecognitionManagerService( 149): no available voice recognition services found 
D/dalvikvm( 149): GC_EXPLICIT freed 400K, 14% free 8170K/9479K, paused 27ms+47ms, total 266ms 
D/AndroidRuntime(14611): Shutting down VM 
D/dalvikvm(14611): GC_CONCURRENT freed 101K, 78% free 458K/2048K, paused 2ms+1ms, total 13ms 
D/jdwp (14611): Got wake-up signal, bailing out of select 
D/dalvikvm(14611): Debugger has detached; object registry had 1 entries 
I/AndroidRuntime(14611): NOTE: attach of thread 'Binder_3' failed 
D/AndroidRuntime(14647): 
D/AndroidRuntime(14647): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<< 
D/AndroidRuntime(14647): CheckJNI is ON 
D/dalvikvm(14647): Trying to load lib libjavacore.so 0x0 
D/dalvikvm(14647): Added shared lib libjavacore.so 0x0 
D/dalvikvm(14647): Trying to load lib libnativehelper.so 0x0 
D/dalvikvm(14647): Added shared lib libnativehelper.so 0x0 
D/AndroidRuntime(14647): Calling main entry com.android.commands.am.Am 
I/ActivityManager( 149): START {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=org.gortcloud.perledisaggezza/.MainActivity u=0} from pid 14647 
W/WindowManager( 149): Failure taking screenshot for (123x221) to layer 21025 
D/AndroidRuntime(14647): Shutting down VM 
D/dalvikvm(14647): GC_CONCURRENT freed 102K, 77% free 489K/2048K, paused 1ms+2ms, total 11ms 
D/jdwp (14647): Got wake-up signal, bailing out of select 
D/dalvikvm(14647): Debugger has detached; object registry had 1 entries 
I/AndroidRuntime(14647): NOTE: attach of thread 'Binder_3' failed 
D/dalvikvm( 258): GC_CONCURRENT freed 539K, 38% free 7520K/12103K, paused 16ms+127ms, total 360ms 
D/dalvikvm(14658): Not late-enabling CheckJNI (already on) 
I/ActivityManager( 149): Start proc org.gortcloud.perledisaggezza for activity org.gortcloud.perledisaggezza/.MainActivity: pid=14658 uid=10044 gids={3003, 1028} 
E/Trace (14658): error opening trace file: No such file or directory (2) 
I/Choreographer( 149): Skipped 35 frames! The application may be doing too much work on its main thread. 
D/ACRA (14658): ACRA is enabled for org.gortcloud.perledisaggezza, intializing... 
D/ACRA (14658): Using default Report Fields 
D/ACRA (14658): Looking for error files in /data/data/org.gortcloud.perledisaggezza/files 
D/dalvikvm(14658): GC_FOR_ALLOC freed 179K, 9% free 5372K/5895K, paused 31ms, total 32ms 
I/dalvikvm-heap(14658): Grow heap (frag case) to 5.965MB for 457616-byte allocation 
D/dalvikvm(14658): GC_CONCURRENT freed 1K, 9% free 5817K/6343K, paused 19ms+13ms, total 61ms 
D/dalvikvm(14658): GC_CONCURRENT freed 48K, 6% free 6322K/6663K, paused 15ms+4ms, total 65ms 
D/dalvikvm(14658): WAIT_FOR_CONCURRENT_GC blocked 18ms 
D/dalvikvm(14658): GC_FOR_ALLOC freed 48K, 6% free 6464K/6855K, paused 41ms, total 41ms 
I/dalvikvm-heap(14658): Grow heap (frag case) to 7.234MB for 668816-byte allocation 
D/dalvikvm(14658): GC_FOR_ALLOC freed <1K, 6% free 7117K/7559K, paused 58ms, total 58ms 
D/dalvikvm(14658): GC_CONCURRENT freed <1K, 6% free 7117K/7559K, paused 16ms+4ms, total 64ms 
I/Choreographer(14658): Skipped 58 frames! The application may be doing too much work on its main thread. 
I/Choreographer(14658): Skipped 233 frames! The application may be doing too much work on its main thread. 
D/gralloc_goldfish(14658): Emulator without GPU emulation detected. 
I/ActivityManager( 149): Displayed org.gortcloud.perledisaggezza/.MainActivity: +1s713ms 
I/Choreographer( 149): Skipped 61 frames! The application may be doing too much work on its main thread. 
I/Choreographer( 149): Skipped 43 frames! The application may be doing too much work on its main thread. 
I/Choreographer(14658): Skipped 271 frames! The application may be doing too much work on its main thread. 
D/dalvikvm( 243): GC_CONCURRENT freed 384K, 13% free 5798K/6599K, paused 4ms+4ms, total 36ms 
I/Choreographer(14658): Skipped 46 frames! The application may be doing too much work on its main thread. 
I/Choreographer( 149): Skipped 36 frames! The application may be doing too much work on its main thread. 
D/dalvikvm(14692): Not late-enabling CheckJNI (already on) 
I/ActivityManager( 149): Start proc org.gortcloud.perledisaggezza:remote for broadcast org.gortcloud.perledisaggezza/.AlarmReceiver: pid=14692 uid=10044 gids={3003, 1028} 
E/Trace (14692): error opening trace file: No such file or directory (2) 
D/ACRA (14692): ACRA is enabled for org.gortcloud.perledisaggezza, intializing... 
D/ACRA (14692): Using default Report Fields 
D/ACRA (14692): Looking for error files in /data/data/org.gortcloud.perledisaggezza/files 
D/gralloc_goldfish(14692): Emulator without GPU emulation detected. 

UnUsedService(從我的活動啓動

public class AlarmReceiver extends BroadcastReceiver { 
    @Override 
    public void onReceive(Context context, Intent intent) { 
     Toast.makeText(context, "Alarm worked.", Toast.LENGTH_LONG).show(); 

    } 
} 
+0

發佈您的所有LogCat錯誤和相關的Java代碼,所以我們可以看到更多的事情發生。 – Sam

+0

我更新了我的代碼,感謝您的幫助! –

回答

3

我注意到,你所創建的錯誤類型的PendingIntent的:

pendingIntent = PendingIntent.getService(UnUsedService.this, 0, myIntent, 0); 

你想定位廣播接收器,所以你需要使用:

pendingIntent = PendingIntent.getBroadcast(AlarmReceiver.this, 0, myIntent, 0); 
+0

對不起...我現在刪除舊的(測試代碼)是正確的代碼,我檢查... –

+0

你仍然調用'PendingIntent.getService()'而不是'getBroadcast()'並且你發佈了所有的LogCat錯誤? – Sam

+0

非常感謝您的幫助!解決了!!! :-D –

-1

而不是在你的主要。 。

試試這個

<activity android:name="com.example.mypackage.Index"></activity> 
    <activity android:name="com.example.mypackage.SendText"></activity> 
相關問題