J2me MIDlet操作手机功能性用法总结
发布时间:2012-03-24 11:39:44
发布时间:2012-03-24 11:39:44
J2me MIDlet操作手机功能性用法总结(如调用其他程序或者调用其他MIDlet)
分类: j2me/wm/andriod/移动开发 2010-07-14 11:01 957人阅读 评论(3) 收藏 举报
本技术文章,由www.j2megame.com原创, 转载请说明。
方法1:MIDlet 通过 platformRequest,调用手机本地应用程序。
示例:
S60中调用
platformRequest("nativeapp:application-exe=MediaPlayer.exe;content=E:/Feelings.MP3;application-args=-ExampleArgument");
S40中调用
platformRequest("localapp://gallery/show?folder=C:/predefgallery/predefphotos");
方法2:MIDlet通过 platformRequest,调用其他MIDlet。
示例:
S40中
platformRequest("localapp://jam/launch?midlet-name=ArcadeGames;midlet-vendor=Acme;sounds=OFF;difficulty=easy;wizard_mode=ON");
MIDlet启动参数说明
Nokia-MIDlet-Launch-Params: sounds,difficulty,wizard_mode
The ArcadeGames MIDlet can access the parameters as follows:
System.getProperty("sounds");
System.getProperty("difficulty");
System.getProperty("wizard_mode");
platformRequest("javaapp:midlet-name=ArcadeGames;midlet-vendor=Acme;sounds=OFF;difficulty=easy;wizard_mode=ON");
通过MIDlet的UID启动
platformRequest("javaapp:midlet-uid=0xE1000000;sounds=OFF;difficulty=easy;wizard_mode=ON);
方法3:手机本地应用程序调用MIDlet
代码如下:
The following example code shows how to launch a MIDlet from a native Symbian application.
RProcess rProcess;
TInt err = rProcess.Create(_L("javalauncher.exe"), _L("midlet-uid=0x10137c4d;startMode=startFromCmdLine;sound=ON;landscapeMode=true;"));
if (KErrNone == err)
{
TRequestStatus status;
rProcess.Logon(status);
rProcess.Resume();
// now wait until javalauncher exits
User::WaitForRequest(status);
if (status.Int() != KErrNone)
{
// Launching midlet failed
err = status.Int();
}
}
else
{
// Cannot start javalauncher
}
rProcess.Close();
The following example code shows how to launch the same MIDlet from a Symbian application using Open C APIs.
include
gint exitStatus = 0;
// Start javalauncher and wait until it starts midlet
gboolean startOK = g_spawn_command_line_sync(
"javalauncher midlet-uid=0x10137c4d;startMode=startFromCmdLine;sound=ON;landscapeMode=true;",
NULL,
NULL,
&exitStatus,
NULL);
if (startOK)
{
if (exitStatus != 0)
{
// launching midlet failed, (Symbian) error code in exitStatus
}
}
else
{
// Cannot start javalauncher
}
方法4:MIDlet重新启动
In Series 40 and Symbian, when a MIDlet is already running and it is re-launched, it is set on the foreground and can receive the new command line parameters.
In Symbian, every time a MIDlet is re-launched, the integer value in com.nokia.mid.cmdline.instance system property is incremented by one. This value can be used to check whether the MIDlet has really been re-launched or just brought to the foreground. The old values of the command line arguments are not changed unless new command line values redefine them. If JAD attribute Nokia-MIDlet-Background-Event has the value pause, the startApp method is called every time the MIDlet is brought to foreground. This provides an easy way to acquire new command line parameters.
方法5:从手机浏览器网站链接启动MIDlet
n Symbian, when a link with the javaapp: or localapp://jam/launch? URI scheme is opened on a web page, the corresponding MIDlet is launched. If JavaScript is enabled, a JavaScript function may also activate the link.
Before the MIDlet is started from a web browser link, the auto invocation permission of the MIDlet is checked. This means that in case of third-party MIDlets, the user is always asked at least once to confirm the MIDlet launch.
If you use non-US-ASCII characters in the URL, you must use UTF-8 encoding. Also spaces must be encoded, for example:
javaapp:midlet-name=Arcade Pro;midlet-vendor=Acme;midlet-n=1;sounds=OFF;difficulty=medium
方法6:MIDlet platformRequest其他常用功能
打电话:
platformRequest("tel:+19143680400");
打开网页:
platformRequest("http://www.forum.nokia.com/");
打开1个RTSP流连接:
platformRequest("rtsp://ra.yle.fi/ramgen/tv2/viihde/zencafe.rm");
利用本地默认软件打开1个本地文件
platformRequest("file://E/image.png");
打开短信编辑器,并发短信到指定号码
platformRequest("sms:+19143680400");
其他常用列表及功能:
使用连接后提示用语列表
In Symbian, localapp supports launching only the following applications:
Symbian本地应用程序列表