How to make "uses-library" optional in android

I created an Android app that uses the Google Map feature. I want my application to be installed on phones that do not install Google Map, in which case I would disable the map function.

There is a uses-library tag in the manifest file, what can I do with this?

+4
source share
3 answers

@CommonsWare: I think you are referring to android: required , not android: enabled

Something like that:

<uses-library android:name="com.google.android.maps" android:required="false" /> 
+6
source

There is an undocumented android:enabled attribute in <uses-library> . However, Dianne Hackborn mentioned this in the discussion, saying that we use it, so I hope this is a documentation error and that it is really supported.

Having android:enabled="false" , then using reflection to see if MapActivity , you should give you what you need, AFAIK.

+1
source

You must definitely use reflection. Make your activity on the Singleton map and create an interface for your public methods. Then use try catch to check if the class exists through the class loader. If so, in an attempt to get started. If you need to interact with the withe class, then declare an instance of the type interface as a data element and use reflection to interact with it.

0
source

All Articles