Phonegap multiple instances - android

Hi I'm working on a phonegap / jquery mobile app. It is an audio (media.play) based app. I have the problem of multiple instances with StatusBarNotification plugin. I've tried to force with android:launchMode="singleTop" and it seems to work fine, but in some strange cases a new instance of the app opens, and the first one is working on background with the audio running.
It is quite annoying becouse I can't stop the audio until I get back to the first one. Is there a piece of code that really forces to only one instance?
I've heard about launchMode="singleInstance", but don't know really the difference.. what will be better?
Thanks.

It strictly depends on the device, where you run your application. Consult this answer to see, that on some devices (here: HTC) using android:launchMode="singleTask" rather than android:launchMode="singleTop" solve the problem.

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.

Improving performance of PhoneGap application on Android?

i am new to phonegap i want to know how can i improve performance of my app created using phonegap. Key issue is when the app starts up it is very slow on emulator as well as on device. When the app starts it first shows native android activity UI then the webview is invoked. Why this transition is happening and how i can hide from user.
Sounds like you are talking about splashscreen.
Im going to give you a lot of general answers, hope that some of them can help you.
You can extend the "splashscreen" life time by using the config.xml file, check this:
https://build.phonegap.com/docs/config-xml#android-prefs
Simon made a post about Android Splash Screens:
http://simonmacdonald.blogspot.dk/2012/04/phonegap-android-splashscreen-just-got.html
Or read some here:
Black screen for Android app

Android App, how to run without GUI?

How do I create a simple app that runs a method or activity without actually opening a gui?
I have the coding for the app already.
For example, a task manager on android I have has an icon that you push and it terminates apps running in the background without having to open an app and then pushing terminate manually.
Do I just remove the layout or do I need to have more than that?
Sorry for using the wrong terms, I'm still learning.
Thanks
Ran into your question by chance, I'm learning on the go myself. But it sound to me you maybe should consider making a service, and not an activity that has a layout. A service can work in the background and interact with other applications, which seems to me is your case.
Android Service API http://developer.android.com/reference/android/app/Service.html
Good luck!

Pause an Android App with Phonegap

Is there any way to programmatically pause an Android app in Phonegap? I would like to mimic the behavior that occurs when you hit the HOME button. I've already had to overwrite the back button handler using this, and while in most cases I want it to do my action, when in a particular state the user would expect the app to minimize, and I want to replicate this behavior.
Keep in mind, on Android this is not the same as closing the app. That is quite easy to do with device.exitApp(); but I would like it to remember its state and keep running in the background. Especially if there's still an asynchronous job being done in the background.
Is there a feature in Phonegap to achieve this?
Possible duplicate of Manually pause an application in Android Phonegap, but I couldn't find some of the tools the OP mentioned there such as navigator, so I was nervious to totally edit and rewrite their post
The simple answer appears to be: no.
However, for anyone else that comes down this path, its not impossible. It's just that there isn't a feature of Phonegap to do it for you.
The Android equivalent of "sleeping an app" is actually just opening another intent. Specifically, opening the "Home" intent would sleep the running app and bring you back to the home screen. But as far as I can tell from asking around and scoping the docs, Phonegap doesn't have a direct way of opening intents.
What you (supposedly) can do is one of two things:
This plugin is supposed to be promising
Call the Java code that does it yourself using the means described here
Mind you, as of right now I've decided to not go any further with this, so I make no promises about either of those means, having not attempted them myself.
I invite anyone else who decides to pursue this further to update their experience here.

Run only one custom app in Android, prevent anything else from running

Is it possible to make Android be able to run only one app? It seems that making a custom ROM might be the option.Can anyone point me to the right direction?
Numerous answers and questions on this already. Basically you have the following options:
Creating you own rom.
Creating your own launcher application.
The best solution is definitely 1, but it's much more complicated. Making your own launcher application could be a solution but it would never be perfect, there would always be ways for the user to get back to normal Android, so if you can't accept that then you need to make your own rom.

Categories

Resources