Location MIDlet closed after 110th orientation call in S60 5th Edition

本文介绍了一个在S60第5版设备上使用Orientation.getOrientation()方法的问题,在第110次调用后可能导致MIDlet应用非正常关闭。通过提供示例代码展示了如何复现该问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

ID KIJ001579 Creation date April 23, 2010
Platform S60 5th Edition Devices Nokia N97, Nokia N97 mini
Category Java ME Subcategory Location API (JSR-179)

 

Keywords (APIs, classes, methods, functions): Orientation.getOrientation()

 

Description

Orientation.getOrientation() returns the terminal's current orientation. This information can be retrieved from Nokia devices equipped with built-in magnetometer hardware.

On S60 5th Edition devices, heavy usage of Orientation.getOrientation() results in the location MIDlet closing either without an exception or with java.lang.OutOfMemoryError. The closing happens right after the 110th method call.

How to reproduce

1. Implement a test MIDlet by using the following code:

 

 

import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Form;
import javax.microedition.location.LocationException;
import javax.microedition.location.Orientation;
import javax.microedition.midlet.*;
 
public class LocationTest extends MIDlet {
 
    Display d;
    Form f;
    boolean running = false;
    Thread t = null;
    protected int interval = 1000;
 
 
    public LocationTest() {
 
            d=Display.getDisplay(this);
            f=new Form("Location Test");
            startRequesting();
            }
 
    public void startApp() {
        d.setCurrent(f);
    }
 
 
    public void show(String s) {
        f.append(s);
    }
 
    //Implement the orientation updating activity within a thread
    public void startRequesting() {
        t = new Thread(new Runnable() {
 
            public void run() {
                running = true;
                try {
                    while (running) {
                        updateOrientation();
                        Thread.sleep(interval);
                    }
                } catch (InterruptedException ex) {
                    show("Exception: "+ex.toString());
                }
            }
        });
        t.start();
    }
 
    int num = 0;
    private void updateOrientation() {
 
        Orientation o;
        String s;
        try {
            f.deleteAll();
            o = Orientation.getOrientation();
           show("Orientation.getOrientation(): "+num);
            num++;
 
        }
         catch (LocationException ex) {
 
             show("Exception: " +ex.toString());
 
         }
 
    }
 
    public void pauseApp() {
    }
 
    public void destroyApp(boolean unconditional) {
    }
}

 

 

2. Install the MIDlet and wait for it to reach the 110th method call of Orientation.getOrientation().

Solution

This issue is expected to be fixed in future firmware releases for the affected devices

 

 

URL: http://wiki.forum.nokia.com/index.php/KIJ001579_-_Location_MIDlet_closed_after_110th_orientation_call_in_S60_5th_Edition

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值