So starte ich den Dienst:
Code: Select all
Log.Debug(nameof(MainActivity), $"main ProcessId: {System.Environment.ProcessId}");
Android.Content.Intent intent = new Android.Content.Intent(BaseContext, typeof(FfmpegService));
Android.App.Application.Context.StartForegroundService(intent);
Code: Select all
[Service(ForegroundServiceType = Android.Content.PM.ForegroundService.TypeSpecialUse)]
public class FfmpegService : Service
...
public override StartCommandResult OnStartCommand(Intent intent, StartCommandFlags flags, int startId)
{
Log.Debug(nameof(FfmpegService), $"service ProcessId: {System.Environment.ProcessId}");
...
return StartCommandResult.Sticky;
}
...
}
...
Code: Select all
...
Code: Select all
ActivityManager activityManager = (ActivityManager)this.GetSystemService(Context.ActivityService);
var pidsTask = activityManager.RunningAppProcesses;
for (int i = 0; i < pidsTask.Count; i++)
{
Log.Debug(nameof(MainActivity), $"{pidsTask[i].ProcessName} ProcessId: {pidsTask[i].Uid}");
}