-->

Is SNMP supported in Android?

2020-05-24 16:47发布

问题:

I would like to know if SNMP is supported in Android(2.1)?
If it is not available, is it possible to port the snmp source for Android?(some pointers plz..)

If it is available, how can I test the presence of it in my device.

All pointers are welcomed.

Thanks,
Sen

回答1:

I know this is a really old question, but I was doing exactly what you're asking. The short answer is no, by default, SNMP is not supported on android 2.1. Because it isn't available, what I wound up doing was grabbing snmp4j's source code, and sticking it in android and making my own library. There are libraries (snmp4android comes to mind) but I found that it lacked certain classes I needed and did not have the whole snmp4j.agent branch.

There are a few dependencies and a few libraries that android is missing but most of them pertain to the log4j class.

To remedy that, just convert/make the switch to something like slf4j, which is a small logging library that you can include with your application.

I hope that answers some of your initial questions, and I hope this is still relevant even if it is an old question.



回答2:

SNMP4J 2.x can be directly used on Android without changing its sources. The logging can be set to a simple console logger by calling

  static {
    LogFactory.setLogFactory(new ConsoleLogFactory());
    ConsoleLogAdapter.setDebugEnabled(true);
  }

in your root activity. Of course, you can implement a Android Logging Adapter too and register it as shown above.



标签: android snmp