How can I tell if I am running in android:isolatedProcess?

One can check the uid of the running process to see if they fall in the range of isolated process.

int AID_ISOLATED_START = 99000;
int AID_ISOLATED_END = 99999;
int uid = Process.myUid();
if (uid >= AID_ISOLATED_START && uid <= AID_ISOLATED_END) {
    Log.i(TAG, "This is from an isolated process");
}

Process range info source: https://android.googlesource.com/platform/system/sepolicy/+/master/public/isolated_app.te

EDIT: The above has been found to be unreliable on Android 8.1 and below. Another approach is to try accessing privileged APIs and see if an exception is thrown.

try {
    ActivityManager activityManager = (ActivityManager) mContext.getSystemService(ACTIVITY_SERVICE);
    activityManager.getRunningAppProcesses();
} catch (SecurityException e) {
    Log.i(TAG, "This is from an isolated process");
}

As pointed out in an other answer, Android Pie/9 (API 28) introduced a new API for this. See https://developer.android.com/reference/android/os/Process#isIsolated()