Tutorials & tips
BlackBerry - Twitter API and oAuth
by Me
I know it's a real pain in the ass this Twitter API and oAuth (even for me at the beginning) - So, I decided
to come up with this tutorial and the source code I use when I have to do this task.
I will try to explain how to fix some basic configuration problems.
1) Create an empty BlackBerry project and name it as you please.
2) Create the following
StartApp.java for starting your demo application.
3) Create the following
TwitterScreen.java for showing all the important Twitter stuff.
4) Import into your project, the following JAR files:
See below if you have troubles getting these JAR files to work!
Some common configuration problems
- BlackBerry is not recognizing your libraries (Twitter ME JAR files)
- 1) Edit your .classpath file
- 2) Make sure you add exported="true" to the for your JAR files
<classpathentry exported="true" kind="lib" path="lib/json-me.jar"/>
<classpathentry exported="true" kind="lib" path="lib/kxml2-min-2.3.0.jar"/>
<classpathentry exported="true" kind="lib" path="lib/twitter_api_me-1.8.jar"/>
Also in pastebin.com
BlackBerry - Autostart App
by Me
Sometimes you need to build applications witch must start when your BlackBerry starts and also
must make a difference when the user is seeing the screen **this is very important**
1) Before coding, you have to create your new BlackBerry Application (as usual).
2) if you use Eclipse, go to the App Descriptor XML and make sure you do the following:

