BlackBerry - How to start a messenger application? - blackberry

I would like to use gtalk or any other messenger in my application but i don't know how to do this.can u please give me idea about how to solve this one.if u can provide me some web link to know more about this.

BB KB - How To - Launch a third-party application from another third-party application
Try this for standard BB Messanger:
int mh = CodeModuleManager.getModuleHandle("net_rim_bb_qm_peer");
if (mh == 0) {
try {
throw new ApplicationManagerException(
"BB Messanger isn't installed");
} catch (ApplicationManagerException e) {
System.out.println(e.getMessage());
}
}
ApplicationDescriptor ad = CodeModuleManager
.getApplicationDescriptors(mh)[0];
ApplicationDescriptor ad2 = new ApplicationDescriptor(ad, null);
try {
ApplicationManager.getApplicationManager()
.runApplication(ad2, true);
} catch (ApplicationManagerException e) {
System.out.println(e.getMessage());
}
You can start any other app by module name, just replace
"net_rim_bb_qm_peer"
UPDATE And if you want examples of blackberry open source messengers, see:
BlackChat - ICQ chatting software
jmIrc - IRC MIDlet for mobile phones
WLIrc - IRC Client for Java cell phones or any other device who support java MIDP 1.0 (j2ME).

If you are also interested in developing on Android or iPhone platforms, you can build on top of Kik Messenger using Kik API. It lets you to piggyback rich media content and files over the Kik's own transport. The API itself is very simple to use - about 5 lines of code are needed to integrate it into your app. You may give it a shot here: http://www.kik.com/dev
Disclaimer: I am one of the developers behind Kik API :)

Related

how to share content from one activity to email or mobile or other applications using button.Click

I am using visual studio 2015 community and under c# node under android option I am creating one application. where On activity I have placed one button Named 'share' and after button click I want to share content of activity(intent's) to sent to other person using mail or WhatsApp or SMS. My question is How to do that.
please help.
I could able to sort out my own question using below codes.
private void Share_Click(object sender, EventArgs e)
{
var myIntent = new Intent(Intent.ActionSend);
myIntent.SetType("text/plain");
myIntent.PutExtra(Intent.ExtraSubject, "text");
myIntent.PutExtra(Intent.ExtraText, "text");
StartActivity(Intent.CreateChooser(myIntent, "Choose an App"));
}

Is there a Lync API for creating add-ons that run as soon as the user signs into Lync?

I can see custom menu items and custom conversation windows and events inside them but nothing referring to how you'd execute code once a user signs into Lync. Does such an API exist?
I guess my alternative would be creating a Lync Automation object/my own client using the Suppressed ui and building whatever features I want into one of those?
There's nothing you can build into the Lync application, but you could run a separate application which can subscribe to the SignIn state of the user. That way, you'd know when a user signs-in, and could take appropriate action. You wouldn't need to create a SuppressedUI application for that, just something that ran in the background, or taskbar or something.
Here's a bare bones example:
namespace ThoughtStuff
{
class Program
{
static void Main(string[] args)
{
var client = LyncClient.GetClient();
client.StateChanged += client_StateChanged;
}
static void client_StateChanged(object sender, ClientStateChangedEventArgs e)
{
if (e.NewState == ClientState.SignedIn)
{
//do something on sign in
}
}
}
}
You might get errors if you try and attach to Lync in the SDK code using LyncClient.GetClient() if the Lync exe isn't running...but if you know that's likely to be a problem (such as if your application might be running before the user starts Lync), then you can gracefully handle it and retry in code.

launch Blackberry app from link in mail

