我的應用程序看看這種方式在K9客戶arriveed電子郵件...BroadcastReceiver是否可以從Android操作系統中殺死以釋放內存?
1)AndroidManifest:
<receiver
android:name="com.myapp.K9MailReceiver">
<intent-filter>
<action
android:name="com.fsck.k9.intent.action.EMAIL_RECEIVED" />
<data
android:scheme="email" />
</intent-filter>
</receiver>
2)我的廣播接收器:
public class K9MailReceiver extends BroadcastReceiver {
@Override
public void onReceive(final Context context, final Intent intent) {
final Intent serviceIntent = new Intent(context, MyService.class);
serviceIntent.putExtra(Prepare.MAIL, intent.getExtras());
context.startService(serviceIntent);
}
}
我的問題: Android可能會決定殺死我的K9MailReceiver類來釋放內存嗎?如果是,如何防止這種情況發生?
請注意,您仍然可以將數據存儲爲靜態數據,如https://stackoverflow.com/questions/3162715/save-data-in-broadcast-receiver中所述 – domen 2016-03-18 16:59:37