Can't get Image marker plugin to working PLEASE HELP

659 views
Skip to first unread message

daniel

unread,
Sep 27, 2012, 6:19:56 AM9/27/12
to mixare-de...@googlegroups.com


HI mixare people,

My main gold is to load the splash-screen and initialize the imagemarker plug-in

I've got the Bootstrap  working and it's loading the splash-screen , but it will not load the imagemarker plug-in

tried to put the service into my manifest between <application> </application> but my app crashes after loading the splash-screen
I've also got to classes in my project imagermarker.java and ImageMarkerService.java also have a object_url in my JSON php
<service
android:name=".service.ImageMarkerService" android:exported="true" > <intent-filter> <action android:name="org.mixare.plugin.marker"/> <category android:name="mixare.intent.category.MARKER_PLUGIN"/> </intent-filter> </service>


If anybody have a solution I will be VERY happy:-)
being following aduegal tutorials, but may by I am missing something ?.

Best
Daniel



This is my manifest for my AR app:



<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      android:versionCode="30" android:versionName="0.9.5" package="dk.skaale.insideout2400" android:installLocation="auto" xmlns:tools="http://schemas.android.com/tools">

    <uses-sdk android:minSdkVersion="3" android:targetSdkVersion="10"/>

    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.CAMERA" />
    <uses-feature android:required="false" android:name="android.hardware.camera.autofocus"></uses-feature>
    <uses-feature android:required="false" android:name="android.hardware.camera.flash"></uses-feature>
    <uses-feature android:required="false" android:name="android.hardware.camera.front"></uses-feature>
    <uses-permission android:name="android.permission.WAKE_LOCK"></uses-permission>
   
    <supports-screens android:anyDensity="true" android:smallScreens="true" android:normalScreens="true" android:largeScreens="true" android:xlargeScreens="true"></supports-screens>
   
   
    <application android:label="@string/app_name" android:icon="@drawable/ic_launcher">
        <uses-library android:name="com.google.android.maps" />
         
             <activity android:name=".PluginLoaderActivity" android:icon="@drawable/ic_launcher"
                  android:label="@string/app_name" android:screenOrientation="landscape" >
                    
             
             
         
                   <intent-filter>
                    <category android:name="mixare.intent.category.BOOTSTRAP_PLUGIN"/>
                 <action android:name="org.mixare.plugin.marker"/>
               <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter> 
   
        </activity>
       
   
<service
          android:name=".service.ImageMarkerService"
          android:exported="true" >
          <intent-filter>
             <action android:name="org.mixare.plugin.marker"/>
             <category android:name="mixare.intent.category.MARKER_PLUGIN"/>
          </intent-filter>
      </service>
      
 
     
        <activity android:label="@string/app_name" android:name=".MixMap"
        android:screenOrientation="landscape" 
        android:launchMode="singleTop" >
           
            <intent-filter> 
                  <action android:name="android.intent.action.VIEW" />
                  <category android:name="android.intent.category.DEFAULT" />
                  <category android:name="android.intent.category.BROWSABLE" />
                  <data android:scheme="http" android:mimeType="application/mixare-json"/>
                  <data android:scheme="content" android:mimeType="application/mixare-json"/>
                  <data android:scheme="file" android:mimeType="application/mixare-json"/>
            </intent-filter>
           
            <intent-filter>
                <action android:name="android.intent.action.SEARCH"/>
            </intent-filter>
            <meta-data android:name="android.app.searchable"
                       android:resource="@xml/searchable"/>
            <meta-data android:name="android.app.default_searchable"
                       android:value=".MixView" />
        </activity>
       
       
     
       
        <activity android:name="MixListView"
            android:screenOrientation="user"
            android:launchMode="singleTop">
            <intent-filter>
                <action android:name="android.intent.action.SEARCH" />
            </intent-filter>
            <meta-data android:name="android.app.searchable"
                       android:resource="@xml/searchable"/>
        </activity>

        <activity android:name="MixView"
            android:screenOrientation="user"
            android:launchMode="singleTop">
            <intent-filter>
                <action android:name="android.intent.action.SEARCH" />
            </intent-filter>
            <meta-data android:name="android.app.searchable"
                       android:resource="@xml/searchable"/>
        </activity>
         <activity android:name=".data.DataSource" />
         <activity android:name=".data.DataSourceList" />
         
   
       
</application>
 
</manifest>

daniel

