This object is in archive! 

sample code to launch Locus intent

JJ MONOT shared this question 9 years ago
Answered

Hello Menion


Could you provide quick sample code to integrate in my android app in order to launch directly Locus as intent centered on a POI point (given by the intent : geo:lat,lon)?


I have found various information but not a specific code to launch only Locus.


Thank you !

Replies (8)

photo
1

Hi,


there are generally two ways, where depend what you want to do. If you want just display point on map, you may use simple method.


By simple I mean creating common intent as you probably do with geo data. But also set class name that should start this intent by


  1. intent.setClassName("menion.android.locus", "menion.android.locus.MainActivity");

I've not tried it, but it should work. If you want to start Locus Pro, just use "menion.android.locus.pro" package name.


Second, more complicated way is to use existing Locus API, which allows a lot more, but it depend if you need it.


Let me know if it works or if you need more precise information

photo
1

Thank you Menion !


I have two more questions :


1. how can I check that Locus or Locus Pro is intalled on the smartphone ?

I have found following example on the web :

  1. private boolean isCallable(Intent intent) {

    List<ResolveInfo> list = getPackageManager().queryIntentActivities(intent,

    PackageManager.MATCH_DEFAULT_ONLY);

    return list.size() > 0;

    }

2. Api

I have found LOCUS Api in Google Code, is is the latest API ? : https://code.google.com/p/android-locus-map/


photo
2

Sure, you're welcome.


Code you wrote seems to be correct. With this method, you may simply check if exists any application that may handle intent parameter. So if you specify ClassName as I wrote in previous post, you may check if specific verison of Locus is installed.


2. Yes, it's correct. Just yesterday I pushed bigger update with some changes. Anyway all features to check if Locus is installed are already in API. Like here https://code.google.com/p/android-locus-map/source/browse/src/locus/api/android/utils/LocusUtils.java?repo=locus-api-android#320

photo
1

Thank you for the support .


Concerning the intent and the "pro" or "non pro" version, is the activity name the same ?


PRO : is this correct ?

  1. intent.setClassName("menion.android.locus.pro", "menion.android.locus.MainActivity");

or this ?

  1. intent.setClassName("menion.android.locus.pro", "menion.android.locus.pro.MainActivity");

NON PRO :

  1. intent.setClassName("menion.android.locus", "menion.android.locus.MainActivity");

photo
1

I'm stupid, really sorry. I never called Locus in this was so I completely forget, that package of MainActivity is same for all versions.


It's com.asamm.locus.core.MainActivity

photo
1

OK. It is better now .... :-)


I have tried the following and it works :


  1. intent.setClassName("menion.android.locus.pro", "com.asamm.locus.core.MainActivity");

photo
1

Going now further .... I have tried to use OsmDroid to display maps and elements inside my application, but it is not stable enough and some regression appear with new version.....


So, is it possible to use Locus as "map engine" and integrate Locus map views inside my own application ?

photo
1

Unfortunately no, it's currently not possible.


Locus map engine is not a completely separate library and I currently do not plan to publish it under any free license, sorry.


EDIT: Anyway I suggest to try MapsForge library, which part I also use in Locus and which seems to be quite stable and fully working. So give it a try.

Replies have been locked on this page!