0 votes
by (1.5k points)
recategorized by

Please, help, how to invoke Pico System Menu screenshot tool from Unity?

1 Answer

0 votes
by (55.5k points)
selected by
Best answer

Dear developer,

Please try the following code:

AndroidJavaObject context = new AndroidJavaClass("com.unity3d.player.UnityPlayer").GetStatic<AndroidJavaObject>("currentActivity");

AndroidJavaObject intent = new AndroidJavaObject("android.content.Intent");

intent.Call<AndroidJavaObject>("setAction", "pvr.intent.action.CAPTURE");

intent.Call<AndroidJavaObject>("setPackage", "com.pvr.shortcut");

intent.Call<AndroidJavaObject>("putExtra", "action_type", 2);

context.Call<AndroidJavaObject>("startService", intent);

by (1.5k points)
edited by

context.Call("startService", intent); // always needs a return value, sadly

by (1.5k points)

Sadly - it is an immidiate call. We need the same workflow as in the system menu - meaning first choose the command (Screenshot), and only after the short toast description user will be able to capture with long press/short press. Pico System Menu Screenshot - is what we are aiming here for

by (55.5k points)

intent.Call<AndroidJavaObject>("putExtra", "action_type", 0);
0: invokes system screenshot tool and prepares to capture screen, equals to press "screenshot"

intent.Call<AndroidJavaObject>("putExtra", "action_type", 1);
1: captures screen, equals to "short press Home key to finish screenshot and save"

intent.Call<AndroidJavaObject>("putExtra", "action_type", 2);
2: immediate call