How to combine two applications into one - android

Following my previous question, I found out that using BroadcastReceiver to launch my service, the service launches on startup and it doesn't show on task killer.
now my question is, how I add this application (or package) to my main application, so it will be installed as two applications.
I tried to add it as a library, but then the service is attached to the main app, and it can be killed with task killer.

Your question confuses me. Perhaps it is because on the Android, the words 'activity', 'application', 'service' etc take on different meanings from what they would be on another platform. Perhaps you can describe better e.g.
What icons do you want to see on your app launcher?
What entries do you want to see in your app manager > installed apps?
another thing i didn't understand is "how to add this app/pkg to your main application, so that it will be installed as two apps". If you add a package to your main application, then there will only be one application.

Related

When other apps share with my app, it kind of creates two instances of my app

I have an app that works best if the main activity is always the same activity instance, otherwise, it would be very confusing to users. When I first coded this app years ago, the solution I found was to use:
android:launchMode="singleTask"
android:taskAffinity="somestring"
And this works well for the most part, but when some apps share stuff with my app, it is like my app becomes part of their app and now it is like I have two separate instances of my app. If I go to the task switcher and select their app, it will actually go to my app. This works fine with most apps that can share stuff with my app, only some will cause this issue.
How can I get around that issue?
Edit: As it was pointed out, it is not two separate instances but my users think it is, and it is annoying them a lot.
Edit: The issue appears to be when the sharing app uses startActivityForResult instead of startActivity.

Android launch app inside view

Alright so I have an app that I would like to have utilize other apps. For example I have an app that does quite a number of things except for a directory look up since there is already an app that does that for my school. I know I can launch the application with intents, but that also brings them away from the navigation menu for my application. Is there anyway that I could run an app inside a view layout. I am not hopeful for this but I figured I would chance asking it anyway.
This is technically possible by using widgets. You can implement an AppWidgetHost, and other applications can create App Widgets to use inside your own app. This is how the launcher screen in Android works.
This, of course, will only work if other applications in question implement widgets. So, the general answer to your question would be no, it is not possible to host arbitrary applications or Views/Activities from other applications inside your own.
This not the Android design philosophy. You should send an Intent to the directory app, which I hope is designed to look up a result and then return it to you. The mechanism is startActivityForResult() in your app, and setResult() in the directory app.

Android: How to fork a new process

I want to run two processes in the same DalvikVM. This means that I want to run a first app and then that this app starts the second app. And I want that this two apps are then running in the same DalvikVM. I think it is possible if the first app forks an process for the second app. But I´m not sure how can I do that.
Thanks
I want to run two processes in the same DalvikVM.
By definition, that is impossible.
This means that I want to run a first app and then that this app starts the second app. And I want that this two apps are then running in the same DalvikVM.
By definition, that is impossible.
I think it is possible if the first app forks an process for the second app.
No.
I very much doubt what you actually want to do is go digging into the specifics of processes (if you do I would question why). In any case, Android deliberately makes it very difficult for you to go near processes as the platform provides sufficient mechanisms to achieve virtually any functional flow without needing to.
I suspect what you actually mean is you need to start a new Android task (has it's own back stack, functionally operates like a separate application).
Have a read of the Tasks and Back Stack document from the dev guide, particularly the section on tasks. What you probably want to look at is starting your new activity using the FLAG_ACTIVITY_NEW_TASK flag in the Intent.

Android - creating custom launcher

I am intending to develop custom Launcher for Android phone. I have searched web, but I haven't found any valuable information regarding creating "launcher" project. What does an android app needs for being at the top of the GUI (aka launcher)?
I saw this thread a while ago, before creating my own launcher. Here are some crucial things I learned:
Declaring your app to be a launcher
David already mentioned the piece of code that determines your app as a launcher:
<category android:name="android.intent.category.HOME" />
Add this as an intent-filter to the activity your launcher will use for the home screen (in AndroidManifest.xml).
Launcher Issues
As a launcher will run all the time, you need to understand the activity livecycle to prevent issues (like this one).
If you want users (and yourself) to be able to constantly user the app (that's what you usually do with launchers), make sure it never crashes. In the case of a crash users will be taken back to the devices default launcher or other installed ones.
In short: Launchers are expected to be reliable.
Common launcher functions (users usually expect those)
1) A list of apps / appdrawer
From which all apps can be launched or modified. You can use packageManager to list the apps.
As generating such a list may take a while, I suggest you to do it asynchronously and save the list somewhere to speed everything up (which also is expected from launchers ^^)
2) Some settings to change the launcher
I had some users stuck in my launcher before implementing those ^^
You can open the devices launcher settings like this (in Kotlin):
// working in APIs newer than Lollipop
val callHomeSettingIntent = Intent(Settings.ACTION_HOME_SETTINGS)
startActivity(callHomeSettingIntent)
Bonus) An in-app tutorial
This may be useful if you have some features in your app that are not trivial, ways of launching apps that users don't know from other apps.
It also gets you way less messages from users asking how to interact with your software.
Resources:
The GitHub of the minimal launcher I created may be helpful: finnmglas/Launcher
Well, firstly you need to listen to the android.intent.category.HOME intent. Here are some links with full source code which you can have a look at:
Old launcher source code
New launcher source code
Or take a look at launcher plus.

group multiple apps under the same icon in Application launcher

I want to group multiple apps under the same icon in the application launcher.
For example, 5 apps each displaying 1 different image. But those 5 apps should appear as separate apps on the Android market, therefore they need to have different package name.
But different package name, means that on the Android device they will appear as 5 separate apps in the application launcher, which I am trying to avoid.
The closest solution that I found is to listen for PACKAGE_ADDED broadcast event, and every time another app from those 5 are installed on the device, all the already installed apps would call setApplicationEnabledSetting from PackageManager to hide their icons and let the app that was just installed to handle things.
But the icons are hidden only after rebooting the device.
Is there a way to force the application launcher to refresh at runtime?
Or is there any other way to solve my goal?
I am running out of options. Thanks!
Miha,
What about having one main application, with the other 4 being add-ons (i.e., not shown in the launcher)? You would then have only one launcher icon, and the other applications would be started from the main app. By checking whether the other apps were installed, you could adjust your buttons/views accordingly.
As far as I know, there is no way to force the launcher to refresh. However, you could implement your applications as you described -- having each app hide it's icon when I new one is installed. The user would get an application not installed error though, which is probably not something you want.
Personally, I used the first method: have a main keyboard and then install add-ons which can then be loaded from the main app.
Hope this helps.

Categories

Resources