05-24-2012 10:20 AM - edited 05-24-2012 10:26 AM
I have problem with store volume player on exit applicstion.
The player gets the data from
_currentVolume = 50;
and
int _currentVolume;
I know how to store data from LabelField, but i know how to store Integer from player value ![]()
Any help me with this questions?
This is my code for get:
public void Get() {
synchronized (store) {
_data = (Vector) store.getContents();
if (!_data.isEmpty()) {
StoreInfo info = (StoreInfo) _data.lastElement();
mylabel.setText(info.getElement(StoreInfo.INFO));
}
}
};
05-24-2012 10:28 AM
You can get the level from VolumeControl interface...
Have a look into the media demo.
SendMediaDemo with in BB Sample projects.
05-24-2012 10:34 AM
05-24-2012 10:41 AM
I have code...
_player.realize();
volumeControl = (VolumeControl) _player.getControl("VolumeControl");
volumeControl.setLevel(_currentVolume);
setVolume(_currentVolume);
and try like this but not working :)
info.setElement(StoreInfo.VOL2, volumeControl.getLevel());
I got this error...
setElement(int,java.lang.String) in USERSTATION.StoreInfo cannot be applied to (int,int)
info.setElement(StoreInfo.VOL2, volumeControl.getLevel());
I programming 2 month...and understand all.
05-24-2012 10:44 AM
05-24-2012 10:56 AM
try this
info.setElement(StoreInfo.VOL2, String.valueOf(volumeControl.getLevel()));
05-24-2012 11:06 AM - edited 05-24-2012 11:28 AM
I set for Save method this code ![]()
public void Save() {
StoreInfo info = new StoreInfo();
Integer.toString(StoreInfo.VOL2, volumeControl.getLevel());
_data.addElement(info);
EDIT: My code not working...![]()
i try your code a moment
Restart BB ![]()
This code dont work...i cant exit from application when use them.
public void Save() {
StoreInfo info = new StoreInfo();
info.setElement(StoreInfo.VOL2, String.valueOf(volumeControl.getLevel()));
_data.addElement(info);
synchronized (store) {
store.setContents(_data);
store.commit();
}
};
public void Get() {
synchronized (store) {
_data = (Vector) store.getContents();
if (!_data.isEmpty()) {
StoreInfo info = (StoreInfo) _data.lastElement();
I dont know how to :)
}
}
};
05-24-2012 11:53 AM - edited 05-24-2012 11:55 AM
Anybody help me?
I use this but not working...why?
public void Save() {
StoreInfo info = new StoreInfo();
info.setElement(StoreInfo.VOL2, String.valueOf(volumeControl.getLevel()));
_data.addElement(info);
synchronized (store) {
store.setContents(_data);
store.commit();
}
//Dialog.inform("Success!");
};
public void Get() {
synchronized (store) {
_data = (Vector) store.getContents();
if (!_data.isEmpty()) {
StoreInfo info = (StoreInfo) _data.lastElement();
volumeControl.setLevel(info.getElement(StoreInfo.V OL2));
}
}
};I got this error:
setLevel(int) in javax.microedition.media.control.VolumeControl cannot be applied to (java.lang.String)
volumeControl.setLevel(info.getElement(StoreInfo.V
05-25-2012 02:44 AM
05-28-2012 06:45 AM - edited 05-28-2012 06:49 AM
I try everything
But nothing works for me ![]()
I add this code and application works very fine....
String str = "30"; int _currentVolume = Integer.parseInt(str);
Application starts and volume is 30...supa ^^ But when add this code for store, application cant open ![]()
I got This error in EventLog:
guid:0x9C3CD62E3320B498 time: Mon May 28 12:39:07 2012 severity:1 type:3 app:Java Exception data: ArrayIndexOutOfBoundsException 1 >= 1 net_rim_cldc(4BA7D958) Vector elementAt 0xC85C App(4FC354D2) SOME$StoreInfo getElement 0x4F66 ...
public void Save() {
StoreInfo info = new StoreInfo();
info.setElement(StoreInfo.SMS, basicEditField2.getText());//This works fine
info.setElement(StoreInfo.VOL, String.valueOf(volumeControl.getLevel()));
_data.addElement(info);
synchronized (store) {
store.setContents(_data);
store.commit();
}
};
public void Get() {
synchronized (store) {
_data = (Vector) store.getContents();
if (!_data.isEmpty()) {
StoreInfo info = (StoreInfo) _data.lastElement();
basicEditField2.setText(info.getElement(StoreInfo. SMS));//Works fine
Integer.parseInt((String)info.getElement(StoreInfo .VOL));
}
}
};
static final class StoreInfo implements Persistable {
private Vector _elements;
public static final int SMS = 0;
public static final int VOL = 1;
public StoreInfo() {
_elements = new Vector(2);
for (int i = 0; i < _elements.capacity(); ++i) {
_elements.addElement(new String(""));
}
}
public String getElement(int id) {
return (String) _elements.elementAt(id);
}
public void setElement(int id, String value) {
_elements.setElementAt(value, id);
}
}
static {
store = PersistentStore.getPersistentObject (0xdec6a67096f839cL);
synchronized (store) {
if (store.getContents() == null) {
store.setContents(new Vector());
store.commit();
}
}
_data = new Vector();
_data = (Vector) store.getContents();
} Where is the problem??? I cant understand yet ![]()