android Contacts/Acore進程常常被Kill,導致連絡人開機後丟失怎麼辦?

來源:互聯網
上載者:User

標籤:register   sql   部分   activity   icon   優先順序   androi   constant   stop   

Contacts/Acore進程,在記憶體較少和開機進程過多的情況下會常常被 ActivityManager Kill 掉。
導致Sim卡連絡人開機後未匯入或者僅僅匯入一部分,造成連絡人丟失的現象,可是又一次開機後能夠恢複正常。


遇到這種問題能夠採用下面方法提供Contacts/Acore進程的優先順序,減少被ActivityManager 殺掉的機率。
 
方法1:
提高進程優先順序
        startForeground(1, new Notification());
減少進程優先順序
        stopForeground(true); 
NOTICE:
    這種方法能夠將相應AP的ADJ暫時提高到2。
 
方法2:
找到這個進程相應的AndroidMannifest.xml檔案,在當中加入屬性『android:persistent="true"』,
這樣能夠將該進程設定為常駐記憶體進程,就能夠減少被Kill的機率。
以Acore進程為例。
在 /package/providers/ContactsProvider/AndroidMannifest.xml 檔案裡添加一行『android:persistent="true"』
詳細改動示比例如以下:
   <application android:process="android.process.acore"
             android:label="@string/app_label"
             android:icon="@drawable/app_icon"
             android:allowBackup="false"
             android:persistent="true" <!--新添加代碼。保證acore進程不被ActivityManager殺死-->
     >
NOTICE:
    這種方法能夠將相應AP的ADJ暫時提高到2。
 
    解決發生JE問題(必須合入):
    CallLogProvider.java  (Line1000)
    public static final void notifyNewCallsCount(SQLiteDatabase db, Context context) {
        ... ...
        Log.i(TAG, "[notifyNewCallsCount] newCallsCount = " + newCallsCount);
        //send count=0 to clear the unread icon
        if (newCallsCount >= 0) {
            Intent newIntent = new Intent(Intent.MTK_ACTION_UNREAD_CHANGED);
            newIntent.putExtra(Intent.MTK_EXTRA_UNREAD_NUMBER, newCallsCount);
            newIntent.putExtra(Intent.MTK_EXTRA_UNREAD_COMPONENT, new ComponentName(Constants.CONTACTS_PACKAGE,
                    Constants.CONTACTS_DIALTACTS_ACTIVITY));
// New add for fixed JE
            newIntent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
// End
            context.sendBroadcast(newIntent);
        ... ...

android Contacts/Acore進程常常被Kill,導致連絡人開機後丟失怎麼辦?

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.