收到短信时显示机器人吐司

时间:2015-04-12 19:58:31

标签: android

我想在收到Toast时显示一个简单的sms。我在过去4天尝试这个仍然没有成功。请帮忙。  有时我的应用程序执行核心。有时它没有。

1)当我创建一个空白Activity的新项目并向其添加Button时。以便点击Button显示Toast。 ------>执行此操作是成功的。它工作正常。 现在

2)我删除layout\*.xml文件并修改我的MainActivity.javaManifest.xml(如下所示),它会在收到Toast时向我显示sms。 但 如果我重新编译它并重新运行它,相同的代码和相同的Manifest(注意改变)它不起作用。

简而言之,在第一次执行时,它永远不会被执行。

MAINACTIVITY.JAVA

package com.example.vaibhav.savemev2;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.widget.Toast;
public class MainActivity extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
    Toast.makeText(context,"SMS RECEIVED BRO !",Toast.LENGTH_LONG).show();
}
}

的Manifest.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.vaibhav.savemev2">
<uses-permission android:name="android.permission.RECEIVE_SMS"/>
<uses-permission android:name="android.permission.READ_SMS"/>
<application android:allowBackup="true" android:label="@string/app_name"
    android:icon="@mipmap/ic_launcher" android:theme="@style/AppTheme">
    <receiver android:name=".MainActivity">
        <intent-filter>
            <action android:name="android.provider.Telephony.SMS_RECEIVED"/>
        </intent-filter>
    </receiver>
   </application>
 </manifest>

LOGCAT(编辑第2,第3,第4 ......编辑的时间点。第3点)

