Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
New Contributor
Posts: 7
Registered: ‎01-03-2012
My Device: 8900
My Carrier: Airtel

I have developed analog clock,But i am enable to set that clock in Blackberry Home screen

Hi friends,

 

I have developed analog clock,But I enable  to set that one to home screen of balckberry .

 

Can any one help on this issue....

 

 

Regards,

saiswaroop.

Developer
Posts: 16,997
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: I have developed analog clock,But i am enable to set that clock in Blackberry Home screen

i don't understand your question.
you can set a background image for the homescreen, but other interactions are fairly limited.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
New Contributor
Posts: 7
Registered: ‎01-03-2012
My Device: 8900
My Carrier: Airtel

Re: I have developed analog clock,But i am enable to set that clock in Blackberry Home screen

I developed Analog application like about Code..

 

package Analog.ithink.ds.com;

import java.util.Calendar;
import java.util.Date;

import net.rim.device.api.system.Bitmap;
import net.rim.device.api.ui.Graphics;
import net.rim.device.api.ui.component.BitmapField;

public class ClockBitmapFiled extends BitmapField {

Bitmap _face = null;
UpdateClockThread _updateClockThread = null;
Bitmap[] _hourBitmaps = null;
Bitmap[] _minBitmaps = null;
Bitmap[] _secBitmaps = null;
Bitmap _ourBitmap;

public ClockBitmapFiled(Bitmap face, long style, String[] hourPngs,
String[] minPngs, String[] secPngs) {

super(face, style);
_face = face;
_ourBitmap = new Bitmap(_face.getWidth(), _face.getHeight());
this.setBitmap(_ourBitmap);

// Swap to using work area

_hourBitmaps = new Bitmap[hourPngs.length];
for (int i = 0; i < hourPngs.length; i++) {
_hourBitmaps[i] = Bitmap.getBitmapResource(hourPngs[i]);
}
_minBitmaps = new Bitmap[minPngs.length];
for (int i = 0; i < minPngs.length; i++) {
_minBitmaps[i] = Bitmap.getBitmapResource(minPngs[i]);
}

_secBitmaps = new Bitmap[secPngs.length];
for (int i = 0; i < secPngs.length; i++) {
_secBitmaps[i] = Bitmap.getBitmapResource(secPngs[i]);
}
}

protected void onDisplay() {
onExposed();
}

protected void onUnDisplay() {
onObscured();
}

protected void onExposed() {
if (_updateClockThread == null || !_updateClockThread.isAlive()) {
_updateClockThread = new UpdateClockThread(_ourBitmap, _face, this,
_hourBitmaps, _minBitmaps, _secBitmaps);
_updateClockThread.start();
}
}

protected void onObscured() {
if (_updateClockThread != null) {
_updateClockThread.stop();
_updateClockThread = null;
}
}

public void invalidate() {
super.invalidate();
}

// ===============================================================================

class UpdateClockThread extends Thread {
private Calendar _cal = null;
int _curHr = 0;
int _curMin = 0;
int _curSec = 0;
Bitmap _face = null;
int _faceHeight = 0;
int _faceWidth = 0;

Bitmap _ourBitmap = null;
Graphics _g = null;
ClockBitmapFiled _ourField = null;
long LONG_ONE_THOUSAND = 1000;
boolean _stopped = false;

// / hours

Bitmap[] _hourBitmaps = new Bitmap[] {
Bitmap.getBitmapResource("hours/hour1.png"),
Bitmap.getBitmapResource("hours/hour2.png"),
Bitmap.getBitmapResource("hours/hour3.png"),
Bitmap.getBitmapResource("hours/hour4.png"),
Bitmap.getBitmapResource("hours/hour5.png"),
Bitmap.getBitmapResource("hours/hour6.png"),
Bitmap.getBitmapResource("hours/hour7.png"),
Bitmap.getBitmapResource("hours/hour8.png"),
Bitmap.getBitmapResource("hours/hour9.png"),
Bitmap.getBitmapResource("hours/hour10.png"),
Bitmap.getBitmapResource("hours/hour11.png"),
Bitmap.getBitmapResource("hours/hour12.png"),
Bitmap.getBitmapResource("hours/hour13.png"),
Bitmap.getBitmapResource("hours/hour14.png"),
Bitmap.getBitmapResource("hours/hour15.png"),
Bitmap.getBitmapResource("hours/hour16.png"),
Bitmap.getBitmapResource("hours/hour17.png"),
Bitmap.getBitmapResource("hours/hour18.png"),
Bitmap.getBitmapResource("hours/hour19.png"),
Bitmap.getBitmapResource("hours/hour20.png"),
Bitmap.getBitmapResource("hours/hour21.png"),
Bitmap.getBitmapResource("hours/hour22.png"),
Bitmap.getBitmapResource("hours/hour23.png"),
Bitmap.getBitmapResource("hours/hour24.png"),
Bitmap.getBitmapResource("hours/hour25.png"),
Bitmap.getBitmapResource("hours/hour26.png"),
Bitmap.getBitmapResource("hours/hour27.png"),
Bitmap.getBitmapResource("hours/hour28.png"),
Bitmap.getBitmapResource("hours/hour29.png"),
Bitmap.getBitmapResource("hours/hour30.png"),
Bitmap.getBitmapResource("hours/hour31.png"),
Bitmap.getBitmapResource("hours/hour32.png"),
Bitmap.getBitmapResource("hours/hour33.png"),
Bitmap.getBitmapResource("hours/hour34.png"),
Bitmap.getBitmapResource("hours/hour35.png"),
Bitmap.getBitmapResource("hours/hour36.png"),
Bitmap.getBitmapResource("hours/hour37.png"),
Bitmap.getBitmapResource("hours/hour38.png"),
Bitmap.getBitmapResource("hours/hour39.png"),
Bitmap.getBitmapResource("hours/hour40.png"),
Bitmap.getBitmapResource("hours/hour41.png"),
Bitmap.getBitmapResource("hours/hour42.png"),
Bitmap.getBitmapResource("hours/hour43.png"),
Bitmap.getBitmapResource("hours/hour44.png"),
Bitmap.getBitmapResource("hours/hour45.png"),
Bitmap.getBitmapResource("hours/hour46.png"),
Bitmap.getBitmapResource("hours/hour47.png"),
Bitmap.getBitmapResource("hours/hour48.png"),
Bitmap.getBitmapResource("hours/hour49.png"),
Bitmap.getBitmapResource("hours/hour50.png"),
Bitmap.getBitmapResource("hours/hour51.png"),
Bitmap.getBitmapResource("hours/hour52.png"),
Bitmap.getBitmapResource("hours/hour53.png"),
Bitmap.getBitmapResource("hours/hour54.png"),
Bitmap.getBitmapResource("hours/hour55.png"),
Bitmap.getBitmapResource("hours/hour56.png"),
Bitmap.getBitmapResource("hours/hour57.png"),
Bitmap.getBitmapResource("hours/hour58.png"),
Bitmap.getBitmapResource("hours/hour59.png"),
Bitmap.getBitmapResource("hours/hour60.png") };

// / minutes

Bitmap[] _minBitmaps = new Bitmap[] {
Bitmap.getBitmapResource("minutesImages/minutes1.png"),
Bitmap.getBitmapResource("minutesImages/minutes2.png"),
Bitmap.getBitmapResource("minutesImages/minutes3.png"),
Bitmap.getBitmapResource("minutesImages/minutes4.png"),
Bitmap.getBitmapResource("minutesImages/minutes5.png"),
Bitmap.getBitmapResource("minutesImages/minutes6.png"),
Bitmap.getBitmapResource("minutesImages/minutes7.png"),
Bitmap.getBitmapResource("minutesImages/minutes8.png"),
Bitmap.getBitmapResource("minutesImages/minutes9.png"),
Bitmap.getBitmapResource("minutesImages/minutes10.png"),
Bitmap.getBitmapResource("minutesImages/minutes11.png"),
Bitmap.getBitmapResource("minutesImages/minutes12.png"),
Bitmap.getBitmapResource("minutesImages/minutes13.png"),
Bitmap.getBitmapResource("minutesImages/minutes14.png"),
Bitmap.getBitmapResource("minutesImages/minutes15.png"),
Bitmap.getBitmapResource("minutesImages/minutes16.png"),
Bitmap.getBitmapResource("minutesImages/minutes17.png"),
Bitmap.getBitmapResource("minutesImages/minutes18.png"),
Bitmap.getBitmapResource("minutesImages/minutes19.png"),
Bitmap.getBitmapResource("minutesImages/minutes20.png"),
Bitmap.getBitmapResource("minutesImages/minutes21.png"),
Bitmap.getBitmapResource("minutesImages/minutes22.png"),
Bitmap.getBitmapResource("minutesImages/minutes23.png"),
Bitmap.getBitmapResource("minutesImages/minutes24.png"),
Bitmap.getBitmapResource("minutesImages/minutes25.png"),
Bitmap.getBitmapResource("minutesImages/minutes26.png"),
Bitmap.getBitmapResource("minutesImages/minutes27.png"),
Bitmap.getBitmapResource("minutesImages/minutes28.png"),
Bitmap.getBitmapResource("minutesImages/minutes29.png"),
Bitmap.getBitmapResource("minutesImages/minutes30.png"),
Bitmap.getBitmapResource("minutesImages/minutes31.png"),
Bitmap.getBitmapResource("minutesImages/minutes32.png"),
Bitmap.getBitmapResource("minutesImages/minutes33.png"),
Bitmap.getBitmapResource("minutesImages/minutes34.png"),
Bitmap.getBitmapResource("minutesImages/minutes35.png"),
Bitmap.getBitmapResource("minutesImages/minutes36.png"),
Bitmap.getBitmapResource("minutesImages/minutes37.png"),
Bitmap.getBitmapResource("minutesImages/minutes38.png"),
Bitmap.getBitmapResource("minutesImages/minutes39.png"),
Bitmap.getBitmapResource("minutesImages/minutes40.png"),
Bitmap.getBitmapResource("minutesImages/minutes41.png"),
Bitmap.getBitmapResource("minutesImages/minutes42.png"),
Bitmap.getBitmapResource("minutesImages/minutes43.png"),
Bitmap.getBitmapResource("minutesImages/minutes44.png"),
Bitmap.getBitmapResource("minutesImages/minutes45.png"),
Bitmap.getBitmapResource("minutesImages/minutes46.png"),
Bitmap.getBitmapResource("minutesImages/minutes47.png"),
Bitmap.getBitmapResource("minutesImages/minutes48.png"),
Bitmap.getBitmapResource("minutesImages/minutes49.png"),
Bitmap.getBitmapResource("minutesImages/minutes50.png"),
Bitmap.getBitmapResource("minutesImages/minutes51.png"),
Bitmap.getBitmapResource("minutesImages/minutes52.png"),
Bitmap.getBitmapResource("minutesImages/minutes53.png"),
Bitmap.getBitmapResource("minutesImages/minutes54.png"),
Bitmap.getBitmapResource("minutesImages/minutes55.png"),
Bitmap.getBitmapResource("minutesImages/minutes56.png"),
Bitmap.getBitmapResource("minutesImages/minutes57.png"),
Bitmap.getBitmapResource("minutesImages/minutes58.png"),
Bitmap.getBitmapResource("minutesImages/minutes59.png"),
Bitmap.getBitmapResource("minutesImages/minutes60.png") };

// seconds
Bitmap[] _secBitmaps = new Bitmap[] {
Bitmap.getBitmapResource("Seconds/1.png"),
Bitmap.getBitmapResource("Seconds/2.png"),
Bitmap.getBitmapResource("Seconds/3.png"),
Bitmap.getBitmapResource("Seconds/4.png"),
Bitmap.getBitmapResource("Seconds/5.png"),
Bitmap.getBitmapResource("Seconds/6.png"),
Bitmap.getBitmapResource("Seconds/7.png"),
Bitmap.getBitmapResource("Seconds/8.png"),
Bitmap.getBitmapResource("Seconds/9.png"),
Bitmap.getBitmapResource("Seconds/10.png"),

Bitmap.getBitmapResource("Seconds/11.png"),
Bitmap.getBitmapResource("Seconds/12.png"),
Bitmap.getBitmapResource("Seconds/13.png"),
Bitmap.getBitmapResource("Seconds/14.png"),
Bitmap.getBitmapResource("Seconds/15.png"),
Bitmap.getBitmapResource("Seconds/16.png"),
Bitmap.getBitmapResource("Seconds/17.png"),
Bitmap.getBitmapResource("Seconds/18.png"),
Bitmap.getBitmapResource("Seconds/19.png"),
Bitmap.getBitmapResource("Seconds/20.png"),

Bitmap.getBitmapResource("Seconds/21.png"),
Bitmap.getBitmapResource("Seconds/22.png"),
Bitmap.getBitmapResource("Seconds/23.png"),
Bitmap.getBitmapResource("Seconds/24.png"),
Bitmap.getBitmapResource("Seconds/25.png"),
Bitmap.getBitmapResource("Seconds/26.png"),
Bitmap.getBitmapResource("Seconds/27.png"),
Bitmap.getBitmapResource("Seconds/28.png"),
Bitmap.getBitmapResource("Seconds/29.png"),
Bitmap.getBitmapResource("Seconds/30.png"),

Bitmap.getBitmapResource("Seconds/31.png"),
Bitmap.getBitmapResource("Seconds/32.png"),
Bitmap.getBitmapResource("Seconds/33.png"),
Bitmap.getBitmapResource("Seconds/34.png"),
Bitmap.getBitmapResource("Seconds/35.png"),
Bitmap.getBitmapResource("Seconds/36.png"),
Bitmap.getBitmapResource("Seconds/37.png"),
Bitmap.getBitmapResource("Seconds/38.png"),
Bitmap.getBitmapResource("Seconds/39.png"),
Bitmap.getBitmapResource("Seconds/40.png"),

Bitmap.getBitmapResource("Seconds/41.png"),
Bitmap.getBitmapResource("Seconds/42.png"),
Bitmap.getBitmapResource("Seconds/43.png"),
Bitmap.getBitmapResource("Seconds/44.png"),
Bitmap.getBitmapResource("Seconds/45.png"),
Bitmap.getBitmapResource("Seconds/46.png"),
Bitmap.getBitmapResource("Seconds/47.png"),
Bitmap.getBitmapResource("Seconds/48.png"),
Bitmap.getBitmapResource("Seconds/49.png"),
Bitmap.getBitmapResource("Seconds/50.png"),

Bitmap.getBitmapResource("Seconds/51.png"),
Bitmap.getBitmapResource("Seconds/52.png"),
Bitmap.getBitmapResource("Seconds/53.png"),
Bitmap.getBitmapResource("Seconds/54.png"),
Bitmap.getBitmapResource("Seconds/55.png"),
Bitmap.getBitmapResource("Seconds/56.png"),
Bitmap.getBitmapResource("Seconds/57.png"),
Bitmap.getBitmapResource("Seconds/58.png"),
Bitmap.getBitmapResource("Seconds/59.png"),
Bitmap.getBitmapResource("Seconds/60.png") };

Bitmap bolt = Bitmap.getBitmapResource("Images/bolt.png");
Bitmap cover = Bitmap.getBitmapResource("Images/cover-(480x360).png");
public UpdateClockThread(Bitmap ourBitmap, Bitmap face,
ClockBitmapFiled fieldToInvalidate, Bitmap[] hourBitmaps,
Bitmap[] minBitmaps, Bitmap[] secBitmaps) {
super();
_cal = Calendar.getInstance();
_face = face;
_faceWidth = _face.getWidth();
_faceHeight = _face.getHeight()+50;
_ourBitmap = ourBitmap;
_g = new Graphics(_ourBitmap);
_ourField = fieldToInvalidate;

}

public void run() {
long timeToSleep = 0;
while (!_stopped) {
_g.setBackgroundColor(0x00191919);
_g.clear();
_g.drawBitmap(0, 0, _faceWidth, _faceHeight, _face, 0, 0);
_cal.setTime(new Date(System.currentTimeMillis()));
_curHr = _cal.get(Calendar.HOUR);
_curMin = _cal.get(Calendar.MINUTE);
_curHr = (_curHr * 5) + (5 * _curMin / 60);
if (_curHr > 60)
_curHr = _curHr - 60;
_curSec = _cal.get(Calendar.SECOND);


// Seconds Settings

_g
.drawBitmap(
(getWidth() - _secBitmaps[_curSec].getWidth()) / 2,
(getHeight() - _secBitmaps[_curSec].getHeight())/2+50 ,
_faceWidth, _faceHeight, _secBitmaps[_curSec],
0, 0);

// Mintes Settings

_g
.drawBitmap(
(getWidth() - _minBitmaps[_curMin].getWidth()) / 2+3,
(getHeight() - _minBitmaps[_curMin].getHeight()) / 5 ,
_faceWidth, _faceHeight, _minBitmaps[_curMin],
0, 0);

// Hours Settings

_g
.drawBitmap(
(getWidth() - _hourBitmaps[_curHr].getWidth()) / 2,
(getHeight() - _hourBitmaps[_curHr].getHeight() ) / 5+5,
_faceWidth, _faceHeight, _hourBitmaps[_curHr],
0, 0);


// Dot in center bolt

_g.drawBitmap((getWidth() - bolt.getWidth()) / 2,
(getHeight() - bolt.getHeight()) / 5+20, _faceWidth,
_faceHeight, bolt, 0, 0);

// cover on screen

_g.drawBitmap((getWidth() - cover.getWidth()) / 2,
(getHeight() - bolt.getHeight()) / 2-35 , _faceWidth,
_faceHeight, cover, 0, 0);



_ourField.invalidate();
timeToSleep = LONG_ONE_THOUSAND
- (System.currentTimeMillis() % LONG_ONE_THOUSAND);
if (timeToSleep > 20) {
try {
Thread.sleep(timeToSleep);
} catch (Exception e) {
}
}
}
}

public void stop() {
_stopped = true;
}
}
public Bitmap get_ourBitmap() {
return _ourBitmap;
}
}

 

 

 

