I try to bind BugSense 3.0.5 to MonoDroid. I create a new Java Binding Library project, add the bugsense3.0.5.jar to the Jars-folder. I build it, and get the following error:
'Crash': member names cannot be the same as their enclosing type
The auto generate code:
[global::Android.Runtime.Register ("com/bugsense/trace/models/Crash", DoNotGenerateAcw=true)]
public partial class Crash : global::Java.Lang.Object, global::Java.IO.ISerializable {
[Register ("CRASH")]
public const int Crash = (int) 1;
So I need to rename the global variable "Crash" in the Metadata.xml- but how do I do that?
I have try:
<attr path="/api/package[#name='com.bugsense.trace.models']/class[#name='Crash']/field[#name='Crash']" name="managedName">mCrash</attr>
But it fails: matched no nodes
Fixed it renaming the class instead
<attr path="/api/package[#name='com.bugsense.trace.models']/class[#name='Crash']]" name="managedName">Crashed</attr>
You should always look for original fields name in java.
As i know it is lowerCamelCase. And it is probably hidden into setter/getter so you should search for /method[#name='getCrash']
Related
Im trying to use the Genexus Extensions SDK to place buttons on the IDE, in this case, i want to place it in the "context" menu, avaliable only in objects of type "Webpanel/Webcomponent" and "Transaction", Just like WorkWithPlus does here:
So far, digging up into the avaliable documentation, i've noticed that you need tu put the context type string into the xml tag and the GUID of the package that you're aiming to add the menu item, such as below in GeneXusPackage.package:
The Context ID above will add the item into the "Folder View" Context.
My questions:
Where can I find a list with all the possible ID Context strings?
What is that package attribute for, where can i get it's possible values?
I am using the SDK for Genexus 16 U11
I'm sorry to say that there is no extensive list of all the menus available. I'd never thought of it until now, and I see how it could be useful, so we'll definitely consider making it part of the SDK so that any package implementor may use it for reference.
In the meantime, in order to add a new command in the context menu you mentioned, you have to add it to the command group that is listed as part of that menu. That group is KBObjectGrp which is provided by the core shell package whose id is 98121D96-A7D8-468b-9310-B1F468F812AE.
First define your command in your .package file inside a Commands section:
<Commands>
<CommandDefinition id='MyCommand' context='selection'/>
</Commands>
Then add it to the KBObjectGrp mentioned earlier.
<Groups>
<Group refid='KBObjectGrp' package='98121D96-A7D8-468b-9310-B1F468F812AE'>
<Command refid='MyCommand' />
</Group>
</Groups>
Then in order to make your command available only to the objects you said before, you have to code a query handler for the command, that will rule when the command is enabled, disabled, or not visible at all. You can do that in the Initialize method of your package class.
public override void Initialize(IGxServiceProvider services)
{
base.Initialize(services);
CommandKey myCmdKey = new CommandKey(Id, "MyCommand");
AddCommand(myCmdKey, ExecMyCommand, QueryMyCommand);
}
private bool QueryMyCommand(CommandData data, ref CommandStatus status)
{
var selection = KBObjectSelectionHelper.TryGetKBObjectsFrom(data.Context).ToList();
status.Visible(selection.Count > 0 && selection.All(obj => obj.Type == ObjClass.Transaction || obj.Type == ObjClass.WebPanel));
return true;
}
private bool ExecMyCommand(CommandData data)
{
// Your command here
return true;
}
I'm using some helper classes here in order to get the objects from the selection, and then a class named ObjClass which exposes the guid of the most common object types. If you feel something isn't clear enough, don't hesitate to reach out.
Decompiling the Genexus dll and looking for the resource called package, you can infer what the names are.
It's cumbersome but it works
I'm just trying to use android-annotation. When I start another Activity, an empty activity showed up.
I check this to find that the #EActivity generate the subclass of XXActivity named XXActivity_. So I try to code
mIntent = new Intent(this, XXActivity_.class);
But eclipse shows error that XXActivity_ cannot be resolved to a type. I don't know when the XX_ is generated.
I have add the jar, declare the XX_ in the AndroidManifest.xml. How to make eclipse generate the XX_ class?
you could start activity using annotations like this
first you should write your activities on the manifest file with '_' after that you have two activities you want to go from one to another you could use this :
CarDetailActivity_.intent(CarSaleListActivity.this).start();
with this you will go the CarDetailActivity on the other hand if you want to pass message to the other activity you will use this
CarDetailActivity_.intent(CarSaleListActivity.this).myMessage("arrived with android annotations").start();
and in this case you should define this on the CarDetailActivity
#Extra
String myMessage;
and you could use this message on CarDetailActivity like this on
#AfterViews
public void showMessage(){
Toast.makeText(this,myMessage,Toast.LENGTH_SHORT).show();
}
Note : CarDetailActivity should be #EActivity to make this work
Blockquote
I wish to have the sub-classes of a super-class "registered" by an arbitrary name - whenever I declare a sub-class I wish to also have it entered into the super-class.sub Map.
Is there any way to accomplish this outside of main()?
// base class
class Mineral{
final String formula;
static Map<String,Mineral> sub = {}
Mineral( this.formula );
}
// sub class - declare and register
class Mica extends Mineral{
Mica( String formula ) : super( formula );
}
Mineral.sub['mica'] = Mica; // oops!
when I run this, I get
Error: line 10 pos 1: unexpected token 'Mineral' Mineral.sub['mica'] = Mica;
assuming that executable code is not allowed outside main().
cannot put within the super-class since other sub-classes may declared later, outside the library.
Dart has no way to run code as part of a library being loaded.
Executable code can only be put inside methods, or in field initializers, and static field initializers are lazy so they won't execute any code until you try to read them.
This is done to ensure quick startup - a Dart program doesn't have to execute any code before starting the main library's "main" method.
So, no, there is no way to initialize something that isn't constant before main is called.
Either
Mineral.sub['mica'] = new Mica();
or
static Map<String,Type> sub = {};
When you assign Mica you assign the Type Mica. new Mica() is an instance of Mica that is of the kind Mineral and can be assigned to the map you declared.
edit
Maybe you want to initialize the sub map:
static Map<String,Mineral> sub = {'mica': new Mica()};
hint: the semicolon is missing in this line in your question.
I am trying to use NineOldAndroids to enable backwards compatibility with pre-3.x devices, but I am encountering the following build error:
.../NineOldAndroids/obj/Debug/generated/src/Com.Nineoldandroids.Animation.AnimatorSet.cs(83,83):
Error CS0508:
Com.Nineoldandroids.Animation.AnimatorSet.SetDuration(long)': return
type must beCom.Nineoldandroids.Animation.Animator' to match
overridden member
`Com.Nineoldandroids.Animation.Animator.SetDuration(long)' (CS0508)
(NineOldAndroids)
but the signature in generated code looks like this:
public override global::Com.Nineoldandroids.Animation.AnimatorSet SetDuration (long p0)
and the class signature of AnimatorSet looks like this:
public sealed partial class AnimatorSet : global::Com.Nineoldandroids.Animation.Animator {
The problem is, since AnimatorSet is inherited from Animator, I'm not sure why it should be a problem.
Are there any examples of binding NineOldAndroids for MonoDroid that you're aware of or know how to fix this?
These error messages are because C# doesn't support Covariant Return Types while Java ≥1.5 does.
Add these lines to Transforms/Metadata.xml:
<attr path="/api/package/class[#name='AnimatorSet']/method[#name='setDuration']" name="managedReturn">Com.Nineoldandroids.Animation.Animator</attr>
<attr path="/api/package/class[#name='ValueAnimator']/method[#name='setDuration']" name="managedReturn">Com.Nineoldandroids.Animation.Animator</attr>
I'm following the spinner from monodroid tutorial. But encountered problem on the resource.
It cannot lookup the SimpleSpinnerItem & SimpleSpinnerDropDownItem on VS 2010.
Am I missing something?
Edit: Create a partial class to register android runtime as per jonp
public partial class Resource
{
public partial class Layout
{
[Register("simple_spinner_dropdown_item")]
public const int SimpleSpinnerDropDownItem = 17367049;
[Register("simple_spinner_item")]
public const int SimpleSpinnerItem = 17367048;
}
}
Edit 2: Tried the global resource
Edit 3: Conflict on my project namespace
I already identified why the const cannot be recognize. It's because of my namespace projectname.Android, it's being duplicated. When I changed it to projectname.AndroidMobile the global resource is there.
See the conflict below.
Also, to avoid the conflict just use the global:: as per jonp
You need to qualify the class, as there are two Resource types: one local to your project (Your.Namespace.Resource, located in Resource.designer.cs), and global::Android.Resource. You need to use global::Android.Resource.Layout.SimpleSpinnerItem.