One .apk file that installs two apps - android

This is a question concerning android applications with two different .apks (or two apps contained in the one .apk file)
I have two apps which do completely different things but are related, say one is a standard user app and one is an admin app. But a user can be both a user and an admin. I am wondering is it possible for me to create one .apk file that installs two applications to the phone? And how would I got about this?
Thanks,
Matt

You can have two activity elements in the same manifest file, which have both the intent filter with action=MAIN and category=LAUNCHER. Further, you have also to use the attribute "android:taskAffinity" for both activity elements (see also here):
<application android:allowBackup="true"
android:icon="#drawable/main_icon"
android:label="#string/main_name"
android:theme="#style/AppTheme" >
<activity android:name="com.foobar.MyActivity2"
android:taskAffinity="com.foobar.MyActivity2"
android:icon="#drawable/icon1"
android:label="#string/name1" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.foobar.MyActivity2"
android:taskAffinity="com.foobar.MyActivity2"
android:icon="#drawable/icon1"
android:label="#string/name2" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
When the APK file with this manifest is installed on a device, then it will create two icons on the homescreen. The titles of these icons will be taken from the attributes android:label, and the icons will be taken from the attributes android:icon. In the list of apps under "Settings | Apps" you will see the name & icon defined by the attributes of the application tag. When you choose "uninstall" for this entry in the list of apps, then both "apps" will be removed from the device.

It depends on your definition of "application". You cannot install 2 applications if you use the more official definition, as you can have only 1 <application> in your manifest.xml
You can define several activities in your manifest.xml, and they can do seperate things, so in that way YOU CAN have 2 things a person might describe as "application" in one APK
Just define multiple activities and use those could be defined as an option, but it depends on your definition of 'application', but in this case I'd say it would work

Yes, you can install multiple apps by just installing one app.
In Manifest.xml
Project Structure:

You should either build 2 APKs are use APK Expansion Files.
Btw, this is a security measure.

No.
what you can do is to check if the second app is already installed, and if the answer is no, you can prompt the request to install the second app using this post.

Related

Two apps in one apk

When I build a single apk and I try to install it on the device two apps are shown instead of one, but neither app opens. What is the cause of this? I just want one only.
No, there's still just one app but you need to tweak your Manifest file as apparently you have two activities with
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
Remove this filter from activity you do not want to be your entry point.

Enable Widget Setting button for widgets in Android?

Samsung One UI Home Screen shows a setting button for some widgets when I select the widget,
But not for some
Wondering what is the difference between the two or is it just a OEM specific feature as I couldn't the menu in POCO launcher or emulator's launcher at all.
Please note I am already using
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
android:configure=".WidgetConfigurationActivity"
...
in my provider and this in my manifest
<receiver ...>
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
...
Yet these are just adding configuration when I add a widget not after the addition of the widget, and couldn't find the answer on searching the net.
I know this question is months old, but I'll answer anyway. After reverse-engineering a Samsung app, I've found the secret behind the Settings button.
You only got to add this meta-data to your app widget (<receiver>):
<meta-data android:name="android.appwidget.provider.semConfigureActivity" android:value="com.example.MySettingsActivity" />
Full example:
<receiver android:name="com.example.MyWidget">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE"/>
</intent-filter>
<meta-data android:name="android.appwidget.provider" android:resource="#xml/widget_info"/>
<!-- The secret sauce is here -->
<meta-data android:name="android.appwidget.provider.semConfigureActivity" android:value="com.example.MySettings"/>
</receiver>
Advice: It's recommended to learn reverse-engineering to implement undocumented features (just make sure the core functionality of your app does not depend on undocumented APIs).
Just to add also, in Android 12 this has standardized finally and provided with android:widgetFeatures="reconfigurable" or (reconfigurable|configuration_optional), see https://developer.android.com/guide/topics/appwidgets/configuration#use-default for more information from Android 12.
Also maybe worth to note, apparently reconfigurable has been defined for some releases just that in this release the declared it as officially supported.

Changing Android packagename in AndroidManifest.xml without actually changing folder package paths

I have a template app which can be easily reskinned changing config params according to a client's brand. When it comes to publishing on Google Play, I obviously need to change packagename on AndroidManifest.xml.
My question is: is that possible without changing folder names, so that I don't need to mess with the whole project structure?
It's totally possible. In your AndroidManifest.xml you should change your package name according to your need, then all your activities and services should target the full path of your classes.
For instance if your application package name should be com.mybrand.myapp and your old java package name is com.myoldbrand.myoldapp your manifest should look like this :
<application
android:allowBackup="true"
android:icon="#mipmap/common_app_icon"
android:label="#string/common_app_name"
android:supportsRtl="true">
<activity android:name="com.myoldbrand.myoldapp.MyActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
hi it's 4 years after your problem, I faced the same problem today,
and here is my solution to the next one who face the problem
change com.example.your_app_name to what you need like com.companyname.your_app_name
you will find that in many places
i know 4 of them
1.) src/profile/AndroidManifest.xml
2.) src/debug/AndroidManifest.xml
3.) src/main/AdroidManifest.xml
4.) build.gradle .
to find other places search about them with ((edit>>find>>find in path))
after changing them all it worked with me
Android Studio has a really powerful refactor tool that allows you to rename the whole package structure on a easy way by also renaming all directories. You should not use different names in java packages and in your project directory tree, that will make your project pretty dirty.
Did you try this answer. It worked for me when I was working on Eclipse.

Bundle mobile apps into single download

Is it possible to bundle several mobile apps into a single download? So a person can install the bundled apps, then have several new apps available on their phone.
For example, a bundle of iOS apps, or a bundle of Android apps?
For iOS you can't do it. I tried to place multiple application in one ipa (which is just zip), but it will recognized just one of them.
Downloading additional content is also prohibited on iOS.
However, if you distribute application over the air, you can create a file (I don't remember exactly how it's called) which will have multiple asset's in it (multiple ipa's).
For Android, pablisco and user2115660 pretty much covered it.
You can't do that as it is. What wou can do is add an extra Activity with a CATEGORY_HOME in the intent filter and it will appear as a separate app on Android's launcher:
<intent-filter>
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.HOME" />
</intent-filter>
You would have to change the icon and label properties of the activity for it to have a different icon and name as well :)
UPDATE:
The format I was using for the intent filter wasn't correct. This is how the activities would have to be declared inside the application tag in the manifest:
<activity android:name=".MainActivity"
android:icon="#drawable/main_icon"
android:label="#string/main_app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".SecondaryActivity"
android:icon="#drawable/secondary_icon"
android:label="#string/secondary_app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
If you want to include an Activity inside a library project you will have include the full path to that given Activity.
One interesting approach would be to create both apps like library projects and then compound them into one. Bear in mind that you can't package library projects into apk so you would have to do separate projects if you want to create individual products.
Here is some info about library projects: http://www.vogella.com/articles/AndroidLibraryProjects/article.html
I saw one app that after instillation started downloading apk's and installing them.
For iOS, outside of the jailbreak world, of which I am not overly familiar with, no.

Bundling multiple apps I have created into one .apk file

Is it possible to bundle an app and the app settings into one apk file? so I can change the app settings from the "App settings"
Thanks
If these two apps have no overlaps, you only need to merge the AndroidManifest.xml, res and src folders.
Keep two activities with the following intent filter:
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
will make you have two launch entrances in Launcher.
In fact, it's one app with one apk. But since have two launchable activities, user will feel like they have installed two apps with one apk.
Found answer on another question

Categories

Resources