Posted on 2010/11/26, 2:19 am, by zhangv, under
技术(Tech).
直接上代码:
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import javax.microedition.io.Connector;
import javax.microedition.io.HttpConnection;
import org.json.me.JSONObject;
public class GooglUtils {
private static String GOOGL_API_ENDPOINT=”http://goo.gl/api/shorten?security_token=null&url=”;
public static String shorten(String url) throws Exception{
HttpConnection con = null;
InputStream in = null;
OutputStream out = null;
ByteArrayOutputStream bos = null;
OutputStreamWriter osw = null;
InputStreamReader isr = null;
byte[] request;
int messageLength;
try {
bos = new ByteArrayOutputStream();
osw = new OutputStreamWriter(bos, “UTF-8″);
// osw.write(url);
osw.flush();
request = bos.toByteArray();
messageLength [...]
Posted on 2009/05/20, 12:32 pm, by zhangv, under
技术(Tech).
Keep getting the out of memory error when handling the image file in emulator(wtk) and device(e61i)
Just had a simple test and here is what I found:
The code is simple:
for(int i=1000;i<Integer.MAX_VALUE;i++){
System.out.println(i);
byte[] buf = new byte[i];
}
and see when your program will crash. – Actually it won’t crash, as the OOME(out of memory error), is an Error rather [...]
Posted on 2008/03/12, 6:09 pm, by zhangv, under
技术(Tech).
http://www.forum.nokia.com/document/Java_ME_Developers_Library_v1/index.html?content=GUID-545CA84A-8378-4DFA-9035-94479F5BE26E.html
一些常用的路径,比如图像路径,存储卡路径,相机路径
System properties
The table below contains the File API system properties that return the localized names of common directories and the URLs to the most common directories. Several Strings are only supported in either S60 or Series 40. Refer to the individual tables for each implementation.
String
Description
Fileconn.dir.photos.name
Localized name for the photo directory, for example “Images”.
Fileconn.dir.graphics.name
Localized name for [...]
Posted on 2008/03/11, 8:54 pm, by zhangv, under
技术(Tech).
Javablog » How MIDlet Signing is Killing J2ME
TODO: 翻译
Posted on 2008/03/09, 10:38 am, by zhangv, under
技术(Tech).
如果直接videoControl.getSnapshot(null)的话,得到的是默认的较低分辨率和画质-在我的e61i上是640*480,这样显然不能充分利用2M像素的相机。(当然也要看了,你指望从手机上传出多清晰的照片,而且也要有兼容的问题,万一其他手机支持不到这么高怎么办?)通过设置width和height即可以支持更高的分辨率。
videoControl.setVisible(false);
String enc = “encoding=jpeg&width=800&height=600″;
byte[] raw = videoControl.getSnapshot(enc);
appendImage(raw);
在我的小6上测试:
1600*1200 – 无法处理的异常(应该是得到的byte[]太大,ME的Vector会溢出),1200*900 – MediaException : Symbian OS Error: -4,貌似不支持这个分辨率
1280*960 – 同上
1024*768 – 同上
800*600 - 成功
640*480 – 成功,默认的分辨率
参考:nokia.wiki
Powered by MoFire
Posted on 2008/03/02, 3:18 pm, by zhangv, under
技术(Tech).
本文的目的是为读者提供处理不同情况的代码,您可以参考MMAPI DOC。
播放单音
try
{
Manager.playTone(ToneControl.C4, 5000
/* millisec */, 100 /* max vol */);
} catch (MediaException e)
{
}
简单媒体重放功能实现:
try
{
Player p = Manager.createPlayer
(”http://webserver/music.mp3″);
p.setLoopCount(5);
p.start();
} catch (IOException ioe)
{
} catch (MediaException me)
{
}
详细重放控制:
static final long SECS_TO_MICROSECS
= 1000000L;
Player p;
VolumeControl vc;
try {
p = Manager.createPlayer
(”http://webserver/music.mp3″);
p.realize();
// Set a listener.
p.addPlayerListener(new Listener());
// Grab volume control for the player.
// Set Volume to max.
vc = (VolumeControl)p.getControl
(”VolumeControl”);
if (vc != null)
vc.setLevel(100);
// Set a start time.
p.setMediaTime(5 * [...]
try {
// Create a Player that captures live audio.
Player p = Manager.createPlayer(”capture://audio”);
p.realize();
// Get the RecordControl, set the record stream,
// start the Player and record for 5 seconds.
RecordControl rc = (RecordControl)p.getControl(”RecordControl”);
[...]
最新版本(latest version): 0.6.1 download
Source code:
http://code.google.com/p/mofire/
http://sourceforge.net/projects/mofire/
Download and try:
http://mosh.nokia.com/content/4897555AA597E7C5E040050A45306893
手机上的wordpress客户端(jme)
1.支持拍照并发布带图片附件的日志
2.可配置多个blog
3.可保存日志到手机
4.支持从本地载入图片并发布到blog
5.支持分类,标签,使用MetaWeblog API
类图:
mofire-uml-0.1
FAQs:
What is mofire?
It’s a blogging client on your mobile phone.
What blogging application mofire supports?
Initially, this is for my own wordpress blog. Theoretically, it supports all the blog application that support metaweblog API.
Why “mofire”?
“mo” is my prefix, means “nothing”, “fire” is to after my favorite blogging client – [...]
Posted on 2008/02/02, 6:33 pm, by zhangv, under
技术(Tech).
编译时找不到List.deleteAll这个方法,因为默认的的antenna使用cldc1.0。而这个deleteall是1.1的方法,解决方法是覆盖默认的cldc版本
<property name=”wtk.cldc.version” value=”1.1″/>
Antenna是用来构建j2me项目的ant任务 扩展。让整个构建过程变的很简单和易于管理。
附我使用的构建脚本供参考:
<?xml version=”1.0″?>
<project name=”MoFire” default=”build” basedir=”.”>
<!– Define the Wireless Toolkit home directory. Needed by the tasks. –>
<property name=”wtk.home” value=”D:\development\WTK2.5.2″/>
<property name=”wtk.cldc.version” value=”1.1″/>
<property name=”wtk.midp.version” value=”2.0″/>
<property name=”wtk.proguard.home” value=”D:\development\workspaceME\lib\proguard4.1\”/>
<!– Define some additional properties for this project. Not required. –>
<property name=”midlet.name” value=”${ant.project.name}”/>
<property name=”midlet.home” value=”.”/>
<property name=”midlet.vendor” value=”MoDoFo”/>
<property name=”midlet.version” value=”0.0.1″/>
<!– Define the tasks. –>
<taskdef resource=”antenna.properties” classpath=”lib/antenna-bin-1.0.0.jar”/>
<target name=”clean”>
<delete failonerror=”false” dir=”classes”/>
</target>
<target name=”dist” [...]