Skip to content

Instantly share code, notes, and snippets.

@adipascu
Last active August 10, 2016 14:43
Show Gist options
  • Save adipascu/a99dc2415a12d64406b2474c33219e5a to your computer and use it in GitHub Desktop.
Save adipascu/a99dc2415a12d64406b2474c33219e5a to your computer and use it in GitHub Desktop.
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
public class VanillaNav {
/**
* Show the navigation screen for a location
*
* @param context used to call {@link Context#startActivity(Intent)}
* @param venueId from the <a href="http://www.vanillanav.com/admin">admin panel</a>
* @param destinationId used to reference a location, this field is editable in the <a href="http://www.vanillanav.com/admin">admin panel</a>
*/
public static boolean navigate(Context context, long venueId, long destinationId) {
try {
Intent intent = new Intent();
intent.setClassName("net.rosoftlab.nav", "net.rosoftlab.nav.ui.navigation.NavigationActivity");
intent.putExtra("venueId", venueId);
intent.putExtra("destinationId", destinationId);
context.startActivity(intent);
return true;
} catch (ActivityNotFoundException | IllegalArgumentException e) {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=net.rosoftlab.nav"));
context.startActivity(intent);
} catch (SecurityException e) {
//invalid VN Version
}
return false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment