Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import android.app.ActivityManager;
import android.app.ActivityManager.RunningAppProcessInfo;
import android.content.Context;

import android.os.Process;

public class Main {
    private static final String VoiceClientSerivceProcessName = "com.tuenti.voice.example:VoiceClientService";

    public static boolean isRemoteService(Context context) {
        ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
        for (RunningAppProcessInfo process : manager.getRunningAppProcesses()) {
            if (VoiceClientSerivceProcessName.equals(process.processName)) {
                return Process.myPid() == process.pid;
            }
        }
        return false;
    }
}