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
Highlighted
Regular Contributor
Posts: 83
Registered: ‎05-24-2011
My Device: Storm 9550
My Carrier: XXX
Accepted Solution

Cannot instantiate new object from custom class - no stack trace

Hi,

 

I have a bit of a maddening problem. I created a custom class called "Notification". When I try to create an instance of it, I get a no stack trace. Here is the class:

 

package net.creative.core.util;

import net.rim.device.api.system.Bitmap;

/**
 * These are the notification objects that are created and stored 
 * when a push notification is sent.
 * @author Heather
 *
 */

public class Notification {
	
	private String title; 
	private String content;
	private Bitmap image = Bitmap.getBitmapResource("appicon.png");
	
	public Notification(){
		title = "Title";
		content = "Content";
	}
	
	public Notification(String _title, String _content){
		title = _title;
		content = _content;
	}
	public Notification(String _title, String _content, Bitmap _image){
		title = _title;
		content = _content;
		image = _image;
	}
	public String getTitle(){
		return title;
	}
	public String getContent(){
		return content;
	}
	public Bitmap getImage(){
		return image;
	}
	public void setTitle(String _title){
		title = _title;
	}
	public void setContent(String _content){
		content = _content;
	}
	public void setImage(Bitmap _image){
		image = _image;
	}

}

 

I don't think this is an issue, but the screen I am trying to create an instance of in Notification is in the package com.creative.core. I have imported Notification to the screen though...Any ideas?

Regular Contributor
Posts: 83
Registered: ‎05-24-2011
My Device: Storm 9550
My Carrier: XXX

Re: Cannot instantiate new object from custom class - no stack trace

Never mind..just solved it.

Developer
Posts: 713
Registered: ‎05-31-2010
My Device: 8520
My Carrier: Movistar

Re: Cannot instantiate new object from custom class - no stack trace

And the code to instance your class ?

A suggestion, you can write your overrite constructors based in the most parameters used. I mean something like this :

public Notification() {
  this("Title", "Content");
}
	
public Notification(String _title, String _content) {
    this(_title, _content, null);
}
	
public Notification(String _title, String _content, Bitmap _image) {
  title = _title;
  content = _content;
  image = (_image == null) ?    Bitmap.getBitmapResource("appicon.png") : _image;
}