×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Regular Contributor
    Join Date
    May 2009
    Posts
    115

    J2ME Google Maps API access problem

    I use J2ME Google Maps API to write coordinates of a location and see it on a image file. Unfortunately, I got this error when I compile my application:


    java.lang.SecurityException: Application not authorized to access the restricted API
    at com.sun.midp.security.SecurityToken.checkIfPermissionAllowed(SecurityToken.java:170)
    at com.sun.midp.security.SecurityToken.checkIfPermissionAllowed(SecurityToken.java:145)
    at com.sun.midp.midletsuite.MIDletSuiteImpl.checkIfPermissionAllowed(MIDletSuiteImpl.java:281)
    at com.sun.midp.midlet.MIDletState.<init>(+83)
    at javax.microedition.midlet.MIDletProxy.<init>(MIDletProxy.java:33)
    at javax.microedition.midlet.MIDlet.<init>(MIDlet.java:70)
    at GoogleMaps.<init>(GoogleMaps.java:53)
    at GoogleMaps.getForm(GoogleMaps.java:297)
    at GoogleMaps.startMIDlet(GoogleMaps.java:251)
    at GoogleMaps.startApp(GoogleMaps.java:352)


    When I check my password that I took from Gmail and try it on an HTML i can see the image. But it does not work when I wrote the password in the code. What should I do to breach the security? Thank you in advance.

  2. #2
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: J2ME Google Maps API access problem

    This is nothing to do with the Google Maps API.

    You have written a class GoogleMaps, correct? Take a look in the getForm() method... you have the expression:

    Code:
    new GoogleMaps()
    GoogleMaps extends MIDlet. It is an application. Only the application manager can create an instance of a MIDlet. If you need to access the instance of GoogleMaps, it can be referenced as "this" in any instance (non-static) method.

    Graham.

  3. #3
    Regular Contributor
    Join Date
    May 2009
    Posts
    115

    Re: J2ME Google Maps API access problem

    Yes I have new GoogleMaps() expression. You can see my code inside getForm() below:

    public Form getForm() {
    if (form == null) {
    // write pre-init user code here
    form = new Form("form", new Item[] { getImageItem() });
    // write post-init user code here
    GoogleMaps gMap = new GoogleMaps("ABQIAAAA7qdeVaJ6yIEBXYN8wiXCghSokdr2Whc27jI3E0XpKCOM9q-hAxQein5A9oOZcaooUSTtzJoPQmgtQA");
    try {
    Image map = gMap.retrieveStaticImage(320, 240, 41.008822, 28.981542, 8, "png32");
    } catch (IOException ex) {
    ex.printStackTrace();
    }



    }
    return form;
    }

    I have been trying to fix the problem for 2 days and I believe the problem should be something except code but I do not know. Thank you in advance.

  4. #4
    Super Contributor
    Join Date
    Apr 2007
    Posts
    2,708

    Re: J2ME Google Maps API access problem

    are you sure about this line :

    form = new Form("form", new Item[] { getImageItem() });

    whats that method ur calling getImageItem() ?

  5. #5
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: J2ME Google Maps API access problem

    Your class GoogleMaps is a subclass of MIDlet. You cannot create an instance of it.

    This line of code cannot be executed:

    Code:
    GoogleMaps gMap = new GoogleMaps("ABQIAAAA7qdeVaJ6yIEBXYN8wiXCghSokdr2Whc27jI3E0XpKCOM9q-hAxQein5A9oOZcaooUSTtzJoPQmgtQA");
    You are not permitted to create an instance of this class, because it is the MIDlet class.

    Restructure your code, so that the mapping functionality is in a separate class, not in the MIDlet class.

    Graham.

  6. #6
    Regular Contributor
    Join Date
    May 2009
    Posts
    115

    Re: J2ME Google Maps API access problem

    Thank you grahamhughes. As you told me, I had to specify GoogleMaps functions and methods in a different class. I created a different GoogleMaps() class, that's why I got Security Exception. I created GoogleMaps class and I invoked GoogleMaps from VisualMidlets class and it worked very well. Thank you all.

Similar Threads

  1. ambiguous access to name found 'CMatchData' Problem
    By rion in forum Symbian Media (Closed)
    Replies: 2
    Last Post: 2009-04-03, 11:09
  2. MWS REST API with access control
    By talakosk in forum Mobile Web Server
    Replies: 4
    Last Post: 2008-09-09, 12:38
  3. access point problem with http client api
    By saurabh_gyl in forum Symbian Networking & Messaging (Closed)
    Replies: 10
    Last Post: 2007-06-15, 13:19
  4. J2ME access Symbian-limited API???
    By abolfoooud in forum Mobile Java General
    Replies: 1
    Last Post: 2007-01-10, 12:03
  5. J2ME access Symbian-limited API???
    By abolfoooud in forum Symbian
    Replies: 2
    Last Post: 2007-01-10, 12:02

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×