开发者

c2dm receiver doesn't work when app has been killed

In manifest in application tag I have:

<receiver
    android:name=".MyC2dmReceiver"
    android:permission="com.google.android.c2dm.permission.SEND">
    <!-- Receive the actual message -->
    <intent-filter>
        <action
            android:name="com.google.android.c2dm.intent.RECEIVE" />
        <category
            android:name="com.my.app" />
    </intent-filter>
    <!-- Receive the registration id -->
    <intent-filter>
        <action
            android:name="com.google.android.c2dm.intent.REGISTRATION" />
        <category
            android:name="com.my.app" />
    </intent-filter>
</receiver>

And my receiving has sth like that

@Override
public void onReceive(Context context, Intent intent) {
    if (intent.getAction().equals("com.开发者_Python百科google.android.c2dm.intent.REGISTRATION")) {
        handleRegistration(context, intent);
    } else if (intent.getAction().equals("com.google.android.c2dm.intent.RECEIVE")) {
        handleMessage(context, intent);
    }
}

When my app is on or in background onReceive method is fired, but when I kill app using AdvancedTaskKiller onRecived stops receiving. Why?

Why Android doesn't start my receiver? Do I need sth in manifest?


Why?

If you are on Android 3.1 or newer, it is because your application has been moved into the stopped state. This also occurs if the user force-stops you via the Settings application. Until the user manually launches your app again (e.g., taps on an icon in the launcher), none of your BroadcastReceivers will work.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