unread,
Sep 27, 2012, 7:46:33 AM9/27/12
to mixare-de...@googlegroups.com
Actually is not the bootstrap thats loading the splash-screen but the .
PluginLoaderActivity.

But is it possible to load mulitple services in the android manifest splash-screen an imagemarker?

anybody know?

Best
Daniel

Abdullahi Egal

unread,
Oct 9, 2012, 7:16:48 AM10/9/12
to mixare-de...@googlegroups.com
Hi Daniel,

contains a working image-marker maybe you can check on that. 

The newest mixare version already contains the image marker in its core. So if you don't want to change anything in the image marker then you don't need to use it.
You just have to make sure that your data contains the following string "photos"

Another thing, the imagemarker will only be loaded if you select it using a datahandler. https://github.com/abduegal/mixare/wiki/Data-handler
See the following lines:
					InitialMarkerData ma = new InitialMarkerData(jo.getInt("id"),
					HtmlUnescape.unescapeHTML(jo.getString("title"), 0),
					jo.getDouble("lat"), jo.getDouble("lng"),
					jo.getDouble("elevation"), link, taskId, colour);
					ma.setMarkerName("imagemarker");

Let me know if this solved your problem.
Sincerely,
Abdullahi

Shahry

unread,
Dec 11, 2012, 8:25:37 AM12/11/12
to mixare-de...@googlegroups.com
Hi Abdullahi,

thank you for your useful contribution and tutorials.

I've just tried to use plugins in my app but I don't manage to make them work.

I've got Mixare 0.9.2 but I imported imagemarker-plugin packages in my project as well renaming them into org.mixare.plugin.marker and org.mixare.plugin.marker.service.
Then I imported arena-processor-plugin renaming into org.mixare.plugin.datahandler and org.mixare.plugin.datahandler.service.

I put the code below in my AndroidManifest.xml

<service
          android:name=".plugin.marker.service.ImageMarkerService"
          android:exported="true" >
          <intent-filter>
             <action android:name="org.mixare.plugin.marker"/>
             <category android:name="mixare.intent.category.MARKER_PLUGIN"/>
          </intent-filter>
      </service>
     
<service
          android:name=".plugin.datahandler.service.ArenaProcessorService"
          android:exported="true" >
          <intent-filter>
             <action android:name="org.mixare.plugin.datahandler"/>
             <category android:name="mixare.intent.category.DATAHANDLER"/>
          </intent-filter>
      </service>

Using Log I can notice that both the plugins are loaded (PluginLoader.java: if (sinfo != null) is verified), but they don't work and I still see the white circle for my POIS instead of the icon that I set in my json objects with attribute "object_url" (I've add #arena at the end of my file (with POIs inside) URL in the arrays.xml).

What are my mistakes?

Thank you very much!

Shahry

unread,
Dec 11, 2012, 11:11:48 AM12/11/12
to mixare-de...@googlegroups.com
I forgot to say that I always need to use plugins, so I don't ask user if using them or not but I directly launch PluginLoaderActivity.

Abdullahi Egal

unread,
Dec 11, 2012, 3:24:28 PM12/11/12
to mixare-de...@googlegroups.com
Hi Shahry,

I dont think that the problem is in your code, but in your JSON. Can you please send me a sample JSON that you are using for mixare, so that I can look at it.

It seems that you used the ArenaProcessor and ImageMarker well. But in order to load the plugin, you need to specify some matchers.
In the case of the ArenaProcessor its the following:
                @Override
		public String[] getUrlMatch() {
			String[] str = { "arena" };
			return str;
		}

		@Override
		public String[] getDataMatch() {
			String[] str = { "arena" };
			return str;
		}
This means that either the url must contain the word "arena" or the data must contain the word "arena". You said that you added #arena at the end of your URL, but it is highly possible that mixare ignores that. You could also change the matchers or add extra matchers.

If that does not work, then I suggest that you debug the following class: https://github.com/abduegal/mixare/blob/development/src/org/mixare/data/convert/DataConvertor.java
particularly looking at the attribute: dataProcessors and verify that it contains the ArenaProcessor. Look particulary on the outcome of line #63. If that returns null as value, then mixare will use the circle marker as default.

Please let me know if that was the issue. If that was not the issue, the please provide me with the json data and debug information from the previous steps. I could also help you by taking a look directly into your code and help you solve the problem that way. Is your project open source? or hosted on github?

Sincerely,
Abdullahi

Shahry

