How to switch view using Intent?

Hi,

As I read here: https://developer.android.com/training/basics/firstapp/starting-activity.html

How to switch to other view using Intent in Silver with Fire? Here’s what I did which failed…

It should be easy, but I’m stucked for almost an hour. :grinning:

Any hints?

Thank you.

-Bee

Add the full namespace. there’s a local Intent property that hides the Intent class.

Thanks, logged as bugs://77951 (to improve the messaging)

I change the red line into:

let intent = android.content.Intent(self, ContentActivity.Class)

And noe the error points to the Class with message “no such static member”. I changed it to various possible values without luck.

Any hints?

.Class is Java language syntax. dynamicType(ContentActivity) is the correct Swift syntax for the same thing.

1 Like

Thank you. It works now. There are many things still need to be learned, both on Android APIs and how to call them from Silver. I had no clue that .Class property has to be replaced by dynamicType method. Is there any documentation for this kind of things? :blush:

Swift is documented here: https://developer.apple.com/swift/resources/

I’ve read most of them. AFAIR, there’s no mention about Android/Java .Class should be replaced by .dynamicType in there. :grinning: It’s not Swift that becomes the problem. It’s about how to “convert” Java/Android code into Silver.

Well, yes, the Swift documentation is not a “how java syntax maps to swift” document. i bet they don’t tell you to use “:” instead of “extends”, either, they just tel you that “:” is why you use to specify the ancestor, Same thing for this.

to do that, you need to know what the code means that you ar trying to convert (.Class in java means, “gimme the type for this thing”), and you need to know what the corresponding Swift syntax is, yes.

bugs://77951 got closed with status fixed.