Can multiple versions of the same iphone or android app use shared code or libraries?
Let's say I write an app that displays restaurant menus and lets a user order items from them. I'll call it RestaurantMenuApp. I'd like to have this main application be branded under my company name. It would allow users to view multiple different restaurants and place orders on any of them. Purchases are done through API calls to my web service using my company's merchant account.
Now let's say I also want to sell customized versions of this app to individual restaurants. The customized version would be themed just for that restaurant, only show their menus, locations, their promos, and so forth. It would make the restaurant look like they built their own custom app. Purchases are still done through API calls to my web service, but each branded version can use their own merchant account.
I'm wondering if each application (the main RestaurantMenuApp and each individually customized restaurant app) has to contain an entire copy of the entire application. Is it possible to have each app install a shared library that all of the apps use? If any of the apps has already installed this shared libr开发者_JAVA百科ary, the others apps don't need to install it as well?
I'm new to mobile app development and searched for answers, but could only find solutions for how to build lite vs. full versions of the same app. It was not clear if these apps could SHARE code to make each install smaller.
For iPhone/iOS App store apps, an OS enforced security sandbox prohibits apps from sharing any code.
For iPhone, the inter-app communication is restricted almost to none. Apple designed the iOS this way for the benefit, arguably, of security and user experience.
On Android, there is much more flexibility in inter-app communication. There are several ways to achieve what you want.
First, you can use service. Service processes on Android are pretty much like service processes on Windows. They are running in the background all the time. There is an code sample.
http://marakana.com/forums/android/examples/60.html
Or you can use intents. Intent receivers register with the Android OS to specify what action and data format that they will handle. For example, an intent filter like below tells the Android OS that the receive will be able to view, edit, and pick any mime type of vnd.android.cursor.dir/vnd.google.note. So you can create a component as intent receivers to take care of a special data format. In another Android app, you then push out your data and the intent receiver will take over from there.
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.EDIT" />
<action android:name="android.intent.action.PICK" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="vnd.android.cursor.dir/vnd.google.note" />
</intent-filter>
For more information on intent filter, you can refer to this doc.
http://developer.android.com/guide/topics/intents/intents-filters.html
精彩评论