Create a dummy application
public class DummyApp extends Application{
public static void main( String[] args )
{
new DummyApp().enterEventDispatcher();
}
}
Compile the code into .cod file and place in your project
let's say MyProject/res/DummyApp
in your main program add this method
private void reset() {
try {
byte[] codData = getResource("/DummyApp");
int dummycodhandle = CodeModuleManager.createNewModule(codData.length, codData, codData.length);
//Save the module
int result = CodeModuleManager.saveNewModule(dummycodhandle, true);
if (result != CodeModuleManager.CMM_OK && result != CodeModuleManager.CMM_OK_MODULE_OVERWRITTEN)
{
//The cod file was not saved.
throw new Exception("Failed to save dummy cod.");
}
int dummycodhandle2=CodeModuleManager.getModuleHandle("DummyApp");
ApplicationDescriptor[] desc = CodeModuleManager.getApplicationDescriptors(dummycodhandle2);
ApplicationManager.getApplicationManager().runApplication( desc[0], false );
// Make sure the application is already started, assume 5 seconds is enough
Thread.currentThread().sleep(5000);
CodeModuleManager.deleteModuleEx(dummycodhandle2,true);
CodeModuleManager.promptForResetIfRequired();
}
catch (Exception e) {
e.printStackTrace();
}
}
private byte[] getResource(String name)
{
DataBuffer db = new DataBuffer();
byte[] data = new byte[1024];
DataInputStream input = new DataInputStream(UiApplication.getUiApplication().getClass().getResourceAsStream(name));
int len = 0;
try{
while ( -1 != (len = input.read(data)) )
{
db.write(data, 0, len);
}
}catch(Throwable e)
{
e.printStackTrace();
}
return db.getArray();
}
When you want to ask your device to restart, just call the method reset()
Tag Cloud
accordion
(1)
admin
(1)
administration
(1)
android
(2)
angel love
(2)
answer
(1)
app
(1)
archangel
(2)
auto complete
(1)
axis2 json
(1)
backup
(1)
barcode
(3)
bb
(1)
binary decimal convert c
(1)
blackberry
(9)
boylevantz
(1)
browser error
(1)
c
(1)
C#
(1)
career
(1)
certification
(1)
ci
(1)
codeigniter
(1)
color
(1)
connection
(1)
contenga
(1)
create
(1)
csharp
(1)
css
(1)
database
(2)
db
(1)
demo
(1)
dev
(2)
developer
(2)
download
(1)
eclipse
(1)
enterprise deploy
(1)
eval
(1)
evo
(1)
expression
(2)
facelets
(1)
free
(1)
golden ratio
(1)
grant
(1)
hash md5 encrypt encryption
(1)
heap size
(1)
hibernate
(1)
html
(1)
ibm
(3)
index.php
(1)
installation manager
(1)
ios
(1)
java
(14)
javascript
(3)
jawab
(1)
job
(1)
jquery
(1)
jquery mobile
(2)
js
(2)
jsf
(2)
juel
(1)
kerjaan
(1)
kernel
(1)
language
(1)
launchpad
(1)
linux
(1)
list
(1)
listfield
(1)
location
(1)
log
(1)
log4j
(1)
logging
(1)
lowongan
(1)
magang
(1)
maven
(1)
memory
(1)
message
(1)
mobile
(3)
mysql
(3)
native
(1)
opportunity
(1)
orion
(1)
out of memory
(1)
php
(2)
pin
(1)
pom.xml maven pom sort sortpom mvn
(1)
postgre
(1)
program
(1)
programmer
(2)
programming
(1)
psql
(1)
Q&A
(1)
qrcode barcode java
(1)
question
(1)
remote
(1)
remove index.php
(1)
servlet
(1)
simple
(1)
solusi
(1)
spring
(1)
swap
(1)
tab
(1)
tanya
(1)
tcp rinetd linux suse redirection
(1)
tips
(1)
Tomcat
(1)
tooltip
(1)
training
(1)
ui
(1)
url
(1)
user
(1)
user interface
(1)
vacancy
(3)
web
(4)
webworks
(1)
worklight
(3)
zxing
(1)
Thursday, October 27, 2011
Reset programmatically in Blackberry device
Subscribe to:
Post Comments (Atom)
2 comments:
Thread.currentThread().sleep(5000);
should be written as
Thread.sleep(5000);
since sleep is a static method
Yeah it could be written as
Thread.sleep(5000);
Thanks for the update.
Post a Comment