Application Error Occurs in Nokia 6300

北慕城南 提交于 2019-12-06 10:19:03

问题


I am using this code to connect Servlet. Mobile application when try to access internet.

The following message appears in mobile.

"Allow network access?? yes or no ". If I click "no" for that message in Nokia 6300 "Application Error" Warning will appear and it will close the application automatically.

I tried other nokia mobiles like N70 and N72. Mobile will not show "Application Error".

Is it Mobile problem or coding problem?

Is there any efficient way to connect Servlet using http?

 public static InputStream getDataInputStream(String url, String request) 
 {
    HttpConnection httpConnectionObj = null;

    OutputStream dataOutputStreamObj = null;

    try {
        httpConnectionObj = (HttpConnection) Connector.open(url, Connector.READ_WRITE);

        httpConnectionObj.setRequestMethod(HttpConnection.POST);

        dataOutputStreamObj = httpConnectionObj.openOutputStream();

        dataOutputStreamObj.write(request.getBytes());

        dataOutputStreamObj.close();

        return httpConnectionObj.openInputStream();

    } catch (javax.microedition.io.ConnectionNotFoundException cnfe) {
      //Alert
    } catch (Exception ex) {
      //Alert
    } finally {
        try {
            if (httpConnectionObj != null) {
                httpConnectionObj.close();
                httpConnectionObj = null;
            }

        } catch (IOException ex) {
            ex.printStackTrace();
        }

    }
    return null;
}

回答1:


There is no good way to extract java.lang.Throwable.printStackTrace() on a Nokia 6300 since it is a Series40 phone.

The issue with the permission dialog has nothing to do with your code. You have to be aware of the MIDP security model in order to fix this.

A given phone has several security domain encoded in its firmware by the phone manufacturer.

In each domain, there can be several options to restrict access to a sensitive API.

When you install a MIDlet, the phone decides which domain it belongs to based on who trusts the certificate you signed it with. (could be unsigned, trusted third party, operator, manufacturer... )

When you run the MIDlet, every time it attempts to use a restricted API, the corresponding option is applied. (Could be always deny, ask the user every time, ask the user only once, always allow).

Different restricted APIs can have different options in the same domain.

There are therefore several possible explanations to your problem:

  • You signed the MIDlet differently for 6300 and N70.
  • The security domains are different on 6300 and n70.
  • The option to restrict HTTP connection is different on 6300 and N70.
  • The Mobile Network Operator is different on 6300 and N70.



回答2:


I am not sure if it would help, but try closing output stream before HttpConnection in finally block:

    } finally {
        try {
            if (dataOutputStreamObj != null)
                dataOutputStreamObj.close();
            dataOutputStreamObj = null;

            if (httpConnectionObj != null)
                httpConnectionObj.close();
            httpConnectionObj = null;

        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }


来源:https://stackoverflow.com/questions/1497988/application-error-occurs-in-nokia-6300

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!