Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 21fcbbf2 authored by LuK1337's avatar LuK1337 Committed by Bruno Martins
Browse files

sdk: Move app killed toast message to main application thread

Fixes: Can't toast on a thread that has not called Looper.prepare().

Change-Id: Ia0179ccd4433ac6ceaaa13e03b3e4e6465a6d006
parent 67c0daf5
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -27,6 +27,8 @@ import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.os.Handler;
import android.os.Looper;
import android.os.RemoteException;
import android.os.UserHandle;
import android.util.Log;
@@ -74,7 +76,9 @@ public class ActionUtils {
        final IActivityManager am = ActivityManagerNative.getDefault();
        am.forceStopPackage(packageName, UserHandle.USER_CURRENT);

        new Handler(Looper.getMainLooper()).post(() -> {
            Toast.makeText(context, R.string.app_killed_message, Toast.LENGTH_SHORT).show();
        });

        return true;
    }