Clear RAM On按钮单击 - android

时间:2014-07-16 05:37:25

标签: android onclick ram

你好我是stackoverflow的新手,我需要一些关于手机性能的帮助,我必须每次都清理RAM以通过任务管理器释放一些空间。任何人都可以帮我清除RAM,只需点击一下按钮? plss帮助任何人!!

顺便说一下这里是关闭所有后台应用程序的代码(我认为它也应该免费使用ram),但它不能正常工作

package com.example.rampluginforgalaxynote3;

import java.util.List;

import android.app.Activity;
import android.app.ActivityManager;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.view.View;

public class MainActivity extends Activity {

    private Activity context;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }
    public void apps(View view) { 
        List<ApplicationInfo> packages;
        PackageManager pm;
        pm = getPackageManager();
        //get a list of installed apps.
        packages = pm.getInstalledApplications(0);

        ActivityManager mActivityManager = (ActivityManager)context.getSystemService(Context.ACTIVITY_SERVICE);

       for (ApplicationInfo packageInfo : packages) {
            if((packageInfo.flags & ApplicationInfo.FLAG_SYSTEM)==1)continue;
            if(packageInfo.packageName.equals("com.example.rampluginforgalaxynote3")) continue;
            mActivityManager.killBackgroundProcesses(packageInfo.packageName);
       }      

    }

}

0 个答案:

没有答案