How to have external app as requirement for installation of app widget?
I hava an app. External to the app, as a second .apk I have an app widget, which accesses the app's db via a ContentProvider. So the app widget only works, if the app is installed.
I would like to have the following scenario:
Is there a way to accomplish this, ie. with some setting in the app widgets manifest? If not, what other options/scenarios are available? Minimum SDK is 7, target SDK is 8.
Note: Having both the widget and the app in the same apk is not an option as the app is large and installs to the SD card, while app widgets must be installed on the internal memory. That is the reason for the separation.
When a user attempts to install the app widget, the installation should abort and inform the user, that he has to install the app, too.
If by "install the app widget" you mean "install the APK containing the app widget", this is not possible.
If by "install the app widget" you mean "add the app widget to the home screen", you might be able to rig up something using a configuration activity. This will more or less boil down to alex's answer in the comment.
When a user uninstalls the app, the app widget should be removed, too, or alternatively
This is not possible.
the user should be informed, that Unistallation of the app will break the widget.
That too is not possible. However, once the user uninstall the one APK, the app widget APK could have a BroadcastReceiver
watching for ACTION_PACKAGE_REMOVED
, and then let the user know about the problem.
If not, what other options/scenarios are available? Minimum SDK is 7, target SDK is 8.
Don't bother with the app widget until Android 3.0+ becomes sufficient dominant that you are willing to package it in the main APK, as "install to external storage" has no real meaning on Android 3.0+.
链接地址: http://www.djcxy.com/p/50582.html