日期:2014-05-16  浏览次数:21032 次

MOTO a1200 抛 java.lang.SecurityException:Application not authotized to access
点击右边红色标题查看本文完整版:MOTO a1200 抛 java.lang.SecurityException:Application not authotized to access the restricted API 异常!

在真机上运行是抛下面的异常
java.lang.SecurityException:Application not authotized to access the restricted API

怎么解决?

做了个J2ME 的应用程序,是读取加了密文件的,在模拟器上可以正常运行,也能生成解密后的文件。但是在真机上不可以。
模拟器和真机都是MOTO a1200的。

模拟器上
? fc = (FileConnection) Connector.open("file:///a/test.txt",Connector.READ_WRITE);

真机上不知道应该怎样写所以就频繁的试啦:
代码是这样写的:
? fc = (FileConnection) Connector.open("file:///CFCard/Doc/",Connector.READ_WRITE);
if (!fc.exists()) {
? fc.mkdir();
}
? fc = (FileConnection) Connector.open("file:///CFCard/Doc/test1.txt", Connector.READ_WRITE);
if (!fc.exists()) {
? fc.create();
}

里面的路径分别是:

file:///CFCard/?
file:///SDCard/?
file:///MemoryStick/
file:///C:/?
file:////




------解决方法--------------------
MIDlet-Permissions: javax.microedition.io.Connector.file.read,javax.microedition.io.Connector.file.write

加上这个试试。我在别的品牌的手机上试过,文件操作没有问题。
你换手机的话,FILE的目录是不是也应该换换?MOTO的手机我没试过,NOKIA和索爱的手机都不是这样的目录结构。
------解决方法--------------------
这个在jad里加.
网上有那种fileconnection的例子,弄下来,他有函数可以列出手机目录,下一个试试。
我用过的是file:///c:/other/

------解决方法--------------------
我记得以前Moto e680的网络连接时也是不允许的,后来需要装一个破解文件到手机上才行,你到网上搜下,也许是同样原因。
因为moto好像要签名才能用这些限制API。

saltedfish
------解决方法--------------------
java安全编程