0

I have this line of code:

ActivityOptionsCompat.makeSceneTransitionAnimation(this);
//ActivityOptionsCompat.makeSceneTransitionAnimation(this, null); // tried this as well

which causes the mentioned warning. The method signature is

ActivityOptionsCompat makeSceneTransitionAnimation(Activity activity, Pair...<View, String> sharedElements)

I wish to send a null sharedElements but my code gets a warning.

user1506104
  • 6,554
  • 4
  • 71
  • 89
  • Did you mean `Pair...`? – Eran Nov 20 '18 at 07:06
  • Yes. Just copied it here https://developer.android.com/reference/android/support/v4/app/ActivityOptionsCompat#makescenetransitionanimation – user1506104 Nov 20 '18 at 07:08
  • Always keep in mind a Warning is just a warning. Have a second look and if you are convinced all is OK move on. – Henry Nov 20 '18 at 07:20
  • Possible duplicate of [Java unchecked: unchecked generic array creation for varargs parameter](https://stackoverflow.com/questions/21132692/java-unchecked-unchecked-generic-array-creation-for-varargs-parameter) – Hulk Nov 20 '18 at 07:21
  • Why do you want to pass a null array anyway? – Andy Turner Nov 20 '18 at 07:25
  • I believe the linked duplicate question does not answer the question. I am referring to a method that I do not have control over with. – user1506104 Nov 20 '18 at 07:33
  • @AndyTurner. I don't know what it means if I pass a null sharedElements. I am just curious about null varargs with generics. – user1506104 Nov 20 '18 at 07:35
  • 1
    @user1506104 ok - I suppose in that case suppressing the warning is the best you can do (supposing that the method even works as you expect if you don't pass any `sharedElements`, which I'm not sure about, as the docs specifically mention special treatment of the first `sharedElement`) – Hulk Nov 20 '18 at 07:38
  • 1
    Note that the warning should be independent of wheter or not the varargs are empty - you get the warning if you use the method with varargs, if you use it with a generic array you created yourself you don't - but then you need to suppress the warning where you create the array, which doesn't really change anything. – Hulk Nov 20 '18 at 07:54

0 Answers0