unread,
Dec 12, 2012, 1:03:47 PM12/12/12
to mixare-de...@googlegroups.com
Hi Abdullahi,

thank you for your kind reply.

It's very unbelievable but now it works and I really don't know why. I've left the project this morning and mixare loaded all the pois from my server: they didn't have object_url member at that moment; I launched it in the afternoon and it wasn't able to load any poi from my server any more. So I tried to add object_url  in my json objects and then it loaded the pictures I had chosen for the pois.
So, the trouble about pois icon it seems solved.

However, I still have some problems:

1) The first time I launch the app it starts in the right way. If I close it with back button and I relaunch it, it crashes with this error:

12-12 16:03:46.369: E/AndroidRuntime(4190): java.lang.RuntimeException: Unable to destroy activity {org.mixare/org.mixare.PluginLoaderActivity}: java.lang.IllegalArgumentException: Service not registered: org.mixare.plugin.connection.DataHandlerServiceConnection@4051d650
12-12 16:03:46.369: E/AndroidRuntime(4190): at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:2676)
12-12 16:03:46.369: E/AndroidRuntime(4190): at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:2694)
12-12 16:03:46.369: E/AndroidRuntime(4190): at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:2810)
12-12 16:03:46.369: E/AndroidRuntime(4190): at android.app.ActivityThread.access$1600(ActivityThread.java:117)
12-12 16:03:46.369: E/AndroidRuntime(4190): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
12-12 16:03:46.369: E/AndroidRuntime(4190): at android.os.Handler.dispatchMessage(Handler.java:99)
12-12 16:03:46.369: E/AndroidRuntime(4190): at android.os.Looper.loop(Looper.java:123)
12-12 16:03:46.369: E/AndroidRuntime(4190): at android.app.ActivityThread.main(ActivityThread.java:3729)
12-12 16:03:46.369: E/AndroidRuntime(4190): at java.lang.reflect.Method.invokeNative(Native Method)
12-12 16:03:46.369: E/AndroidRuntime(4190): at java.lang.reflect.Method.invoke(Method.java:507)
12-12 16:03:46.369: E/AndroidRuntime(4190): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:874)
12-12 16:03:46.369: E/AndroidRuntime(4190): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:632)
12-12 16:03:46.369: E/AndroidRuntime(4190): at dalvik.system.NativeStart.main(Native Method)
12-12 16:03:46.369: E/AndroidRuntime(4190): Caused by: java.lang.IllegalArgumentException: Service not registered: org.mixare.plugin.connection.DataHandlerServiceConnection@4051d650
12-12 16:03:46.369: E/AndroidRuntime(4190): at android.app.LoadedApk.forgetServiceDispatcher(LoadedApk.java:891)
12-12 16:03:46.369: E/AndroidRuntime(4190): at android.app.ContextImpl.unbindService(ContextImpl.java:912)
12-12 16:03:46.369: E/AndroidRuntime(4190): at android.content.ContextWrapper.unbindService(ContextWrapper.java:352)
12-12 16:03:46.369: E/AndroidRuntime(4190): at org.mixare.plugin.PluginLoader.unBindServices(PluginLoader.java:106)
12-12 16:03:46.369: E/AndroidRuntime(4190): at org.mixare.PluginLoaderActivity.onDestroy(PluginLoaderActivity.java:116)
12-12 16:03:46.369: E/AndroidRuntime(4190): at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:2663)

and it says "Unexpected interruption of application NameOfTheApplication (processorg.mixare). Retry." in a dialog on the smartphone.
So I press OK and if I launch the app again it starts correctly. It crashes and it works one after the other.

How can I solve it? ( I didn't change PluginLoaderActivity.java)

2) I need to open an activity with some poi details like a description, some web links, etc. ( I keep those details in the json object) when the user clicks on a POI instead of opening the url in the browser. 
I managed to open the activity due to the click but it doesn't set the extras contents. For example, I tried adding a description and a weburls string to the POI:
a) I changed ArenaProcessor adding the following lines:

     ma.setExtras("description", jo.getString("description"));
     ma.setExtras("webUrls", "provaweburls");

b) I modified ImageMarker adding

       @Override
public void setExtras(String name,String value)
{
if(name.equals("description"))
{
description=value;
Log.v("ImageMarker","Settata description: "+description);
}
               if(name.equals("webUrls"))
{
webUrls=value;
Log.v("ImageMarker","Settati weburls: "+webUrls);
}
}