Set had set this to blackberry mobile like below example...

 

public static void saveImageInDevice(Bitmap bitmap) {
JPEGEncodedImage encodedImage = JPEGEncodedImage.encode(bitmap, 100);
final byte[] imageBytes = encodedImage.getData();
FileConnection fc = null;
try {
fc = (FileConnection) Connector.open(
"file:///store/home/user/pictures/PendulumClock/",
Connector.READ_WRITE);

if (!fc.exists()) {
// if that path not exist. Create a directory
fc.mkdir();
}
// again open the connection to write the image data
fc = (FileConnection) Connector
.open(
"file:///store/home/user/pictures/PendulumClock/PendulumClock.jpg",
Connector.READ_WRITE);

if (!fc.exists()) {
fc.create();
// open output stream connection to convert bytes into image
// format
OutputStream os = fc.openOutputStream();
os.write(imageBytes);
os.close();
}
else
{
OutputStream os = fc.openOutputStream();
os.write(imageBytes);
os.close();
}
fc.close();
} catch (IOException e) {
e.printStackTrace();
} finally {
// if the connections are open close them
if (fc != null && fc.isOpen()) {
try {
fc.close();

} catch (IOException e) {
e.printStackTrace();
}
System.exit(0);
}
}
ApplicationDescriptor applicationDescriptor = new ApplicationDescriptor(
ApplicationDescriptor.currentApplicationDescriptor(),
new String[] { "refresh" });
ApplicationManager.getApplicationManager().scheduleApplication(
applicationDescriptor, System.currentTimeMillis() + 1, true);
}


}

 

But getting white screen as blackground........

 

kindly give solution with sample eamples....

 

 

Regrads,

saiswaroop.

 

 

 

 

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: I have developed analog clock,But i am enable to set that clock in Blackberry Home screen

[ Edited ]

UiApplications by default, have a white background.  There is nothing you can do about this.

 

If you search the forum you will find a number of 'solutions' or workarounds for this to including taking a screenshot for use as the background and displaying your image in a Global PopupScreen. 

 

Or alternatively, you could just create a Black Background like the usual clock. 

Highlighted
New Contributor
Posts: 7
Registered: ‎01-03-2012
My Device: 8900
My Carrier: Airtel

Re: I have developed analog clock,But i am enable to set that clock in Blackberry Home screen

can u send any sample  code or links in forums.....

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: I have developed analog clock,But i am enable to set that clock in Blackberry Home screen

You are already on the forum.  The Search box is near the top right hand corner. 

New Contributor
Posts: 7
Registered: ‎01-03-2012
My Device: 8900
My Carrier: Airtel

Re: I have developed analog clock,But I am enable to set that clock in Blackberry Home screen

Thank for great advise....