Skip to content

Instantly share code, notes, and snippets.

View reflog's full-sized avatar

Eli Yukelzon reflog

View GitHub Profile
sync2
public static boolean SendSMS(String phone, String text){
try {
String smsurl = "sms://+"+phone;
MessageConnection conn =
(MessageConnection)Connector.open(smsurl);
TextMessage msgOut = (TextMessage) conn.newMessage(MessageConnection.TEXT_MESSAGE);
msgOut.setPayloadText(text);
Utils.log("sending to "+smsurl);
conn.send(msgOut);
return true;
public static synchronized String getAppVersion() {
ApplicationDescriptor descriptor = ApplicationDescriptor.currentApplicationDescriptor();
String version = descriptor.getVersion(); //read from the alx files
if(version == null || version.trim().equals("")) { //read value from jad file
CodeModuleGroup[] allGroups = CodeModuleGroupManager.loadAll();
String moduleName = ApplicationDescriptor.currentApplicationDescriptor().getModuleName();
if (moduleName == null || allGroups == null) {
return "1.0 (sim)"; // be default, for simulator
}
// Inherit your main window from this custom class:
@implementation MotionWindow
- (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event {
if (event.type == UIEventTypeMotion && event.subtype == UIEventSubtypeMotionShake) {
NSLog(@"Global Shake!");
[[NSNotificationCenter defaultCenter] postNotificationName:@"DeviceShaken" object:self];
}
}
- (void)setHtml:(NSString*)content{
NSString *r = [NSString stringWithFormat:@"<html><body style='background-color: transparent'>%@</body></html>", content,nil];
[calcview loadHTMLString:r baseURL:nil];
}
public boolean isNetworkAvailable() {
Context context = getApplicationContext();
ConnectivityManager connectivity = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
if (connectivity == null) {
return true;
} else {
NetworkInfo[] info = connectivity.getAllNetworkInfo();
if (info != null) {
for (int i = 0; i < info.length; i++) {
if (info[i].getState() == NetworkInfo.State.CONNECTED) {
getApplication().addGlobalEventListener(this);
public void eventOccurred(long guid, int data0, int data1, Object object0,
Object object1) {
if(guid != Main.NOTIFICATIONS_ID_1) return;
Utils.log("db changed, reloading list");
UiApplication.getUiApplication().invokeLater(new Runnable() {
public void run() {
try {
final String dir = System.getProperty("fileconn.dir.memorycard")+ "BlackBerry/SubFolder/";
public final static void createDir(String dir) {
FileConnection fconn;
try {
fconn = (FileConnection) Connector.open(dir,
Connector.READ_WRITE);
if (!fconn.exists())
import net.rim.device.api.system.Bitmap;
import net.rim.device.api.ui.Graphics;
import net.rim.device.api.ui.component.ButtonField;
/**
* Button field with a bitmap as its label.
*/
public class BitmapButtonField extends ButtonField {
private Bitmap bitmap;
private Bitmap bitmapHighlight;
File sd = new File(Environment.getExternalStorageDirectory() + File.separator + PDFFolder + File.separator + model.get(idx));
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.fromFile(sd));
intent.setDataAndType(Uri.fromFile(sd), "application/pdf");
try {
getContext().startActivity(intent);
}catch(ActivityNotFoundException e){
//Show a message that PDF viewer is not installed
}