How to check if class exists somewhere in package?

后端 未结 4 721
南笙
南笙 2020-11-29 08:49

I\'m currently dealing with a particular issue with my paid application. Internally it contains a licensing check. The app is patched by hackers by modifying the app apk/j

4条回答
  •  死守一世寂寞
    2020-11-29 09:47

    Here is what I used in Android - standard Java:

    public boolean isClass(String className) {
        try  {
            Class.forName(className);
            return true;
        }  catch (ClassNotFoundException e) {
            return false;
        }
    }
    

    Implementation example:

    if (isClass("android.app.ActionBar")) {
        Toast.makeText(getApplicationContext(), "YES", Toast.LENGTH_SHORT).show();
    }
    

提交回复
热议问题