Android Activity Navigation


Hello there!

The navigation documentation is pretty vague when it comes to Android. I’ve been trying for hours now to figure out how to navigate to a new page on a new activity. The only documentation about this that I found is on this page:

// create a new Frame instance
var frameModule = require("ui/frame");
var frame = new frameModule.Frame();

The last block of code (as shown above) shows exactly what I need. My problem is that it navigates to a new activity but it is completely empty. Anyone know a solution or a way to do it properly?

Thank you.


Hey @SteveGoodtime. If you still not complete the awesome NativeScript Groceries tutorial, Please try to complete it. I am sure then you will get good idea on navigation workflows.


The tutorial does not mention anything about navigating to another frame. My navigation works when navigating from fragment to fragment (topmost frame) but when I try to navigate to a new frame it is blank.


I’m not an expert on navigation in non-Angular apps by any means, but I have used it in the past - for instance in the Bluetooth plugin demo app:


frameModule.topmost().navigate(“path”); works exactly how it should. On Android, there is two ways of navigating: Fragments and Activities. When navigating the topmost frame, it just switches fragments. What I am looking for is navigating to another frame which switches activities which is the right way of navigating on Android.


Ah, I never had the need to break out of the NativeScriptActivity really. Except for of course showing stuff like camera / barcodereader activities via Intents.


I completed my app using default fragment navigation but found that activity navigation is must. If you look at pure native apps, they mostly use it.


Ok, maybe someone can help me here…

After trying to read the code for a while, I found the function “_navigateCore” which calls the function that starts a new activity and then creates a new fragment. So I found a piece of code that blocks the creation of a new fragment:

I then I tried to recall the function a few milliseconds later using a timer by passing the same backstackEntry which I took from “_delayedNavigationEntry”. This actually made it work but not consistently:

    var frame = new frameModule.Frame();
    setTimeout(function() {
    }, 10);

The main problem is that it flashes a blank activity before adding the fragment/page.
The other problem is that I need to get the activity right after I call the “frame.navigate()” function by using “”.

Any suggestions will help.

Thank you.