2012-01-11 94 views
0

我一直在試圖讓SmsReceiver擴展BroadcastReceiver在HTC Desire HD上工作。SmsReceiver BroadcastReceiver問題

我沒有程序爲我的Msgs下載,只是使用手機給我。

我在onReceive函數下有一個日誌,我從來沒有看到它。

合理的新本所以任何幫助將是巨大的:)謝謝

Java類


import android.content.BroadcastReceiver; 
import android.content.Context; 
import android.content.Intent; 
import android.os.Bundle; 
import android.telephony.SmsMessage; 
import android.util.Log; 
import android.widget.Toast; 

public class SmsReceiver extends BroadcastReceiver 
{ 
@Override 
public void onReceive(Context context, Intent intent) 
{ 
Log.d("SIM", "AAAAAAAAAAAAAAAAAAAAAAAAAAA"); 
Toast.makeText(context, "Message", Toast.LENGTH_SHORT).show();  
} 
} 

的Manifest.xml

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

<uses-sdk android:minSdkVersion="10" /> 

<uses-permission android:name="android.permission.INTERNET"></uses-permission> 
<uses-permission android:name="android.permission.RECEIVE_SMS"></uses-permission> 
<uses-permission android:name="android.permission.SEND_SMS"></uses-permission> 


<application 
android:icon="@drawable/ic_launcher" 
android:label="@string/app_name" > 
<activity 
android:label="@string/app_name" 
android:name=".Main" > 
<intent-filter > 
<action android:name="android.intent.action.MAIN" /> 
<category android:name="android.intent.category.LAUNCHER" /> 
</intent-filter> 

<receiver android:name=".SmsReceiver" android:enabled="true"> 
<intent-filter android:priority="2147483647"> 
<action android:name="android.provider.Telephony.SMS_RECEIVED"></action> 
</intent-filter> 
</receiver>     

</activity> 
</application> 
</manifest> 

logcat的日誌下面