and I added the same code also in PluginMarker where I declared another attribute called description because in fClick() method I create a new POIClickHandler(title,ID,description,webUrls,URL, active, txtLab, signMarker, cMarker) instead of the basic ClickHandler

where POIClickHandler is a class made by me that extends ClickHandler. Here is its method handleClick:

public boolean handleClick(float x, float y, MixContextInterface ctx, MixStateInterface state){
if(super.isClickValid(x, y)){
Log.v("POIClickHandler","handleClick: CLICK IS VALID");
Log.v("POIClickHandler","IDPOI: "+idPOI+" description: "+description+" webUrls"+webUrls);
return state.handleEvent(ctx, idPOI, title, description, webUrls);
}
return false;
}

The method state.handleEvent(ctx, idPOI, title, description, webUrls) works because I tested it with LocalMarker after I had updated MixContextInterface and MixStateInterface in the library.

The Log in handleClick inside POIClickHandler shows me that description and webUrls are NULL! So setExtras in ImageMarker and PluginMarker doesn't work.

Where did I miss? Is there a simpler way to add some fields to ImageMarker without changing files in the library?

3) I see the edge of the POI label sometimes red and sometimes white. What does it depend on?
   What is the clicks priority policy? What does it check in isClickValid method? 
   Sometimes my clicks on some pois are ignored and I can't understand why, if I relaunch the app it works again.

Thank you very much for your availability.

Shahry

Abdullahi Egal

unread,
Dec 12, 2012, 1:29:45 PM12/12/12
to mixare-de...@googlegroups.com
Hi Shahry,

See below for the reply (inline):
I think you can solve this by two ways:
1) Please check this post in stackoverflow: http://stackoverflow.com/questions/10986408/unable-to-destroy-activity-service-is-not-registered You could change the following line:
activity.unbindService((ServiceConnection) plugin.getPluginConnection());
To:
 activity.getApplicationContext().unbindService((ServiceConnection) plugin.getPluginConnection());

2) You could catch that exception by wrapping it in a try ... catch. But that would result in memory leaks so I do suggest the option above
I have done that in the past. Instead of opening a browser, I opened a custom activity that shows different information.
Instead of opening the default webview, it opens an activity and builds the objects (question with multiple choice answers).


3) I see the edge of the POI label sometimes red and sometimes white. What does it depend on?
   What is the clicks priority policy? What does it check in isClickValid method? 
   Sometimes my clicks on some pois are ignored and I can't understand why, if I relaunch the app it works again.

I am aware of that issue, but it only happens on some devices. I wasn't able to find the cause of that issue.
Could you please specify in which situation the label becomes red or white?

Shahry

unread,
Dec 12, 2012, 5:28:29 PM12/12/12
to mixare-de...@googlegroups.com
Hi Abdullahi, 

1) I tried with this line  activity.getApplicationContext().unbindService((ServiceConnection)pluginConnection); and also bindService that is activity.getApplicationContext().bindService(serviceIntent, (ServiceConnection)pluginType.getPluginConnection(),Context.BIND_AUTO_CREATE);
but it doesn't work as well.

I thought that I could directly put my own ArenaProcessor (modified to parse my json object) into org.mixare.data.convert package together with the other processor instead of using plugin and bind/unbind mechanism to avoid the fatal crash it causes.
If I wanted to try this way, where would I change the code? I'd like to use my own ArenaProcessor just for pois on my server.

2) Tomorrow I will analyze your code linked. Thanks a lot for sharing!

3) For the time being, I see red edges when lots of pois are put on top (4-5 pois, it doesn't happen with only two pois). I'm not sure it's the only case. I will let you know if it happens in different contexts.

Thank you again.
Shahry

Abdullahi Egal

unread,
Dec 12, 2012, 5:53:33 PM12/12/12
to mixare-de...@googlegroups.com
Hi Shahry,

1) Yes you could use the ArenaProcessor directly by bringing it under the org.mixare.data.convert package. 
Then all you have to do is adding it to the defaultdataprocessors: https://github.com/abduegal/mixare/blob/master/src/org/mixare/data/convert/DataConvertor.java
private void addDefaultDataProcessors(){
dataProcessors.add(new WikiDataProcessor());
dataProcessors.add(new TwitterDataProcessor());
dataProcessors.add(new OsmDataProcessor());
// Add your dataprocessor here: I.E dataprocessor.add(new ArenaDataProcessor());
}
The core mixare already contains an ImageMarker, so you probably don't have to move that. 
Finally you have to slightly modify your ArenaDataProcesor to use your core marker instead of the plugin marker.