04-13 00:18:25.542    1773-1773/com.google.process.gapps I/ConfigService﹕ onBind for Intent { act=com.google.android.gms.config.START pkg=com.google.android.gms } action com.google.android.gms.config.START
04-13 00:18:25.542    1773-1773/com.google.process.gapps I/ConfigService﹕ onBind returning service broker
04-13 00:18:25.578    1233-1245/system_process I/art﹕ Background sticky concurrent mark sweep GC freed 29195(1867KB) AllocSpace objects, 9(144KB) LOS objects, 13% free, 10MB/11MB, paused 1.297ms total 2.026s
04-13 00:18:25.581    1233-1283/system_process I/art﹕ WaitForGcToComplete blocked for 810.831ms for cause Explicit
04-13 00:18:26.462    1233-1283/system_process I/art﹕ Explicit concurrent mark sweep GC freed 5679(338KB) AllocSpace objects, 2(32KB) LOS objects, 16% free, 9MB/11MB, paused 9.483ms total 859.150ms
04-13 00:18:26.624    1973-1973/com.google.android.gms I/ConfigFetchService﹕ service connected
04-13 00:18:26.654    3531-3531/? D/AndroidRuntime﹕ Shutting down VM
04-13 00:18:26.655    3531-3533/? I/art﹕ Debugger is no longer active
04-13 00:18:26.774    1233-1233/system_process D/BackupManagerService﹕ Received broadcast Intent { act=android.intent.action.PACKAGE_ADDED dat=package:com.example.vaibhav.savemev2 flg=0x4000010 (has extras) }
04-13 00:18:26.774    1233-1233/system_process W/BackupManagerService﹕ Removing schedule queue dupe of com.example.vaibhav.savemev2
04-13 00:18:26.809    1233-1269/system_process I/ActivityManager﹕ Resuming delayed broadcast
04-13 00:18:27.240    2038-2038/com.android.keychain W/ContextImpl﹕ Calling a method in the system process without a qualified user: android.app.ContextImpl.startService:1686 android.content.ContextWrapper.startService:515 android.content.ContextWrapper.startService:515 com.android.keychain.KeyChainBroadcastReceiver.onReceive:12 android.app.ActivityThread.handleReceiver:2579
04-13 00:18:27.245    1233-1472/system_process I/ActivityManager﹕ Delay finish: com.android.keychain/.KeyChainBroadcastReceiver
04-13 00:18:27.284    1233-1842/system_process I/ActivityManager﹕ Resuming delayed broadcast
04-13 00:18:27.311    1973-3551/com.google.android.gms D/PackageBroadcastService﹕ Received broadcast action=android.intent.action.PACKAGE_ADDED and uri=com.example.vaibhav.savemev2
04-13 00:18:27.321    1233-1644/system_process I/ActivityManager﹕ Delay finish: com.google.android.gms/.app.receiver.SystemBroadcastReceiver
04-13 00:18:27.408    1973-1973/com.google.android.gms I/ConfigFetchService﹕ onStartCommand Intent { act=android.intent.action.PACKAGE_ADDED dat=package:com.example.vaibhav.savemev2 cmp=com.google.android.gms/.config.ConfigFetchService (has extras) }
04-13 00:18:27.409    1973-1973/com.google.android.gms I/ConfigFetchService﹕ launchTask
04-13 00:18:27.907    1973-3555/com.google.android.gms I/PeopleContactsSync﹕ CP2 sync disabled
04-13 00:18:27.908    1973-1973/com.google.android.gms I/ConfigFetchService﹕ service connected
04-13 00:18:27.967    1973-1973/com.google.android.gms D/ConfigFetchService﹕ ConfigApi connection successful.
04-13 00:18:28.035    1233-1272/system_process W/VoiceInteractionManagerService﹕ no available voice recognition services found for user 0
04-13 00:18:37.462    1973-3553/com.google.android.gms V/ConfigFetchTask﹕ ConfigFetchTask getDeviceDataVersionInfo(): ABFEt1V7na1GUYHmCFdhBRFSiefbF1ngJlylTaCxtj477EUPZ4tUkHtmCOqm3yL-4bmaZmZaWw7ipVyPnbnfUe04Mimqdod_MohZrTXZh15F1RAla6JoKLuzCufzRnkj505ZtfvnCb2Ayjzk2-YWKzcTP-vbOfgL2fW9mYnYwsv_wq_5Yqr92WCP2UViB4Ie7NhpJu8UBYCWd5R2DeVxdnZgJcHjB_p_9fLN2acfhJWXS0KMoDV1yxyzoPGC-ksM1zqMMpKC4JknD1ePU0EDyK_pjXVL1hxASE6GXtnLyVgS1eF2ik92lfZ8lDG-TYtFbkT__vJ1ANdkXdkCiNUxenPaOWezZf31LCE5H0kJ8pI8VSuC7pKxjVw
04-13 00:18:37.498    1973-3553/com.google.android.gms I/GoogleURLConnFactory﹕ Using platform SSLCertificateSocketFactory
04-13 00:18:37.807    1973-1973/com.google.android.gms I/ConfigFetchService﹕ fetch service done; releasing wakelock
04-13 00:18:37.808    1973-1973/com.google.android.gms I/ConfigFetchService﹕ stopping self
04-13 00:18:37.810    1233-1842/system_process I/ActivityManager﹕ Resuming delayed broadcast
04-13 00:18:37.856    1773-1773/com.google.process.gapps E/NetworkScheduler.SchedulerReceiver﹕ Invalid parameter app
04-13 00:18:37.856    1773-1773/com.google.process.gapps E/NetworkScheduler.SchedulerReceiver﹕ Invalid package name : Perhaps you didn't include a PendingIntent in the extras?
04-13 00:18:37.872    1233-1269/system_process I/ActivityManager﹕ Delay finish: com.google.android.gms/.gcm.nts.SchedulerReceiver
04-13 00:18:37.881    1233-1779/system_process I/ActivityManager﹕ Resuming delayed broadcast
04-13 00:18:37.886    1233-1339/system_process I/ActivityManager﹕ Delay finish: com.google.android.gms/.app.receiver.SystemBroadcastReceiver
04-13 00:18:37.888    1973-3558/com.google.android.gms D/PackageBroadcastService﹕ Received broadcast action=android.intent.action.PACKAGE_REPLACED and uri=com.example.vaibhav.savemev2
04-13 00:18:37.891    1973-3559/com.google.android.gms I/PeopleContactsSync﹕ CP2 sync disabled
04-13 00:18:37.925    1233-1580/system_process I/ActivityManager﹕ Resuming delayed broadcast
04-13 00:18:38.028    1233-1269/system_process I/ActivityManager﹕ Delay finish: com.android.mms/.transaction.PrivilegedSmsReceiver
04-13 00:18:38.031    2161-2161/com.android.mms V/Mms﹕ onStart: #1 mResultCode: -1 = Activity.RESULT_OK
04-13 00:18:38.489    2161-3560/com.android.mms D/Mms﹕ handleSmsReceived messageUri: content://sms/24 threadId: 1
04-13 00:18:38.522    2161-3560/com.android.mms D/Mms﹕ updateNotification: new message, adding sound to the notification
04-13 00:18:38.574    1233-1233/system_process I/ValidateNoPeople﹕ Validating: 0|com.android.mms|123|null|10010
04-13 00:18:38.575    1233-1233/system_process I/ValidateNoPeople﹕ final affinity: 0.0
04-13 00:18:38.592    1233-1268/system_process I/ActivityManager﹕ Resuming delayed broadcast
04-13 00:18:38.875    1415-3562/com.android.systemui E/MediaPlayer﹕ Should have subtitle controller already set
04-13 00:18:38.939    1233-1269/system_process I/MediaFocusControl﹕ AudioFocus  requestAudioFocus() from android.media.AudioManager@bfa2e69
04-13 00:18:38.941      944-944/? D/NuPlayerDriver﹕ start(0xb4883280)
04-13 00:18:38.942     944-1578/? D/NuPlayerDriver﹕ reset(0xb5a4b100)
04-13 00:18:38.948     944-3514/? D/NuPlayerDriver﹕ notifyResetComplete(0xb5a4b100)
04-13 00:18:38.948    1415-3562/com.android.systemui E/MediaPlayer﹕ Should have subtitle controller already set
04-13 00:18:38.949     944-3563/? I/GenericSource﹕ start
04-13 00:18:38.970     944-3565/? D/AudioSink﹕ bufferCount (8) is too small and increased to 12
04-13 00:18:40.975    1233-1472/system_process I/MediaFocusControl﹕ AudioFocus  abandonAudioFocus() from android.media.AudioManager@bfa2e69
04-13 00:18:41.422     944-1224/? I/AudioFlinger﹕ BUFFER TIMEOUT: remove(4097) from active list on thread 0xb61b7000
04-13 00:18:42.866    1773-1773/com.google.process.gapps I/ConfigService﹕ onDestroy
04-13 00:19:00.254    1415-1428/com.android.systemui I/art﹕ Background sticky concurrent mark sweep GC freed 27578(1080KB) AllocSpace objects, 0(0B) LOS objects, 15% free, 6MB/7MB, paused 1.210ms total 193.993ms
04-13 00:19:22.023    3575-3575/? D/AndroidRuntime﹕ >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
04-13 00:19:22.075    3575-3575/? D/AndroidRuntime﹕ CheckJNI is ON
04-13 00:19:23.256    3575-3575/? E/memtrack﹕ Couldn't load memtrack module (No such file or directory)
04-13 00:19:23.257    3575-3575/? E/android.os.Debug﹕ failed to load memtrack module: -2
04-13 00:19:24.405    3575-3575/? D/AndroidRuntime﹕ Calling main entry com.android.commands.pm.Pm
04-13 00:19:24.676    1781-3586/com.android.defcontainer D/DefContainer﹕ Copying /data/local/tmp/com.example.vaibhav.savemev2 to base.apk
04-13 00:19:24.767    1233-1283/system_process D/PackageManager﹕ Renaming /data/app/vmdl202891466.tmp to /data/app/com.example.vaibhav.savemev2-1
04-13 00:19:24.767    1233-1273/system_process I/ActivityManager﹕ Force stopping com.example.vaibhav.savemev2 appid=10059 user=-1: uninstall pkg
04-13 00:19:24.871    1233-1283/system_process I/PackageManager﹕ Package com.example.vaibhav.savemev2 codePath changed from /data/app/com.example.vaibhav.savemev2-2 to /data/app/com.example.vaibhav.savemev2-1; Retaining data and using new
04-13 00:19:24.871    1233-1283/system_process I/art﹕ DexFile_isDexOptNeeded failed to open oat file '/data/dalvik-cache/x86/data@app@com.example.vaibhav.savemev2-1@base.apk@classes.dex' for file location '/data/app/com.example.vaibhav.savemev2-1/base.apk': Failed to open oat filename for reading: No such file or directory
04-13 00:19:24.874    1233-1283/system_process I/art﹕ DexFile_isDexOptNeeded failed to open oat file '/data/app/com.example.vaibhav.savemev2-1/x86/base.odex' for file location '/data/app/com.example.vaibhav.savemev2-1/base.apk': Failed to open oat filename for reading: No such file or directory
04-13 00:19:24.874    1233-1283/system_process I/PackageManager﹕ Running dexopt on: /data/app/com.example.vaibhav.savemev2-1/base.apk pkg=com.example.vaibhav.savemev2 isa=x86 vmSafeMode=false
04-13 00:19:25.221    3588-3588/? I/dex2oat﹕ /system/bin/dex2oat --zip-fd=6 --zip-location=/data/app/com.example.vaibhav.savemev2-1/base.apk --oat-fd=7 --oat-location=/data/dalvik-cache/x86/data@app@com.example.vaibhav.savemev2-1@base.apk@classes.dex --instruction-set=x86 --instruction-set-features=default --runtime-arg -Xms64m --runtime-arg -Xmx512m
04-13 00:19:25.844    3588-3588/? W/dex2oat﹕ Compilation of void com.example.vaibhav.savemev2.BuildConfig.<init>() took 166.920ms
04-13 00:19:25.874    3588-3588/? I/dex2oat﹕ dex2oat took 602.641ms (threads: 1)
04-13 00:19:25.875    1233-1273/system_process I/ActivityManager﹕ Force stopping com.example.vaibhav.savemev2 appid=10059 user=-1: update pkg
04-13 00:19:25.876    1233-1283/system_process W/PackageManager﹕ Code path for pkg : com.example.vaibhav.savemev2 changing from /data/app/com.example.vaibhav.savemev2-2 to /data/app/com.example.vaibhav.savemev2-1
04-13 00:19:25.876    1233-1283/system_process W/PackageManager﹕ Resource path for pkg : com.example.vaibhav.savemev2 changing from /data/app/com.example.vaibhav.savemev2-2 to /data/app/com.example.vaibhav.savemev2-1
04-13 00:19:25.929    1233-1283/system_process I/ActivityManager﹕ Force stopping com.example.vaibhav.savemev2 appid=10059 user=0: pkg removed
04-13 00:19:25.942    1233-1233/system_process D/BackupManagerService﹕ Received broadcast Intent { act=android.intent.action.PACKAGE_REMOVED dat=package:com.example.vaibhav.savemev2 flg=0x4000010 (has extras) }
04-13 00:19:25.942    1233-1233/system_process D/JobSchedulerService﹕ Receieved: android.intent.action.PACKAGE_REMOVED
04-13 00:19:25.982    1233-1283/system_process W/Settings﹕ Setting install_non_market_apps has moved from android.provider.Settings.Global to android.provider.Settings.Secure, returning read-only value.
04-13 00:19:25.992    1773-1773/com.google.process.gapps E/NetworkScheduler.SchedulerReceiver﹕ Invalid parameter app
04-13 00:19:25.992    1773-1773/com.google.process.gapps E/NetworkScheduler.SchedulerReceiver﹕ Invalid package name : Perhaps you didn't include a PendingIntent in the extras?
04-13 00:19:26.000    1233-1269/system_process I/ActivityManager﹕ Delay finish: com.google.android.gms/.app.receiver.SystemBroadcastReceiver
04-13 00:19:26.005    1973-3590/com.google.android.gms D/PackageBroadcastService﹕ Received broadcast action=android.intent.action.PACKAGE_REMOVED and uri=com.example.vaibhav.savemev2
04-13 00:19:26.011    1773-1773/com.google.process.gapps I/ConfigService﹕ onCreate
04-13 00:19:26.023    1773-1773/com.google.process.gapps I/ConfigService﹕ onBind for Intent { act=com.google.android.gms.config.UPDATE pkg=com.google.android.gms } action com.google.android.gms.config.UPDATE
04-13 00:19:26.027    1973-1973/com.google.android.gms I/ConfigFetchService﹕ onStartCommand Intent { act=android.intent.action.PACKAGE_REMOVED dat=package:com.example.vaibhav.savemev2 cmp=com.google.android.gms/.config.ConfigFetchService (has extras) }
04-13 00:19:26.052    1233-1320/system_process I/InputReader﹕ Reconfiguring input devices.  changes=0x00000010
04-13 00:19:26.056    1233-1320/system_process I/InputReader﹕ Reconfiguring input devices.  changes=0x00000010
04-13 00:19:26.061    1233-1233/system_process D/BackupManagerService﹕ Received broadcast Intent { act=android.intent.action.PACKAGE_ADDED dat=package:com.example.vaibhav.savemev2 flg=0x4000010 (has extras) }
04-13 00:19:26.061    1233-1233/system_process W/BackupManagerService﹕ Removing schedule queue dupe of com.example.vaibhav.savemev2
04-13 00:19:26.064    1233-1320/system_process I/InputReader﹕ Reconfiguring input devices.  changes=0x00000010
04-13 00:19:26.699    1511-1532/com.android.phone I/art﹕ Background sticky concurrent mark sweep GC freed 8436(428KB) AllocSpace objects, 0(0B) LOS objects, 22% free, 1850KB/2MB, paused 1.184ms total 710.008ms
04-13 00:19:26.741    1773-1773/com.google.process.gapps I/ConfigService﹕ onBind returning update interface
04-13 00:19:26.743    1773-1773/com.google.process.gapps I/ConfigService﹕ onBind for Intent { act=com.google.android.gms.config.START pkg=com.google.android.gms } action com.google.android.gms.config.START
04-13 00:19:26.744    1773-1773/com.google.process.gapps I/ConfigService﹕ onBind returning service broker
04-13 00:19:26.801    1233-1272/system_process W/VoiceInteractionManagerService﹕ no available voice recognition services found for user 0
04-13 00:19:26.811    1233-1582/system_process I/ActivityManager﹕ Resuming delayed broadcast
04-13 00:19:26.834    2038-2038/com.android.keychain W/ContextImpl﹕ Calling a method in the system process without a qualified user: android.app.ContextImpl.startService:1686 android.content.ContextWrapper.startService:515 android.content.ContextWrapper.startService:515 com.android.keychain.KeyChainBroadcastReceiver.onReceive:12 android.app.ActivityThread.handleReceiver:2579
04-13 00:19:26.851    1233-1580/system_process I/ActivityManager﹕ Delay finish: com.android.keychain/.KeyChainBroadcastReceiver
04-13 00:19:26.954    1233-1269/system_process I/ActivityManager﹕ Resuming delayed broadcast
04-13 00:19:27.139    1233-1283/system_process I/art﹕ Explicit concurrent mark sweep GC freed 24509(1676KB) AllocSpace objects, 10(160KB) LOS objects, 16% free, 9MB/11MB, paused 17.625ms total 1.041s
04-13 00:19:27.335    3575-3575/? D/AndroidRuntime﹕ Shutting down VM
04-13 00:19:27.509    3575-3577/? I/art﹕ Debugger is no longer active
04-13 00:19:27.880    1233-1269/system_process I/ActivityManager﹕ Delay finish: com.google.android.gms/.app.receiver.SystemBroadcastReceiver
04-13 00:19:27.885    1973-3595/com.google.android.gms D/PackageBroadcastService﹕ Received broadcast action=android.intent.action.PACKAGE_ADDED and uri=com.example.vaibhav.savemev2
04-13 00:19:27.898    1973-1973/com.google.android.gms I/ConfigFetchService﹕ onStartCommand Intent { act=android.intent.action.PACKAGE_ADDED dat=package:com.example.vaibhav.savemev2 cmp=com.google.android.gms/.config.ConfigFetchService (has extras) }
04-13 00:19:27.918    1973-1973/com.google.android.gms I/ConfigFetchService﹕ launchTask
04-13 00:19:28.234    1973-1973/com.google.android.gms I/ConfigFetchService﹕ service connected
04-13 00:19:28.238    1973-3599/com.google.android.gms I/PeopleContactsSync﹕ CP2 sync disabled
04-13 00:19:28.263    1973-1973/com.google.android.gms D/ConfigFetchService﹕ ConfigApi connection successful.
04-13 00:19:29.514    1773-1799/com.google.process.gapps E/StrictMode﹕ A resource was acquired at attached stack trace but never released. See java.io.Closeable for information on avoiding resource leaks.
    java.lang.Throwable: Explicit termination method 'end' not called
            at dalvik.system.CloseGuard.open(CloseGuard.java:184)
            at java.util.zip.Inflater.<init>(Inflater.java:82)
            at com.android.okio.GzipSource.<init>(GzipSource.java:57)
            at com.android.okhttp.internal.http.HttpEngine.initContentStream(HttpEngine.java:478)
            at com.android.okhttp.internal.http.HttpEngine.readResponse(HttpEngine.java:668)
            at com.android.okhttp.internal.http.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:379)
            at com.android.okhttp.internal.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:323)
            at com.android.okhttp.internal.http.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:491)
            at com.android.okhttp.internal.http.DelegatingHttpsURLConnection.getResponseCode(DelegatingHttpsURLConnection.java:105)
            at com.android.okhttp.internal.http.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:25)
            at com.google.android.gms.http.GoogleHttpClient.a(SourceFile:791)
            at com.google.android.gms.http.GoogleHttpClient.b(SourceFile:760)
            at com.google.android.gms.http.GoogleHttpClient.execute(SourceFile:663)
            at com.google.android.gms.http.GoogleHttpClient.execute(SourceFile:654)
            at com.google.android.gms.playlog.uploader.e.a(SourceFile:346)
            at com.google.android.gms.playlog.uploader.e.a(SourceFile:232)
            at com.google.android.gms.playlog.uploader.e.a(SourceFile:204)
            at com.google.android.gms.playlog.uploader.UploaderService.a(SourceFile:52)
            at com.google.android.gms.gcm.ap.run(SourceFile:131)
