Software Archive
Read-only legacy content
17061 Discussions

PhoneGap Android Launchmode serious problem

Alessandro_S_
Beginner
812 Views
Hello another big problem to solve while trying to let my app work with phonegap. After exporting from Xdk and built in phonegap (CLI 6.2 and 6.5) I notice that every tap on app icon or as I follow deeplinks (that usually open my app) a new instance of my app is opened. This is dramatic for me. I tried to add preference to config.xml file preference name="AndroidLaunchMode" value="singleInstance" or "singleTask" But nothing changes. Please help me
0 Kudos
11 Replies
PaulF_IntelCorp
Employee
812 Views

This appears to be an Android+Cordova issue, which is not something we can fix for you. These threads are particularly useful:

The changes being suggested are to the AndroidManifest.xml file, not to your config.xml file. To implement such changes into the AndroidManifest.xml file you need to use some special PhoneGap Build-specific notation withing your config.xml file, as outlined by this PhoneGap Build doc page > http://docs.phonegap.com/phonegap-build/configuring/config-file-element/ < (note this requires adding an additional namespace fragment -- xmlns:android="http://schemas.android.com/apk/res/android" -- to the <widget> tag in the config.xml file to avoid errors with PhoneGap Build).

0 Kudos
Alessandro_S_
Beginner
812 Views

thank you now I'm trying your suggestion. I will update if it works. But...everything I'm changing manually, will be automatically put into config.xml by next XDK release? (in example density for icons, in example this adding made for the LaunchMode and namespace and so on...). I'm trying to figure out that I will put this into config.additions and they will be put into config.xml file ready to be exported, is it? tell me yes please 

0 Kudos
PaulF_IntelCorp
Employee
812 Views

We are fixing the density issue and I've requested that the additional namespace be added to the <widget> tag, as well as several other fixes that are needed for proper operation of the export feature. In addition, I have an external script you can use that I'm currently updating, in order to address changes that do may be delayed in the product.

Regarding the specific instructions you are adding to change the LaunchMode, that is something that is specific to your application, so having us add those tags does not make sense for all users. However, you can put those lines into the intelxdk.config.additions.xml file and they will be transferred, untouched, to the exported config.xml. Other than a few items specific to Crosswalk, everything that is in your intelxdk.config.additions.xml file is transferred without change into the exported config.xml (do a compare and you'll see what I mean).

0 Kudos
Alessandro_S_
Beginner
812 Views

Thank You,

I've used apktool to see difference between standard XDK build apk and standard (no modifications) PhoneGap build apk. In particular I've seen difference in manifest.xml file

1) XDK builds with launchmode = "singleTop" 

2) Phonegap builds without launchmode option (so standard is assumed)

So the problem is not only mine, but for everyone, because the behaviour of the app changes.

Anyway the problem is in example when I call custom url scheme to open app and pass to it parameters. Everytime a new instance is open and is pushed on history stack, so going back and back you fill find the original app opened. This is catastrofic because I handle back and push states

0 Kudos
Alessandro_S_
Beginner
812 Views

hello I fixed it by adding namespace to widget tag (as You suggested) and by adding

 

<config-file platform="android" parent="/manifest/application" mode="merge">
           <activity android:launchMode="singleTop" />
</config-file>
 

to the config.xml of exported zip.

but anyway adding it in config.additions.xml is not exported correctly:(

infact the snippet is not transferred to config.xml if declared outside android platform tag in config.additions.xml; if I declare it into android platform is transferred without activity tag (the most important thing to transfer). But PhoneGap needs it OUTSIDE the platform tag.

0 Kudos
PaulF_IntelCorp
Employee
812 Views

You're correct, it's not getting transferred from the additions file to the config file. I'm just finishing a Node.js script that will work with that situation. I believe it is not getting transferred by the export option because they are using a full XML parser to process the contents, whereas my script is simply doing an AWK-like transformation of the files. There's a draft version of the script I am referring to here > https://github.com/xmnboy/xdk-to-cli < but it won't work the way you want it to until I get the 3.0 version posted, which I'm trying to finish this week. At that point the instructions will change dramatically on that README, so you'll know when it is ready to try.

0 Kudos
Alessandro_S_
Beginner
812 Views

ok, anyway I think you should add for everyone the snippet here, because it lets PhoneGap build to work as XDK build

<config-file platform="android" parent="/manifest/application" mode="merge">
		   <activity android:launchMode="singleTop" android:theme="@android:style/Theme.DeviceDefault.NoActionBar" />
</config-file>

and of course namespace in widget tag. This update fixes SingleTop launch mode and the title bar at starting that I posted here https://software.intel.com/en-us/comment/1900335#comment-1900335

What you think about it?

0 Kudos
PaulF_IntelCorp
Employee
812 Views

I need to check with the build engineer to get the details on how we are setting that parameter in the build system.

0 Kudos
PaulF_IntelCorp
Employee
812 Views

Alessandro, try adding this preference tag to your intelxdk.config.additions.xml file, it should not be removed and should do what you want:

<preference name="AndroidLaunchMode" value="singleTop"/>

See these cordova config.xml docs > https://cordova.apache.org/docs/en/latest/config_ref/index.html < and this sample additions.xml file > https://github.com/gomobile/sample-hello-cordova/blob/master/intelxdk.config.additions.xml <

0 Kudos
Alessandro_S_
Beginner
812 Views
Hello, this has been my very first try. I tried to paste it into exported config.xml, I pasted it inside and outside android platform tag. Phonegap just doesn't consider it. By the way XDK removes it if I paste into config.addition.xml outside Android platform tag. Imo, after days spent fighting aginst Phoneg, the only solution that could work is that one I posted in my previous comment
0 Kudos
PaulF_IntelCorp
Employee
812 Views

I've confirmed what you've found. It appears that PhoneGap Build is stripping or ignoring that standard Cordova CLI preference tag. I built with a local copy of CLI to confirm, and it behaves as expected. I'm asking Adobe why this is the case and will see if this is something we can get into the upcoming hotfix, but I am not able to promise it will be part of that fix, we're trying to address several very pressing issues ASAP.

0 Kudos
Reply