I'm implementing two plugins in my unity project. First plugin is a live wallpaper which contain the main activity. The second plugin is a native sharing. What I did is I got the context reference from the first plugin which contain the main activity:
public static Context getContext()
{
instance.startActivity(myIntent);
return instance;
}
In unity script
Main_Context = appClass.CallStatic<AndroidJavaObject>("getContext");
and then I use the Main_Context reference to call a sharing function in the second plugin
new NativeShare().AddFile(Application.persistentDataPath + "/img Shot.png").SetSubject(" Image Share").SetText("").Share(Main_Context);
The problem is I keep getting this error:
Calling startActivity() from outside of an Activity context requires the
FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?
So it seems that I some how need to add this line in the second plugin just before the startactivity() call
myIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
Is there an easier way to solve this error without editing an already compiled plugin ?