3) Now place the following code:
import app.screen.MyAppScreen;
import net.rim.device.api.system.RuntimeStore;
public class MyApp extends net.rim.device.api.ui.UiApplication
{
private static final long APP_ID = 0xf46f5a7867d69ff0L;
public static void main(String[] args)
{
RuntimeStore runtimeStore = RuntimeStore.getRuntimeStore();
MyApp _myApp;
if (args != null && args.length > 0 && args[0].equals("gui"))
{
_myApp = (MyApp) runtimeStore.get(APP_ID);
if (_myApp != null)
{
doLog("Forground");
_myApp.requestForeground();
}
else
{
doLog("Create");
_myApp = new MyApp(true);
runtimeStore.put(APP_ID, _myApp);
_myApp.enterEventDispatcher();
System.out.println("dispatched");
}
}
else
{
doLog("Auto Start");
_myApp = new MyApp(false);
synchronized (runtimeStore)
{
runtimeStore.put(APP_ID, _myApp);
}
doLog("Added");
_myApp.enterEventDispatcher();
doLog("dispatched");
}
}
public MyApp(boolean isGui)
{
this.pushScreen(new MyAppScreen(isGui));
}
private static void doLog( String message )
{
System.out.println(":::::::: " + message);
}
}
4) The last Class you must add is the one you show to your users.
package app.screen;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.container.MainScreen;
public class MyAppScreen extends MainScreen
{
private LabelField label = new LabelField("Constructor...");
private boolean _isGui = false;
public MyAppScreen( boolean isGui )
{
_isGui = isGui;
if ( isGui ) add( label );
}
protected void onDisplay()
{
super.onDisplay();
if ( _isGui ) label.setText("On Display...");
}
}
BlackBerry - Repackage your Android apps for BlackBerry Playbook
by RIM
Follow the link below, you will learn -watching a short video- the way for
repackaging your Android app and make it ready for BB PlayBook.
Go to the short tutorial
BlackBerry Messenger - Definitive Official Guide for Developers
by RIM
Follow the link below, you can make your app social in the BlackBerry world.
As you already know, RIM has a close circle of communication using BlackBerry and
their unique PIN number. Using this and the private network for carriers, you
can make your applications more social, by communicating messages to users.
The BlackBerry® Messenger SDK
BlackBerry WebWorks and BBM Social Platform
Getting Started
This article provides a walkthrough of the required steps necessary to get started using the sample BlackBerry® WebWorks™? application distributed as part of the BlackBerry® Messenger Social Platform SDK for BlackBerry WebWorks. This sample application demonstrates the various capabilities of the BBM™? SDK that you can use within your own BlackBerry smartphone application development.
Tutorial and Download of source code
BlackBerry Simple Location API
Starting from OS 5.0
The Simple Location API is designed to include the following features:
- Simplified API with a focus on real world use cases.
- An API that leverages on-device GPS and RIM’s Locate Services.
- Dynamically detects available and supported location modes on the device before trying any of them.
- Has the ability to choose the best location mode based on the modes available on the smartphone.
- Built-in retry mechanism with dynamic delay (to save battery) based on a retry factor set by the API user.
- Performs both single and tracking location fixes.
- Simplified events via SimpleLocationListener interface.
- Capable of starting, stopping and restarting tracking sessions in a reliable thread-safe way.
- Designed to eliminate/reduce misuse of the API
Download
BlackBerry Porting Applications
From PlayBook to SmartPhone and viceversa
Very handy
post.
BlackBerry Web Applications
Some useful tips
Today I received the following question: What do I need to consider if I want to build a Web Application for BlackBerry?
And well, this answer has a lot to say. Let's start for the latest known technology available and then I'll talk about the
old stuff. Why? Becuase I always look for users to update their systems. Changes are complicated because we need to think more.
But changes are good. To change is to be better (it does not matter if something good or bad happens, a change is for good)
Ok, enough philosofy. Talking about the new stuff, let me say that RIM has full HTML5 support for all BlackBerry with OS 5.0 or
higher. That's all you need to know. From that, the only thing you need to see is a lot of tutorials about HTML5 and its
capability.
First: What about PHP?
You can use PHP as you do normally. The important thing is that your Server will send HTML to the browser.
Frameworks
jQueryMobile is an excellent Framework for developing both mobile and PC web-applications with easy.
There are some adjustments you need to do for some platforms. Use both PHP or Javascript for detecting this devices and
take descisions. Some of this considerations are:
For PC you have more horizontal space than for mobile phones. And that's an issue if you try to place items covering
all the screen. Another common problem is with long titles. On a PC you can use a long screen as title, but on small
devices, that text will be trimmed and your users will not be able to read it well.
So, be careful with this because it goes beyond any Framework capabilities. It's all about your app's design now.
Sencha has a lot more funcionality than jQuery. Try it and do all your tests because it has a lot to
offer. You will need to be prepared before the app reaches your users.
There are obviously other options very used for thousands of developers. The thing is that I'm not comfortable with them
and that's why I'm not talking about here.
Back to BlackBerry again, now I'll finally will talk about all OS before 5.0. RIM has no much there. 4.6 browsers are more
powerful than 4.5 but not that much...
Here's a list of resources you may consider before starting a Web application for blackBerry:
- Ripple (emulator): This Chrome Exension is now supported
by RIM. Is a complete and powerful Emulator which runs on Google Chrome and simulates a mobile device (also supports
RIM's PlayBook) and you can set pretty much everything to make it look real (GPS latency, different screen sizes, etc)
- Sencha Framework: What else can I say about this wonderful Framework? Just
download all the features and start enjoying and building apps with easy!
- HTML Reference - BlackBerry Browser: All you need to know about supported HTML tags for
different BlackBerry OSs.
- JavaScript Reference - BlackBerry Browser: All you need to know about what is
available and what is not for Javascript and its different OSs in BlackBerry.
- CSS Reference - BlackBerry Browser: All you need to know about what is
available and what is not for CSS and its different OSs in BlackBerry.
- Eclipse PLugin: As Web developer you can installa an Eclipse Plugin for testing your web applications
using all the power inside Eclipse. The best place for downloading tutorials about this and more source code is here.
Don't forget the HREF
You can do the usual stuff as Web Developer: Call phones and send emails, just by following a link. Here is the link
for those instructions:
BlackBerry HREF Links
The New era
No doubts about it. Developers right now are entering into the new PlayBook and HTML5 development. Using all the power of
WebWorks, which lets you compile a PlayBook application and also (the same source code) can be compiled for any BlackBerry
running OS5.0 and avobe.
If you want to use any special API for your Web Application and OS 5.0 (like GPS, memory, etc), well,
here is the complete list!
PlayBook Development
Tutorial, tips and all you need
I did this document resuming what it's the most important things you should have at hand when
you start doing some Playbook application.
I love the idea of RIM using HTML5 for application developent!
Open from Google Docs - This is a public shared document
SVN Online and Free
Check out this tutorial
It's not from me and it's nothing new, but I put it here in case you need it.
Free SVN and how to set it up
Sencha
Frameworks and More
Sencha is an Open Source community, building great frameworks for mobile. They have very useful products,
which you can download and enjoy. They have:
Ext JS 4
A Javascript Framework for Rich Apps in every
Ext GWT
Internet Application Framework for Google Web Toolkit
Ext Designer
Rapidly create rich Ext JS interfaces with Ext Designer.
Ext Core
JavaScript Library for enhancing websites.
Sencha Touch
Sencha Touch allows you to develop mobile web apps that look and feel native on iPhone,
Android, and BlackBerry touch devices.
View Examples.
Sencha Animator
Create amazing CSS3 animations with ease.
Sencha Website
AndEngine
Frameworks for 2D Games for Android
Zynga has long been an advocate of the open source community. For example, the key contributors behind cocos2D recently joined Zynga, and I’m proud to join in this tradition.
Rest assured that I will continue to support and contribute to the AndEngine open source project and I will continue to operate the blog and the forums. AndEngine will remain 100% free and open source!
AndEngine Website
Some Web Security
Hacker's Humble HandBook
I'll be writing down here some security advices you should read befor thinking your site
is secure.
It's not finished. There's ** a lot ** more to say. So, stay tunned for updates right here (RSS soon)
- Always have the latest version
That's the key for security. If your software is not up-to date, so be prepared
for several hackers to attack you, trying to get some valuable info.
- Be sure you have your important folders secured
The most common search is something like
this one. Hackers can use
Google to get all the important CGI-BIN folders without protection and read you configuration files
to get some users and passwords from your database.
- phpMyAdmin Google Dork
Google Dork is the slang term for a person who is fool enough to get caught insecure just by doing
a Google search. If you're not fully protected, anyone can query this
and get access to your phpMyAdmin site.
Other Dorks:
Password files
- Cross-site scripting
This is another easy and most-used way for hacking your site and content. It's all about writing Javascript on the
URL of any browser or using Plugins to make it easier (For example, Google's Chrome has a great tool for developers which can
be used for this task).
If you're looking for a definition on Cross-site scripting, go to the Wikipedia, where you will also find
some interesting samples.
Changing cookies values:
javascript:void prompt("Introduce la cookie:",document.cookie).replace(/[^;]+/g,function(_){document.cookie=_;});
This is another example for Cross-site...
It can be very dangerous, depending on your code and how much validation you're using.