I can not be more clear with the title :D
Is it possible? to launch an application on a blackbeery just cliking on a "link" inside a mail? i read about taping a url and going to the application but this is much more specific.
thx in advance
Actually you can listen incoming emails.
You can implement menu item that will be available in mail app.
But you can also implement content handler with specific URI to launch your app.
All examples are available in BB samples.
Look in the RIM sample apps, more specifically HTTPFilterDemo.
You have to register a filter for the type of link you need the app to be triggered by (you'll need to put this code in the main method of you app):
HttpFilterRegistry.registerFilter("www.rim.com","com.rim.samples.device.httpfilterdemo.filter");
where "www.rim.com" is obviously the link that should open the app and the second parameter is the package that contains the "Protocol" class. The Protocol class has a callback method:
public Connection openFilter( String name, int mode, boolean timeouts ) throws IOException {
This method will be called each time the user clicks on a link that has the form specified by you. So, to open the app, in the "openFilter" method, do:
int modHandle = CodeModuleManager.getModuleHandle("YourAppModuleName");
ApplicationDescriptor[] apDes = CodeModuleManager.getApplicationDescriptors(modHandle);
try {
ApplicationManager.getApplicationManager().runApplication(apDes[0]);
} catch (ApplicationManagerException e) {
e.printStackTrace();
}

Authenticating via oAUTH with providers using Phonegap for Blackberry

We are currently working on the finishing touches of an application which uses Phonegap and have hit some issues with the Blackberry port.
So far, we've been reviewing the content available online and can't find a really finale answer to this. Seems like the "right" way to make and oauth authentication process for either Twitter, Facebook or Foursquare would be to use the ChildBrowser plugin, instantiate a window and then use that to handle the process.
Rightly so, there seems to be a lack of a ChildBrowser plugin for Blackberry. We've been looking so far at a couple of private projects on Github that look like they build/use that capability but we are not sure on how to control the created window.
Most (or all?) of those plugins refer to invoking the native Blackberry browser to handle the URLS, but then how would be manage to work on the callbacks, get the tokens and close the windows since it's another process.
For example, we have this concept code:
function openWindow() {
if (typeof blackberry !== 'undefined') {
app_id = SOMETHING_HERE;
redirect = 'http://www.facebook.com/connect/login_success.html';
url = 'https://graph.facebook.com/oauth/authorizeclient_id='+app_id+'&redirect_uri='+redirect+'&display=touch&scope=publish_stream';
var args = new blackberry.invoke.BrowserArguments(url);
blackberry.invoke.invoke(blackberry.invoke.APP_BROWSER, args);
}
}
Which works for opening the URL, but that's it. Is there a way to get a handle on the window and inject some listener to events? What should be our correct approach?
Thanks!
I am not PhoneGap user, but we did have to handle a very similar scenario - native app invokes the mobile browser to prompt the oAuth flow and then be able to handle a callback to the aative app.
This is possible on the BlackBerry using the BrowserContentProviderRegistry API. You can register your app to be invoked whenever a particular MIME type is returned to the browser. Sounds complicated but its fairly straightforward when all the pieces are in play.
Here is the rough flow -
Native app invokes browser to the oAuth page. This is part is easy and seems like you got this part.
The oAuth redirect needs to go to a URL that you can control. Something like http://mycompany.com/oAuthRedirectHandler.asp.
The oAuthRedirectorHandler.asp has simple code like this (we chose classic ASP but this can be done in PHP or any language, you can also ignore the Android block below) -
<html><body>
<h1>Redirect page</h1>
If you are not re-directed, please open the application manually.
<% strUA = Request.ServerVariables("HTTP_USER_AGENT")
if (InStr(strUA, "BlackBerry")) then
Response.Write("Opening appplication on BlackBerry")
Response.ContentType="application/x-MyCustomApp"
elseif (InStr(strUA, "Android")) then
Response.Write("Opening appplication on Android")
Response.Redirect("MyCustomApp://mycompany.com")
end if %>
</body> </html>
In your BlackBerry code you want a new BrowserContentProvider like this -
final class CustomBrowserProvider extends BrowserContentProvider{
String[] ACCEPT = new String[]{"application/x-MyCustomApp};
String appName;
CustomBrowserProvider(String appName){
this.appName = ApplicationDescriptor.currentApplicationDescriptor().getModuleName();
//cache this appName from the constructor in the invocation code below.
}
public String[] getSupportedMimeTypes() { return ACCEPT;}
public String[] getAccept(RenderingOptions context){return ACCEPT;}
public BrowserContent getBrowserContent( BrowserContentProviderContext context) throws RenderingException {
//this is where the callback happens
//this is happening in a separate process, raise your main app here using the appName that got passed in
//I dont have a sanitized ready to go sample to post here on how to do this, but not too complicated
//as a hint use the ApplicationDescriptor and CodeModuleManager classes
return null;
}
}
Now, in your application initialization, register this new BrowserPlugin like this -
BrowserContentProviderRegistry converterRegistry = BrowserContentProviderRegistry.getInstance();
converterRegistry.register(new CustomBrowserProvider());
Hope this helps. This has worked pretty well for us. The one downside we've had here is that when the user returns to the browser app, they are left with an empty page and there is no good way to close that in the BB.

Obtaining cellsite gps location on Blackberry Curve 8520

Details of my phone:
Model:Blackberry Curve 8520
Version :5.0.0.1036
data services :on
When I am installing google maps I am able to see the location ,so there is a chance of obtaining the current location using this phone.
I am trying to develop an application which will show the current location of the phone,by using the cell site locations because this phone model does not have an in-built GPS device.
I am using the following code:
BlackBerryCriteria bc=new BlackBerryCriteria(GPSInfo. GPS_MODE_CELLSITE );
try {
LocationProvider lp=LocationProvider.getInstance(bc);
if(lp !=null)
{
Location loc=lp.getLocation(-1);
add (new EditField(loc.getQualifiedCoordinates().getLatitude()+"\n"+loc.getQualifiedCoordinates().getLongitude(),""));
}
else
{
add(new EditField("unable to find the location provider", ""));
}
} catch (LocationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}}
I am installing the alx file on the bb phone using desktop manager.
On starting the application it is giving me an Uncaught exception:
NET.RIM.DEVICE.API.SYSTEM.UNSupportedOperationException.
The device might currently not support GPS_MODE_CELLSITE. Check using
GPSInfo.isGPSModeAvailable(GPS_MODE_CELLSITE)
and use another mode if neccessary.
It might not support GPS_MODE_CELLSITE because:
There is no valid SIM card in your phone (ok, i assume you have one :)
Check if your device and carrier have available GPS mode you are using (here)
If your carrier is Verizone, check for Verizon GPSSettings signing requirement
Your APN settings are not correct (Options > Device > Advanced Settings > TCP IP)
You don't have a BlackBerry Service Plan (not too sure about that one)

Resources