jeudi 13 décembre 2018

Argument is not assignable to 'int'

I'm trying to convert a code to reflection. This is the exact code that I'm trying to convert to reflection

android.os.Process.killProcess(android.os.Process.myPid());

Here is my reflection code.

Class<?> process = Class.forName("android.os.Process");
Method killProcess = process.getMethod("killProcess", Integer.TYPE);
Method myPid = process.getMethod("myPid");
killProcess.invoke(null, myPid.invoke(null));

How ever the issue is I'm getting an warning on this line myPid.invoke(null) the warning as stated in the title is Argument is not assignable to 'int'

Here is a snapshot of the warning.

My question is how do I resolve this warning without using surpass? I wan't to resolve this a proper way instead of using surpass warning annotation or disabling the warning.

enter image description here





Aucun commentaire:

Enregistrer un commentaire