Access app_icon from an Android Plugin

Just like the title says. I need to access the app_icon from inside my android plugin.

I tried just using R.drawable.app_icon, but that doesn’t work.

I then tried some code I found:

	public int getResourseIdByName(String packageName, String className, String name) {

		int id = 0;
	    try {
	        for (int i = 0; i < Class.forName(packageName + ".R").getClasses().length; i++) {
	            if(Class.forName(packageName + ".R").getClasses()*.getName().split("\\$")[1].equals(className)) {*

_ if(Class.forName(packageName + “.R”).getClasses() != null)_
id = Class.forName(packageName + “.R”).getClasses().getField(name).getInt(Class.forName(packageName + “.R”).getClasses());
* break;*
* }*
* }*
* } catch (ClassNotFoundException e) {*
* e.printStackTrace();*
* } catch (IllegalArgumentException e) {*
* e.printStackTrace();*
* } catch (SecurityException e) {*
* e.printStackTrace();*
* } catch (IllegalAccessException e) {*
* e.printStackTrace();*
* } catch (NoSuchFieldException e) {*
* e.printStackTrace();*
* }*

* return id;*
* }*
I tried passing in my package name from the plugin and also the package name for my whole unity app. Neither worked.
Can someone give me some sample for for accessing the app_icon from inside my plugin?

In order to access the current App Icon you usually need the Int value of the resource (which normally store at R.Drawable.icon var) the Int value to the icon is: 0x7f020000
Use that to access the resource instead the yourpackage.R.Drawable.icon. At least it work for me!
:smiley:

This works.

    Resources res = getResources();
    int icon = res.getIdentifier("app_icon", "drawable", getPackageName());