01-11 13:43:50.078: D/Jerry(1438): messageRef >182 
01-11 13:43:50.078: D/Jerry(1438): ackPDU >null 
01-11 13:43:50.078: D/Jerry(1438): errorCode >-1 
01-11 13:43:50.078: D/Jerry(1438): handleMessage >2 
01-11 13:43:50.178: D/Jerry(1438): handleMessage >1 
01-11 13:43:50.178: D/SMSDispatcher(1438): dispatchWapPushToCIQ >>> 
01-11 13:43:50.178: D/SMSDispatcher(1438): dispatchWapPushToCIQ >>> 
01-11 13:43:50.228: V/SmsReceiverService(8697): onStart: #1 
01-11 13:43:50.238: V/SmsReceiverService(8697): action: android.provider.Telephony.SMS_RECEIVED 
01-11 13:43:50.238: D/SmsReceiverService(8697): [HTC_MESSAGES] - SmsReceiverService: handleSmsReceived() 
01-11 13:43:50.238: D/SmsReceiverService(8697): isEvdo: false before inserMessage 
01-11 13:43:50.238: D/SmsReceiverService(8697): extractContentValues: not EVDO 
01-11 13:43:50.238: D/SmsReceiverService(8697): MsgBase: from Evdo: false 
01-11 13:43:50.238: D/SmsProvider(1438): insert url=content://sms/inbox, match=2 
01-11 13:43:50.248: D/SmsProvider(1438): thread id> null 
01-11 13:43:50.248: D/MmsSmsProvider(1438): ids: 73 
01-11 13:43:50.248: D/MmsSmsProvider(1438): recipientIds: 73 
01-11 13:43:50.248: D/SmsProvider(1438): get thread id> 114 
01-11 13:43:50.278: D/MmsSmsV2Provider(1438): Notify ContactMessageStore new thread have been created 
01-11 13:43:50.278: D/ContactMessageStore(1438): insertContactsTable> 114, 0 
01-11 13:43:50.278: D/ContactMessageStore(1438): getContactsTableStr> contacts1 
01-11 13:43:50.278: D/ContactMessageStore(1438): insertContactsTable() 114, 98 already exist 
01-11 13:43:50.278: D/MmsSmsDatabaseHelper(1438): refreshThreadsTable: 114 
01-11 13:43:50.448: D/MmsSmsDatabaseHelper(1438): refreshThreadsTable count: 1 
01-11 13:43:50.458: D/SmsReceiverService(8697): insertUri> content://sms/2287 
01-11 13:43:50.458: D/SmsReceiverService(8697): class: UNKNOWN 
01-11 13:43:50.458: D/Messaging(8697): accumulateNewIncomingMSG> 2 
01-11 13:43:50.468: D/MmsSmsProvider(1438): ids: 73 
01-11 13:43:50.468: D/MmsSmsProvider(1438): recipientIds: 73 
01-11 13:43:50.478: V/Recycler(8697): Recycler.deleteOldMessagesByThreadId this: [email protected] threadId: 114 
01-11 13:43:50.478: D/MessagingNotification(8697): New incoming message, can't cancel notification now 
01-11 13:43:50.478: D/MessagingNotification(8697): newMsgCnt: 2, true 
01-11 13:43:50.518: D/MessagingNotification(8697): Thread id > 114 
01-11 13:43:50.518: D/MessagingNotification(8697): Contact id > 100000098 
01-11 13:43:50.518: D/MessagingNotification(8697): Unread count: 18, 2 
01-11 13:43:50.518: D/MessagingNotification(8697): updateNotification> 
01-11 13:43:50.518: E/xxxx!!(8697): ringtoneStr= content://media/internal/audio/media/3 
01-11 13:43:50.528: D/MessagingNotification(8697): getValidNotificationUri> content://media/internal/audio/media/3 
01-11 13:43:50.548: D/NotificationFlashLightUtility getIncomingCall(8697): load fail~~~~~~~~~~ 
01-11 13:43:50.548: D/MessagingNotification(8697): show notification 
01-11 13:43:50.548: D/MessagingNotification(8697): notifyNotification> 123 
01-11 13:43:50.548: D/MessagingNotification(8697): threadID> 114 
01-11 13:43:50.548: D/MessagingNotification(8697): addItemIntoIdList> [114] 
01-11 13:43:50.548: D/StatusBarService(31423): old notification: when=1326250052000 ongoing=false [email protected] [email protected] 
01-11 13:43:50.548: D/StatusBarService(31423): new notification: when=1326250098000 ongoing=false [email protected] 
01-11 13:43:50.568: D/MediaPlayer(1326): setDataSource(Context context, content://media/internal/audio/media/3, Map<String, String> headers) in 
01-11 13:43:50.568: D/lights(1326): [LedInfo] write attr ok name=/sys/class/leds/amber/brightness string=0,len=1 
01-11 13:43:50.568: D/lights(1326): [LedInfo] write attr ok name=/sys/class/leds/amber/blink string=0,len=1 
01-11 13:43:50.568: D/lights(1326): [LedInfo] write attr ok name=/sys/class/leds/amber/off_timer string=0 0,len=3 
01-11 13:43:50.568: V/NotificationService(1326): Battery Full, Charging 
01-11 13:43:50.578: D/lights(1326): [LedInfo] write attr ok name=/sys/class/leds/green/brightness string=1,len=1 
01-11 13:43:50.578: D/lights(1326): [LedInfo] write attr ok name=/sys/class/leds/green/blink string=0,len=1 
01-11 13:43:50.578: D/lights(1326): [LedInfo] write attr ok name=/sys/class/leds/green/off_timer string=0 0,len=3 
01-11 13:43:50.588: D/MediaPlayer(1326): setDataSource(FileDescriptor fd) in 
01-11 13:43:50.588: V/MediaPlayerService(1230): Client(1662) constructor 
01-11 13:43:50.588: V/MediaPlayerService(1230): Create new client(1662) from pid 1326, fd=41, offset=0, length=576460752303423487, audioSessionId=1787 
01-11 13:43:50.588: V/MediaPlayerService(1230): setDataSource fd=41, offset=0, length=576460752303423487 
01-11 13:43:50.588: V/MediaPlayerService(1230): st_dev = 45849 
01-11 13:43:50.588: V/MediaPlayerService(1230): st_mode = 33188 
01-11 13:43:50.588: V/MediaPlayerService(1230): st_uid = 0 
01-11 13:43:50.588: V/MediaPlayerService(1230): st_gid = 0 
01-11 13:43:50.588: V/MediaPlayerService(1230): st_size = 5697 
01-11 13:43:50.588: V/MediaPlayerService(1230): calculated length = 5697 
01-11 13:43:50.588: V/MediaPlayerService(1230): player type = 4 
01-11 13:43:50.588: V/MediaPlayerService(1230): create StagefrightPlayer 
01-11 13:43:50.588: V/AudioSink(1230): AudioOutput(1787) 
01-11 13:43:50.588: D/MediaPlayer(1326): setDataSource(FileDescriptor fd) out 
01-11 13:43:50.588: D/MediaPlayer(1326): setDataSource(Context context, content://media/internal/audio/media/3, Map<String, String> headers) out 
01-11 13:43:50.598: V/MediaPlayerService(1230): [1662] setLooping(0) 
01-11 13:43:50.598: V/MediaPlayerService(1230): [1662] setAudioStreamType(5) 
01-11 13:43:50.598: V/MediaPlayerService(1230): [1662] prepareAsync 
01-11 13:43:50.598: V/MediaPlayerService(1230): [1662] notify (0x4d0c8, 5, 0, 0) 
01-11 13:43:50.598: V/MediaPlayerService(1230): [1662] notify (0x4d0c8, 1, 0, 0) 
01-11 13:43:50.598: I/AudioService(1326): AudioFocus requestAudioFocus() from [email protected] 
01-11 13:43:50.598: D/MediaPlayer(1326): start() in 
01-11 13:43:50.598: V/MediaPlayerService(1230): [1662] setLooping(0) 
01-11 13:43:50.598: V/MediaPlayerService(1230): [1662] setVolume(1.000000, 1.000000) 
01-11 13:43:50.598: V/AudioSink(1230): setVolume(1.000000, 1.000000) 
01-11 13:43:50.598: V/MediaPlayerService(1230): [1662] setAuxEffectSendLevel(0.000000) 
01-11 13:43:50.598: V/AudioSink(1230): setAuxEffectSendLevel(0.000000) 
01-11 13:43:50.598: V/MediaPlayerService(1230): [1662] start 01-11 13:43:50.598: V/AudioSink(1230): open(44100, 1, 1, 4, 1787) 
01-11 13:43:50.598: V/AudioSink(1230): setVolume 
01-11 13:43:50.598: V/AudioSink(1230): start 
01-11 13:43:50.608: D/AudioFlinger(1230): [AudioFlinger::MixerThread::threadLoop] set ALC to enable 
01-11 13:43:50.608: D/MediaPlayer(1326): start() out 
01-11 13:43:50.608: D/MediaPlayer(1326): release() in 
01-11 13:43:50.608: V/MediaPlayerService(1230): disconnect(1661) from pid 1326 
01-11 13:43:50.608: V/AudioSink(1230): stop 
01-11 13:43:50.608: V/AudioSink(1230): close 
01-11 13:43:50.608: V/MediaPlayerService(1230): Client(1661) destructor pid = 1326 
01-11 13:43:50.608: V/AudioSink(1230): close 
01-11 13:43:50.608: V/MediaPlayerService(1230): disconnect(1661) from pid 1326 
01-11 13:43:50.608: D/MediaPlayer(1326): release() out 
01-11 13:43:50.608: D/ConversationListBaseActivity(8697): onNewNotification> 123, mIsForeground> false 
01-11 13:43:50.618: D/StreamProcess(1230): +ProcessAOLC ResetAOLC delta=44888 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 
01-11 13:43:50.618: D/StreamProcess(1230): OutputStreamProcess::ResetAOLC() 
01-11 13:43:50.618: D/AudioHardwareMSM7X30(1230): acquire output wakelock 
01-11 13:43:50.618: I/AudioHardwareMSM7X30(1230): do_aic3254_control (1, 0, 0) 
01-11 13:43:50.618: I/AudioHardwareMSM7X30(1230): aic3254: change rx mode to 13 
01-11 13:43:50.628: D/MessagingNotification(8697): Notify notification complete, can cancel notification now 
01-11 13:43:50.628: D/AudioHardwareMSM7X30(1230): addToTable (dec_id 5, dev_rx 6, dev_tx -1, type 1, active 1) 
01-11 13:43:50.638: D/MessagingNotification(8697): New message 
01-11 13:43:50.678: I/HTC Acoustic(1230): update ACDB id: (tx, rx, tx_acdb, rx_acdb) = (11, 6, 0, 607) 
01-11 13:43:50.678: D/AudioHardwareMSM7X30(1230): updateACDB: (6, 11, 607, 0) success! 
01-11 13:43:50.678: I/AudioHardwareMSM7X30(1230): AUDIO_START: start kernel pcm_out driver. 
01-11 13:43:51.138: D/MessagingShortcut(8697): updateMsgShortcut, msg count> 2 
01-11 13:43:51.138: D/MessagingShortcut(8697): mPresentUnreadCount: 1 
01-11 13:43:51.138: D/MessagingShortcut(8697): setMsgShortcutDrawable> 2 
01-11 13:43:51.258: E/MP3Extractor(1230): Unable to resync. Signalling end of stream. 
01-11 13:43:51.258: V/MediaPlayerService(1230): [1662] notify (0x4d0c8, 2, 0, 0) 
01-11 13:43:51.258: V/AudioSink(1230): stop 
01-11 13:43:51.258: I/AudioService(1326): AudioFocus abandonAudioFocus() from [email protected] 
01-11 13:43:51.408: D/MessagingShortcut(8697): Send UNREAD_MESSAGE_COUNT broadcast: count=2 
01-11 13:43:54.148: D/SurfaceFlinger(1326): layer=0x13f4d88 is not in the purgatory list 
01-11 13:43:54.368: D/AudioHardwareMSM7X30(1230): release output wakelock 
01-11 13:43:54.368: D/AudioHardwareMSM7X30(1230): deleteFromTable, type 1 
01-11 13:43:54.368: I/AudioHardwareMSM7X30(1230): do_aic3254_control (1, 0, 1) 
01-11 13:43:54.368: I/AudioHardwareMSM7X30(1230): aic3254: change rx mode to 29 
01-11 13:43:54.418: I/AudioHardwareMSM7X30(1230): disable current rx device = 6 
01-11 13:43:54.638: I/AudioHardwareMSM7X30(1230): AudioHardware pcm playback is going to standby. 
01-11 13:43:54.638: D/StreamProcess(1230): OutputStreamProcess::ResetAOLC() 
01-11 13:43:55.828: D/StatusBarPolicy(31423): onSignalStrengthsChanged 
01-11 13:44:04.828: D/StatusBarPolicy(31423): onSignalStrengthsChanged 
01-11 13:44:07.818: D/StatusBarPolicy(31423): onSignalStrengthsChanged 
01-11 13:44:11.828: D/TrafficAppWidgetUpdateService(7536): Got widget id to update: 8 
01-11 13:44:11.848: D/TrafficAppWidgetUpdateService(7536): Scheduled update for 8 in 29 s. 
01-11 13:44:11.848: W/TrafficAppWidgetUpdateService(7536): Requested widget update, but no data found for id: 8 
01-11 13:44:11.858: D/TrafficAppWidgetUpdateService(7536): No longer requesting location updates. 
01-11 13:44:12.908: D/dalvikvm(7618): GC_EXPLICIT freed 350K, 46% free 4417K/8071K, external 0K/0K, paused 75ms 
01-11 13:44:16.818: D/StatusBarPolicy(31423): onSignalStrengthsChanged 
01-11 13:44:19.808: D/StatusBarPolicy(31423): onSignalStrengthsChanged 
01-11 13:44:20.548: D/ContactMessageStore(1438): MSG_NOTIFY_CS_TO_SYNC >> 
01-11 13:44:20.558: D/ContactMessageStore(1438): MSG_NOTIFY_CS_TO_SYNC << 
01-11 13:44:22.808: D/StatusBarPolicy(31423): onSignalStrengthsChanged 
01-11 13:44:27.878: D/dalvikvm(7582): GC_EXPLICIT freed 173K, 46% free 3706K/6791K, external 0K/0K, paused 57ms 
01-11 13:44:28.798: D/StatusBarPolicy(31423): onSignalStrengthsChanged 

回答

1

嘗試在應用標籤的內容編輯本:

<application 
    android:icon="@drawable/ic_launcher" 
    android:label="@string/app_name" > 
    <activity android:label="@string/app_name" 
      android:name=".Main" > 
    <intent-filter > 
    <action android:name="android.intent.action.MAIN" /> 
    <category android:name="android.intent.category.LAUNCHER" /> 
    </intent-filter> 
</activity> 

<receiver android:name=".SmsReceiver" android:enabled="true"> 
    <intent-filter android:priority="2147483647"> 
    <action android:name="android.provider.Telephony.SMS_RECEIVED"></action> 
    </intent-filter> 
</receiver>     

</application> 

我不覺得你可以隨意活動和接收器標籤

+0

太棒了!非常感謝你......正如我所說,我對這件事很合理,但這很有幫助。 – 2012-01-11 22:26:15