04-13 00:19:37.973    1973-3597/com.google.android.gms V/ConfigFetchTask﹕ ConfigFetchTask getDeviceDataVersionInfo(): ABFEt1V7na1GUYHmCFdhBRFSiefbF1ngJlylTaCxtj477EUPZ4tUkHtmCOqm3yL-4bmaZmZaWw7ipVyPnbnfUe04Mimqdod_MohZrTXZh15F1RAla6JoKLuzCufzRnkj505ZtfvnCb2Ayjzk2-YWKzcTP-vbOfgL2fW9mYnYwsv_wq_5Yqr92WCP2UViB4Ie7NhpJu8UBYCWd5R2DeVxdnZgJcHjB_p_9fLN2acfhJWXS0KMoDV1yxyzoPGC-ksM1zqMMpKC4JknD1ePU0EDyK_pjXVL1hxASE6GXtnLyVgS1eF2ik92lfZ8lDG-TYtFbkT__vJ1ANdkXdkCiNUxenPaOWezZf31LCE5H0kJ8pI8VSuC7pKxjVw
04-13 00:19:37.977    1973-3597/com.google.android.gms I/GoogleURLConnFactory﹕ Using platform SSLCertificateSocketFactory
04-13 00:19:38.251    1973-1973/com.google.android.gms I/ConfigFetchService﹕ fetch service done; releasing wakelock
04-13 00:19:38.262    1973-1973/com.google.android.gms I/ConfigFetchService﹕ stopping self
04-13 00:19:38.265    1233-1842/system_process I/ActivityManager﹕ Resuming delayed broadcast
04-13 00:19:38.303    1773-1773/com.google.process.gapps E/NetworkScheduler.SchedulerReceiver﹕ Invalid parameter app
04-13 00:19:38.303    1773-1773/com.google.process.gapps E/NetworkScheduler.SchedulerReceiver﹕ Invalid package name : Perhaps you didn't include a PendingIntent in the extras?
04-13 00:19:38.322    1233-1779/system_process I/ActivityManager﹕ Delay finish: com.google.android.gms/.gcm.nts.SchedulerReceiver
04-13 00:19:38.329    1233-1644/system_process I/ActivityManager﹕ Resuming delayed broadcast
04-13 00:19:38.335    1973-3606/com.google.android.gms D/PackageBroadcastService﹕ Received broadcast action=android.intent.action.PACKAGE_REPLACED and uri=com.example.vaibhav.savemev2
04-13 00:19:38.335    1233-1580/system_process I/ActivityManager﹕ Delay finish: com.google.android.gms/.app.receiver.SystemBroadcastReceiver
04-13 00:19:38.340    1973-3607/com.google.android.gms I/PeopleContactsSync﹕ CP2 sync disabled
04-13 00:19:38.350    1233-1629/system_process I/ActivityManager﹕ Resuming delayed broadcast
04-13 00:19:43.329    1773-1773/com.google.process.gapps I/ConfigService﹕ onDestroy
04-13 00:20:12.317    1233-1580/system_process I/ActivityManager﹕ Delay finish: com.android.mms/.transaction.PrivilegedSmsReceiver
04-13 00:20:12.322    2161-2161/com.android.mms V/Mms﹕ onStart: #1 mResultCode: -1 = Activity.RESULT_OK
04-13 00:20:12.416    2161-3608/com.android.mms D/Mms﹕ handleSmsReceived messageUri: content://sms/25 threadId: 1
04-13 00:20:12.428    2161-3608/com.android.mms D/Mms﹕ updateNotification: new message, adding sound to the notification
04-13 00:20:12.434    1233-1233/system_process I/ValidateNoPeople﹕ Validating: 0|com.android.mms|123|null|10010
04-13 00:20:12.434    1233-1233/system_process I/ValidateNoPeople﹕ final affinity: 0.0
04-13 00:20:12.458    1415-3610/com.android.systemui E/MediaPlayer﹕ Should have subtitle controller already set
04-13 00:20:12.461    1233-1339/system_process I/MediaFocusControl﹕ AudioFocus  requestAudioFocus() from android.media.AudioManager@21dff0ee
04-13 00:20:12.462     944-1578/? D/NuPlayerDriver﹕ start(0xb5a4b1c0)
04-13 00:20:12.464     944-1226/? D/NuPlayerDriver﹕ reset(0xb4883280)
04-13 00:20:12.470     944-3563/? D/NuPlayerDriver﹕ notifyResetComplete(0xb4883280)
04-13 00:20:12.471    1415-3610/com.android.systemui E/MediaPlayer﹕ Should have subtitle controller already set
04-13 00:20:12.472     944-3611/? I/GenericSource﹕ start
04-13 00:20:12.491     944-3613/? D/AudioSink﹕ bufferCount (8) is too small and increased to 12
04-13 00:20:12.565    1233-1269/system_process I/ActivityManager﹕ Resuming delayed broadcast
04-13 00:20:14.485    1233-1580/system_process I/MediaFocusControl﹕ AudioFocus  abandonAudioFocus() from android.media.AudioManager@21dff0ee
04-13 00:20:14.933     944-1224/? I/AudioFlinger﹕ BUFFER TIMEOUT: remove(4097) from active list on thread 0xb61b7000

LOGCAT(工作,这是第一次编译。第2点)

https://www.dropbox.com/s/c7nlfh6qy4vg99m/workingLOGCAT.png?dl=0

1 个答案:

答案 0 :(得分:0)

它是头晕目眩的logcat ......

我认为复制广播接收器。

如果您想在首次运行后每次运行,请在后台服务中注册broadcastreceiver,如果需要,请注册unregisterReceiver。

或者您希望在show activity中运行,注册broadcastreceiver和shutdown活动unregisterReceiver。

我的英语不好..... 我希望能帮到你。

IntentFilter intentFilter = new IntentFilter();
    intentFilter.addAction("android.provider.Telephony.SMS_RECEIVED");
    registerReceiver(smsreceiver, intentFilter);

if(smsreceiver != null){
        unregisterReceiver(smsreceiver);
        smsreceiver = null;
    }
谢谢。