Launching Activity from Overlay onTap

by jgostylo » Wed, 11 Feb 2009 02:22:29 GMT


Sponsored Links
 I am wondering if I am going about this problem the correct way.

I am making an app that places overlays on top of google maps.  When
you click on the overlay it should launch a dialog type window that
will give you options on what to do with that overlay.

Currently the method I am trying to use is to Override onTap():

Intent myIntent = new Intent(context, MyActivity.class);
myIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(myIntent);

The context is the MapActivity that contains the MapView.  It is
passed to the Overlay with the constructor.

It is the line startActivity where the app throws an exception
(ActivityNotFoundException).  I did the setFlags because an error
message said it was needed because I was trying to start the Activity
while outside an Activity.  That makes me think I am going about this
wrong.

I have 'MyActivity' listed in my manifest so I don't think that is the
issue.  I have searched for this problem on the internet and I can't
seem to find anyone else running into this so that is another reason I
think I may be trying to do this the wrong way.

--~--~---------~--~----~------------~-------~--~----~



Launching Activity from Overlay onTap

by Tim Bray » Wed, 11 Feb 2009 02:36:44 GMT


 




This works for me just fine.  I want to launch the browser on a URL that's
associated with where they tapped:

container.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(uri)));

Works fine.  So the problem must be with finding your activity.  -T

--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


Launching Activity from Overlay onTap

by jgostylo » Wed, 11 Feb 2009 21:22:16 GMT


 > This works for me just fine. I want to launch the browser on a URL that's

Thanks Tim!  Your words helped me push on and I finally found out
where I was going wrong.  I had been passing the context to my
MyOverlay class incorrectly as getApplicationContext() instead of just
'this' when I declared a new MyOverlay.  When I changed that it
started working.
--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. Working on another Android story

Hey All,
Thanks for all your responses so far, they've definitely helped with my
stories. I'm working on another one about the cost to develop these
applications. Obviously cost is a tough thing to nail down, but if you could
figure out based on number of hours spent and salary or however makes sense
for your specific application, that would be great.

Thanks,
Vasanth Sridharan
Reporter
Silicon Alley Insider
C: (408) 455-2254
http://www.alleyinsider.com
http://www.vasanthsridharan.com

--~--~---------~--~----~------------~-------~--~----~

2. Annotations and reflection

Are reflection methods like
java.lang.reflect.AccessibleObject.isAnnotationPresent() implemented?

Here is my example:

-- i have this simple annotation:
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface GSTestAnn {

}

-- i have this class:
public class GSTest {
        @GSTestAnn
        public void annotated() {
                // empty
        }
}

-- and finally this block of code:
GSTest test = new GSTest();
for (Method m : test.getClass().getMethods()) {
        if (m.isAnnotationPresent(GSTestAnn.class)) {
                log("is in  : " + m.getName()); }
        else {
                log("NOT in : " + m.getName());
        }
}

If i run this example outside Android, everything works and name of
method "annotated()" is prefixed by "is in" in log. But if I run it
inside Android, all methods (including "annotated()") are prefixed
with "NOT in" .. does it mean that it isn't implemented? (it's same
for other reflection methods as well)

Thanks for any advice,

  srakyi

--~--~---------~--~----~------------~-------~--~----~

3. Android Map Exception

4. question about mimetype in android browser

5. I Want to add button and with event to press button application

6. Can we improve the SNR of the newsgroups?

7. Bucket Fill