I'm having some trouble with integrating some markers in a map with OsmDroid. In fact, i'm not even in my App Project.
I'm at the prerequesite : the binding project.
I need to implement some functions of osmbonuspack_v5.1 wich is not in the v3.4.
I adapted the Metadata.xml to work with these new jars (i'm using osmdroid v4.3 / osmbonuspack v5.1 and slf4j v1.6.1) but there are still 2 errors who make me crazy.
How to implement these 2 class (CleaningTask & DownloadingTask) with the osmbonuspack_v5.1 ?
Here are the details :
\Projects\OsmDroid\OsmDroid\obj\Debug\generated\src\Org.Osmdroid.Bonuspack.Cachemanager.CacheManager.cs(36,36):
Error CS0534:
'Org.Osmdroid.Bonuspack.Cachemanager.CacheManager.CleaningTask'
n'implémente pas le membre abstract hérité
'Android.OS.AsyncTask.DoInBackground(params Java.Lang.Object[])'
(CS0534) (OsmDroid)
\Projects\OsmDroid\OsmDroid\obj\Debug\generated\src\Org.Osmdroid.Bonuspack.Cachemanager.CacheManager.cs(36,36):
Error CS0534:
'Org.Osmdroid.Bonuspack.Cachemanager.CacheManager.DownloadingTask'
n'implémente pas le membre abstract hérité
'Android.OS.AsyncTask.DoInBackground(params Java.Lang.Object[])'
(CS0534) (OsmDroid)
Here is my Metadata.xml :
<metadata>
<!-- fixup the namespaces, notice that we have to do one for each namespace. -->
<attr path="/api/package[#name='org.osmdroid']" name="managedName">OsmDroid</attr>
<attr path="/api/package[#name='org.osmdroid.api']" name="managedName">OsmDroid.Api</attr>
<attr path="/api/package[#name='org.osmdroid.contributor']" name="managedName">OsmDroid.Contributor</attr>
<attr path="/api/package[#name='org.osmdroid.contributor.util']" name="managedName">OsmDroid.Contributor.Util</attr>
<attr path="/api/package[#name='org.osmdroid.contributor.util.constants']" name="managedName">OsmDroid.Util.Constants</attr>
<attr path="/api/package[#name='org.osmdroid.events']" name="managedName">OsmDroid.Events</attr>
<attr path="/api/package[#name='org.osmdroid.tileprovider']" name="managedName">OsmDroid.TileProvider</attr>
<attr path="/api/package[#name='org.osmdroid.tileprovider.constants']" name="managedName">OsmDroid.TileProvider.Constants</attr>
<attr path="/api/package[#name='org.osmdroid.tileprovider.modules']" name="managedName">OsmDroid.TileProvider.Modules</attr>
<attr path="/api/package[#name='org.osmdroid.tileprovider.tilesource']" name="managedName">OsmDroid.TileProvider.TileSource</attr>
<attr path="/api/package[#name='org.osmdroid.tileprovider.util']" name="managedName">OsmDroid.TileProvider.Util</attr>
<attr path="/api/package[#name='org.osmdroid.util']" name="managedName">OsmDroid.Util</attr>
<attr path="/api/package[#name='org.osmdroid.views']" name="managedName">OsmDroid.Views</attr>
<attr path="/api/package[#name='org.osmdroid.views.overlay']" name="managedName">OsmDroid.Views.Overlay</attr>
<attr path="/api/package[#name='org.osmdroid.views.util.constants']" name="managedName">OsmDroid.Views.Util.Constants</attr>
<attr path="/api/package[#name='org.osmdroid.bonuspack.overlays']" name="managedName">OsmDroid.Bonuspack.Overlays</attr>
<attr path="/api/package[#name='org.osmdroid.bonuspack.routing']" name="managedName">OsmDroid.Bonuspack.Routing</attr>
<attr path="/api/package[#name='org.osmdroid.bonuspack.overlays.marker']" name="managedName">OsmDroid.Bonuspack.Overlays.Marker</attr>
<!-- different scoping rules in .NET, so we make these public -->
<attr path="/api/package[#name='org.osmdroid.tileprovider.modules']/class[#name='MapTileModuleProviderBase.TileLoader']" name="visibility">public</attr>
<attr path="/api/package[#name='org.osmdroid.tileprovider.modules']/class[#name='MapTileModuleProviderBase.TileLoader']/method[#name='loadTile']" name="visibility">public</attr>
<attr path="/api/package[#name='org.osmdroid.tileprovider']/class[#name='MapTileProviderBase.ScaleTileLooper']/method[#name='handleTile']" name="visibility">public</attr>
<attr path="/api/package[#name='org.osmdroid.tileprovider']/class[#name='MapTileProviderBase.ZoomInTileLooper']/method[#name='handleTile']" name="visibility">public</attr>
<attr path="/api/package[#name='org.osmdroid.tileprovider']/class[#name='MapTileProviderBase.ZoomOutTileLooper']/method[#name='handleTile']" name="visibility">public</attr>
<!-- Draw() seems to be public for android so we need to be consistent about it. C# doesn't like to mix visibility during inheritance. -->
<attr path="/api/package[#name='org.osmdroid.views.overlay']/class[#name='Overlay']/method[#name='draw']" name="visibility">public</attr>
<attr path="/api/package[#name='org.osmdroid.views.overlay']/class[#name='TilesOverlay']/method[#name='draw']" name="visibility">public</attr>
<attr path="/api/package[#name='org.osmdroid.views.overlay']/class[#name='PathOverlay']/method[#name='draw']" name="visibility">public</attr>
<!-- added for 4.2 jar -->
<attr path="/api/package[#name='org.osmdroid.views.overlay.compass']/class[#name='CompassOverlay']/method[#name='draw']" name="visibility">public</attr>
<attr path="/api/package[#name='org.osmdroid.bonuspack.clustering']/class[#name='MarkerClusterer']/method[#name='draw']" name="visibility">public</attr>
<attr path="/api/package[#name='org.osmdroid.bonuspack.overlays']/class[#name='FolderOverlay']/method[#name='draw']" name="visibility">public</attr>
<attr path="/api/package[#name='org.osmdroid.bonuspack.overlays']/class[#name='GroundOverlay']/method[#name='draw']" name="visibility">public</attr>
<attr path="/api/package[#name='org.osmdroid.bonuspack.overlays']/class[#name='Polygon']/method[#name='draw']" name="visibility">public</attr>
<attr path="/api/package[#name='org.osmdroid.bonuspack.overlays']/class[#name='Polyline']/method[#name='draw']" name="visibility">public</attr>
<attr path="/api/package[#name='org.osmdroid.views.overlay.mylocation']/class[#name='MyLocationNewOverlay']/method[#name='draw']" name="visibility">public</attr>
<attr path="/api/package[#name='org.osmdroid.views.overlay']/class[#name='ItemizedOverlay']/method[#name='draw']" name="visibility">public</attr>
<attr path="/api/package[#name='org.osmdroid.views.overlay']/class[#name='NonAcceleratedOverlay']/method[#name='draw']" name="visibility">public</attr>
<attr path="/api/package[#name='org.osmdroid.views.overlay']/class[#name='ScaleBarOverlay']/method[#name='draw']" name="visibility">public</attr>
<remove-node path="/api/package[#name='org.osmdroid.tileprovider.tilesource']/class[#name='CloudmadeTileSource']" />
<!-- Return IMapController in MapView.Controller so that we match IMapView. -->
<attr path="/api/package[#name='org.osmdroid.views']/class[#name='MapView']/method[#name='getController']" name="managedReturn">
OsmDroid.Api.IMapController
</attr>
<!-- We need to rename class MapView.Projection because it conflicts with a property of the same name -->
<attr path="/api/package[#name='org.osmdroid.views']/class[#name='MapView.Projection']" name="managedName">
MapView.ProjectionImpl
</attr>
<!-- Change return type to match IMapView.Projection property return type -->
<attr path="/api/package[#name='org.osmdroid.views']/class[#name='MapView']/method[#name='getProjection']" name="managedReturn">
OsmDroid.Api.IProjection
</attr>
<attr path="/api/package[#name='org.osmdroid.views.overlay']/class[#name='OverlayManager']/method[#name='get' and count(parameter)=1 and parameter[1][#type='int']]" name="managedReturn"> Java.Lang.Object
</attr>
<!-- For update 5.1 but doesn't work
<attr path="/api/package[#name='org.osmdroid.bonuspack.cachemanager']/class[#name='CacheManager.CleaningTask']/method[#name='DoInBackground' and count(parameter)=1 and parameter[1][#type='int']]" name="managedReturn">
</attr>
Java.Lang.
<attr path="/api/package[#name='org.osmdroid.bonuspack.cachemanager']/class[#name='CacheManager.DownloadingTask']/method[#name='DoInBackground' and count(parameter)=1 and parameter[1][#type='int']]" name="managedReturn">
</attr>
-->
<!-- fix up some parameter names -->
<attr path="/api/package[#name='org.osmdroid.views']/class[#name='MapView']/method[#name='setTileSource']/parameter[#name='p0']" name="name">tileSource</attr>
<attr path="/api/package[#name='org.osmdroid.views']/class[#name='MapView']/method[#name='setBuiltInZoomControls']/parameter[#name='p0']" name="name">show</attr>
<attr path="/api/package[#name='org.osmdroid.api']/interface[#name='IMapController']/method[#name='setZoom']/parameter[#name='p0']" name="name">zoomLevel</attr>
<attr path="/api/package[#name='org.osmdroid.api']/interface[#name='IMapController']/method[#name='setCenter']/parameter[#name='p0']" name="name">centreOfMap</attr>
<attr path="/api/package[#name='org.osmdroid.bonuspack.routing']/class[#name='RoadLink']" name="visibility">public</attr>
<attr path="/api/package[#name='org.osmdroid.bonuspack.overlays']/class[#name='MapEventsOverlay']/method[#name='draw']" name="visibility">public</attr>
</metadata>
And here the error's reference :
// Metadata.xml XPath class reference: path="/api/package[#name='org.osmdroid.bonuspack.cachemanager']/class[#name='CacheManager.CleaningTask']"
[global::Android.Runtime.Register ("org/osmdroid/bonuspack/cachemanager/CacheManager$CleaningTask", DoNotGenerateAcw=true)]
protected internal partial class CleaningTask : global::Org.Osmdroid.Bonuspack.Cachemanager.CacheManager.CacheManagerTask {
internal static new IntPtr java_class_handle;
internal static new IntPtr class_ref {
get {
return JNIEnv.FindClass ("org/osmdroid/bonuspack/cachemanager/CacheManager$CleaningTask", ref java_class_handle);
}
}
and
// Metadata.xml XPath class reference: path="/api/package[#name='org.osmdroid.bonuspack.cachemanager']/class[#name='CacheManager.DownloadingTask']"
[global::Android.Runtime.Register ("org/osmdroid/bonuspack/cachemanager/CacheManager$DownloadingTask", DoNotGenerateAcw=true)]
protected internal partial class DownloadingTask : global::Org.Osmdroid.Bonuspack.Cachemanager.CacheManager.CacheManagerTask {
internal static new IntPtr java_class_handle;
internal static new IntPtr class_ref {
get {
return JNIEnv.FindClass ("org/osmdroid/bonuspack/cachemanager/CacheManager$DownloadingTask", ref java_class_handle);
}
}
I already followed the tutorial on http://developer.xamarin.com/guides/android/advanced_topics/java_integration_overview/binding_a_java_library_%28.jar%29/ but i don't understand what to do with my Java.Lang.Object.
Thank's in advance, i think it's pretty simple, but I definitely didn't get it.
Related
First of all, i know that there plenty of post about the issue and i think i read them all. If someone ask i will attach them for approve :)
I have an issue with attrs. The issue is that sometimes i see programmers using it when they create a custom view but sometimes i see that they are used also when building a theme.
For example:
<declare-styleable name="Main_Theme">
<attr name="background" format="reference" />
<attr name="backgroundCard" format="reference" />
<attr name="secondaryTextColor" format="reference" />
<attr name="primaryTextColor" format="reference" />
<attr name="primaryColor" format="reference" />
<attr name="secondaryColor1" format="reference" />
<attr name="secondaryColor2" format="reference" />
<attr name="secondaryColor3" format="reference" />
<attr name="dividerColor" format="reference" />
and then they creates a theme using it.
For example:
<item name="background">#color/dark_theme_background</item>
<item name="backgroundCard">#color/dark_theme_card_background</item>
<item name="secondaryTextColor">#color/dark_theme_scores_new</item>
<item name="primaryTextColor">#color/dark_theme_primary_text_color</item>
<item name="primaryColor">#color/dark_theme_primary_color</item>
<item name="secondaryColor1">#color/dark_theme_secondary_1_color</item>
<item name="secondaryColor2">#color/dark_theme_secondary_2_color</item>
<item name="secondaryColor3">#color/dark_theme_secondary_3_color</item>
<item name="dividerColor">#color/dark_theme_divider_color</item>
Then i saw them using those items as values for attributes in layout activity xml file
So i really can't understand the variety use of attrs.
I hope someone can help me to understand cause i feeling very confused
attr is used when make custom view with custom attribute.
If you define attr, you can use it in xml file.
Normal View use default attribute such as width, height, background, text etc.
So you can use it in xml file.
<TextView
android:width="match_parent"
android:height="wrap_content"
android:background="#color/white"
android:text="#string/app_name" />
But there is no attribute for your custom view.
If your custom view needs dividerColor attribute, you can't use it android:dividerColor as following.
<YourCustomView
android:width="match_parent"
android:height="wrap_content"
android:background="#color/white"
android:dividerColor="#color/black" /> // it caused compile error.
So you need your attribute for use in xml file.
For it, you need declare attrs in attrs.xml file. (xml file name can change.)
<declare-styleable name="Main_Theme">
<attr name="dividerColor" format="reference" />
</declare-styleable>
And then you can use new attribute in view xml file.
<YourCustomView
xmlns:app="http://schemas.android.com/apk/res-auto" // need define app
android:width="match_parent"
android:height="wrap_content"
android:background="#color/white"
app:dividerColor="#color/black" /> // it's works
PS: You need to additional code for use custom attr in YourCustomView class file.
TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.Main_Theme);
dividerColor = ta.getColor(R.styleable.MainTheme_divider_color, Color.WHITE);
Attr represents an attribute in an element. Simply put attrs are allowable quantities that are defined in a schema associated with a document.
Whenever we create a custom view we don't want the view to accept every possible value under the sky, so we define a few values that can be accepted by the view using the attr interface. these attributes are defined using declare-stylable that enables you to define attributes for custom views.for example:
<resources>
<declare-styleable name="PieChart">
<attr name="showText" format="boolean" />
<attr name="labelPosition" format="enum">
<enum name="left" value="0"/>
<enum name="right" value="1"/>
</attr>
</declare-styleable>
</resources>
this custom view accepts showText and label attributes. the showText accepts a boolean value and the labelPosition accepts values: left and right. like the example below
<PieChart
showText="false"
labelPosition="left"/>
similarly in themes we need to define certain attributes that can be used inside the theme for example if we create 2 themes and want to define a different primary color that will be used by the app when using either theme. we first declare the color attr like so in the attrs.xml:
<declare-styleable name="Main_Theme">
<attr name="color_primary" format="color" />
</declare-stylable>
and then inside the styles.xml we define the values for the color_primary attr for the 2 themes
<style name="theme_one">
<item name="color_primary">#ff0000</item> // red
</style>
<style name="theme_two">
<item name="color_primary">#00ff00</item> // green
</style>
this value could then be used in layout files like so: ?attr/color_primary
similarly attr could be used to define a wide range of things. an attr element itself has 2 attributes the name with which you refer it in other parts of the code and the format which could be color, boolean, dimension, float etc. for example enums could be defined as:
<attr name="some_enum_attr">
<enum name="value_one" value="1" />
<enum name="value_two" value="2" />
</attr>
Goodday, I am getting this error when i decide to build my android app on Android Studio. Please how do i fix
C:\Users\HP-PC.gradle\caches\transforms-2\files-2.1\dc1436142102318e0c7f87330e8cc57a\jetified-pinpad-1.0.1\res\values\values.xml:7:5-161: AAPT: error: resource attr/foreground (aka com.cptvstudio.tv:attr/foreground) not found.
C:\Users\HP-PC.gradle\caches\transforms-2\files-2.1\dc1436142102318e0c7f87330e8cc57a\jetified-pinpad-1.0.1\res\values\values.xml:7:5-161: AAPT: error: resource attr/foregroundGravity (aka com.cptvstudio.tv:attr/foregroundGravity) not found.
I do not know where the error might be coming from. Below is my values.xml code if it might help
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="pstck_pinpad_default_button_textcolor">#DFE1E2</color>
<color name="pstck_pinpad_default_pin_indicator_empty_color">#E0E0E0</color>
<color name="pstck_pinpad_default_pin_indicator_filled_color">#C4C4C4</color>
<color name="pstck_pinpad_default_prompt_textcolor">#D0D0D0</color>
<declare-styleable name="ForegroundView"><attr name="foreground"/><attr name="foregroundInsidePadding"/><attr name="foregroundGravity"/></declare-styleable>
<declare-styleable name="PinPadView"><attr format="boolean" name="place_digits_randomly"/><attr format="boolean" name="auto_submit"/><attr format="boolean" name="vibrate_on_incomplete_submit"/><attr format="color" name="pin_indicator_filled_color"/><attr format="color" name="pin_indicator_empty_color"/><attr format="dimension" name="pin_indicator_size"/><attr format="dimension" name="pin_indicator_stroke_width"/><attr format="dimension" name="pin_indicator_spacing"/><attr format="integer" name="pin_length"/><attr format="string" name="prompt_text"/><attr format="color" name="prompt_textcolor"/><attr format="dimension" name="prompt_textsize"/><attr format="dimension" name="prompt_text_padding"/><attr format="dimension" name="prompt_text_paddingTop"/><attr format="dimension" name="prompt_text_paddingBottom"/><attr format="color" name="button_textcolor"/><attr format="dimension" name="button_numeric_textsize"/><attr format="dimension" name="button_alpha_textsize"/><attr format="string" name="button_text_numeric"/><attr format="string" name="button_text_alpha"/><attr format="reference" name="button_drawable"/><attr format="dimension" name="button_drawable_size"/></declare-styleable>
<dimen name="pstck_pinpad__default_indicator_height">64dp</dimen>
<dimen name="pstck_pinpad__default_prompt_padding">24dp</dimen>
<dimen name="pstck_pinpad__default_prompt_paddingBottom">16dp</dimen>
<dimen name="pstck_pinpad__default_prompt_paddingTop">16dp</dimen>
<string name="pstck_pinpad__app_name">pinpad</string>
<string name="pstck_pinpad__num_0">0</string>
<string name="pstck_pinpad__num_1">1</string>
<string name="pstck_pinpad__num_2">2</string>
<string name="pstck_pinpad__num_3">3</string>
<string name="pstck_pinpad__num_4">4</string>
<string name="pstck_pinpad__num_5">5</string>
<string name="pstck_pinpad__num_6">6</string>
<string name="pstck_pinpad__num_7">7</string>
<string name="pstck_pinpad__num_8">8</string>
<string name="pstck_pinpad__num_9">9</string>
<style name="Widget"/>
<style name="Widget.PinPad">
<item name="android:layout_width">0dp</item>
<item name="android:layout_height">match_parent</item>
<item name="button_textcolor">#color/pstck_pinpad_default_button_textcolor</item>
<item name="prompt_textcolor">#color/pstck_pinpad_default_prompt_textcolor</item>
<item name="pin_indicator_filled_color">#color/pstck_pinpad_default_pin_indicator_filled_color</item>
<item name="pin_indicator_empty_color">#color/pstck_pinpad_default_pin_indicator_empty_color</item>
<item name="android:gravity">center</item>
</style>
</resources>
check your attr file again <attr name="foreground"/> and <attr name="foregroundGravity"/> not defined in attr file
I am using custom font style for that created custom xml attributes.already used enum in declared style attributes but still no success. Its seems some messed up and facing the below-mentioned issue.
Facing this issue:
Error:(555, 5) error: expected enum but got (raw string) bold.
attrs.xml file is
<declare-styleable name="CustomTextView">
<attr name="font_name" format="string" />
<attr name="font_style" format="enum">
<enum name="normal" value="0" />
<enum name="bold" value="1" />
<enum name="italic" value="2" />
</attr>
</declare-styleable>
I created styles for Textview.
<style name="STextView">
<item name="android:textColor">#color/colorBlack</item>
<item name="font_style">bold</item>
</style>
It was working earlier recently updated compile sdk version in build.gradle to 27 and stated facing this issue.
Change
<item name="font_style">bold</item>
to
<item name="font_style">#bold</item>
I've been looking to the Google iosched 2014 app to ensure im following correct design patterns for material design and specifically for pre-L devices with the support v7 library and appcompat v21.
In order to use the material design theme you must inherit from "Theme.AppCompat", but i can't seem to understand or find any documentation of the styles attributes in the link below. They aren't under the "android:" namespace and i dont seem to be able to use them myself.
https://github.com/google/iosched/blob/master/android/src/main/res/values/styles.xml#L32-L38
<item name="actionBarIconColor">#fff</item>
<item name="actionBarInsetStart">#dimen/keyline_2</item>
<item name="homeAsUpIndicator">#drawable/ic_up</item>
<item name="spinnerBarInsetStart">#dimen/keyline_2_minus_16dp</item>
<item name="popupItemBackground">?android:selectableItemBackground</item>
<item name="photoItemForeground">?android:selectableItemBackground</item>
<item name="photoItemForegroundBorderless">?android:selectableItemBackground</item
I'm barely familiar with custom attributes in /attr folder, but how can i find where they are used.
<declare-styleable name="BaseTheme">
<attr name="actionBarIconColor" format="color" />
<attr name="actionBarInsetStart" format="dimension" />
<attr name="spinnerBarInsetStart" format="dimension" />
<attr name="popupItemBackground" format="reference" />
<attr name="photoItemForeground" format="reference" />
<attr name="photoItemForegroundBorderless" format="reference" />
</declare-styleable>
I don't understand how this custom set of attributes is being used and its bugging me. Can anyone explain to me whats going on here and how they attributes are being used?
Here's a search of the repository that shows some instances of where they are used:
https://github.com/google/iosched/search?utf8=%E2%9C%93&q=photoItemForeground
This is my very first attempt at including ads in my app. I have read the online documentation and read it word for word. Now, the only part I don't get is how to actually request ads and to add it into my app.
AdView adView = (AdView)findViewById(R.id.ad);
That seems to work so far so good.
Anything else I do will just force close.
For example adding this line:
adView.setAdListener(this);
I have implemented AdListener to the Activity.
By the way, when I hover over the imported classes:
import com.admob.android.ads.AdView;
or other similar classes, it says: Note: This element neither has attached source nor attached Javadoc and hence no Javadoc could be found.
Is that supposed to be correct?
It's tough to say for sure without seeing your code and your layout, but here are some things you might want to check:
1) The AdMobActivity is declared in your AndroidManifest:
<activity android:name="com.admob.android.ads.AdMobActivity"
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"
android:configChanges="orientation|keyboard|keyboardHidden" />
2) You request the INTERNET permission in your AndroidManifest:
<uses-permission android:name="android.permission.INTERNET" />
3) Your attrs.xml file contains the necessary styles:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="com.admob.android.ads.AdView">
<attr name="backgroundColor" format="color" />
<attr name="primaryTextColor" format="color" />
<attr name="secondaryTextColor" format="color" />
<attr name="keywords" format="string" />
<attr name="refreshInterval" format="integer" />
</declare-styleable>
</resources>
4) Your AdView is included in your layout:
<com.admob.android.ads.AdView
android:id="#+id/ad"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
myapp:backgroundColor="#000000"
myapp:primaryTextColor="#FFFFFF"
myapp:secondaryTextColor="#CCCCCC"
/>
5) Your AdView is being found properly:
AdView adView = (AdView)findViewById(R.id.ad);
if (adView == null) {
Log.e(TAG, "AdView not found!");
}