문제

i set a service that checks if a specific process is running in time intervals by using:

appsList = am.getRunningAppProcesses();

i saved its name and id with:

s = pross.processName;
i=pross.pid;

i launch the default launcher with:

Intent intent = null;
        final PackageManager pManager = context.getPackageManager();
        for (final ResolveInfo resolveInfo:pManager.queryIntentActivities(new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_HOME),pManager.MATCH_DEFAULT_ONLY ))
        {
            if(!context.getPackageName().equals(resolveInfo.activityInfo.packageName))
            {
                intent = new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_HOME).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                intent.setClassName(resolveInfo.activityInfo.packageName, resolveInfo.activityInfo.name);
                break;
            }
        }
        context.startActivity(intent);

than kill the process with :

mActivityManager.killBackgroundProcesses(s);

it all works fine but the problem is that its doing the whole calling the launcher and closing the process twice. it's like the process is still running the second time the service checks if its running.

any idea how to solve this?

올바른 솔루션이 없습니다

다른 팁

I think we can not kill any other process. System not allow to do that without root access.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top