2) Alright, good luck and let me know if that worked for you.

3) I think this issue only happens with the plugins, so if you are adding your plugin files to the core, then the issue might be fixed in your case.

Sincerely,
Abdullahi

Shahry

unread,
Dec 14, 2012, 7:54:34 AM12/14/12
to mixare-de...@googlegroups.com
Hi Abdullahi,

now I'm focusing on trouble number 1, I'll try 2) and 3) only when my ArenaProcessor works fine.

I tried to put ArenaProcessor in the org.mixare.data.convert package and add it as a default processor as you said, but it gave me an error because ArenaProcessor (taken from the plugin) extends PluginDataProcessor instead of extending DataHandler and implementing DataProcessor like others processors in the package. So I tried to modify ArenaProcessor to make it similar to others and I put ImageMarker class in org.mixare. So I changed load method in ArenaProcessor as you can see below: 

@Override
public List<Marker> load(String rawData, int taskId, int colour)
throws JSONException {
List<Marker> markers = new ArrayList<Marker>();
JSONObject root = convertToJSON(rawData);
JSONArray dataArray = root.getJSONArray("results");
int top = Math.min(MAX_JSON_OBJECTS, dataArray.length());

for (int i = 0; i < top; i++) {
JSONObject jo = dataArray.getJSONObject(i);
if (jo.has("title") && jo.has("lat") && jo.has("lng")
&& jo.has("elevation") && jo.has("description")) {

String link = null;

if (jo.has("has_detail_page")
&& jo.getInt("has_detail_page") != 0
&& jo.has("webpage"))
link = jo.getString("webpage");

Bitmap image = getBitmapFromURL(jo.getString("object_url"));
ImageMarker ma = new ImageMarker(jo.getInt("id"),
HtmlUnescape.unescapeHTML(jo.getString("title"), 0),
jo.getDouble("lat"), jo.getDouble("lng"),
jo.getDouble("elevation"), link, taskId, colour,jo.getString("description"),"provaUrls");
ma.setExtras("bitmap", new ParcelableProperty(
"android.graphics.Bitmap", image));
markers.add(ma);
}
}
return markers;
}

Now it loads my markers but with white circle again! :(

Shahry

unread,
Dec 14, 2012, 8:10:41 AM12/14/12
to mixare-de...@googlegroups.com
I've just solved leaving what I did and changing the draw method inside ImageMarker. Now I can see icons without any plugins!

I'll try the other solutions 2) and 3) later, then I'll let you know the results.

Do you know how can I pause or even stop updates (the downloads of the pois from the selected servers) when MixView is running?
I need to do that because I have to send a file to my server in some cases while the user is using MixView activity. I do it with an asynctask that runs in background but I want to pause or stop pois updates because they slow my sending down too much.

Thanks a lot!
Shahry

Abdullahi Egal

unread,
Dec 14, 2012, 8:41:54 AM12/14/12
to mixare-de...@googlegroups.com
I think you can stop the downloads by calling the switchOff function of the downloadmanager.

Shahry

unread,
Dec 14, 2012, 7:14:47 PM12/14/12
to mixare-de...@googlegroups.com
Hi Abdullahi,

thanks to your precious help I solved pois details visualization.

The only remain issue is stopping updates. I tried to invoke switchOff but nothing changed. 
In particular, I still see those logs:

12-15 01:01:31.319: V/Mixare(20808): <!>org.mixare.data.DataHandler 46<!> Marker before: 0
12-15 01:01:31.329: D/Mixare(20808): <!>org.mixare.data.DataHandler 52<!> Marker count: 6
...
...

I found them inside the addMarkers method in DataHandler and using the "Open call hierarchy" tool I could notice that it's called from the draw method inside DataView which is called in turn from @Override onDraw (Canvas canvas) inside MixView. onDraw is automatically called, isn't it? So I can't go on the hierarchy over onDraw to understand which line calls this chain of methods.

What do you think about it?

Thank you!
Shahry

Didzis Brīvkalns

unread,
May 30, 2017, 10:20:04 AM5/30/17
to mixare-development
Hi Shahry,

are you finding solution to the problem ( Marker before: 0, Marker count: 6)?
Reply all
Reply to author
Forward
0 new messages