BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 05-16-2007, 06:12 AM   #1 (permalink)
New Member
 
Join Date: May 2007
Model: 8707
PIN: N/A
Carrier: vodafone
Posts: 6
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default pushregistry

Please Login to Remove!

Hello
I am trying to make a application that will autostart on incoming sms:s.
I looked at the "How_To_-_Create_an_auto-start_MIDlet_using_the_PushRegistry" but I use the UIapplication not a MIDlet .
Can this be done?

Regards,
Olle
Offline  
Old 05-16-2007, 11:57 PM   #2 (permalink)
Talking BlackBerry Encyclopedia
 
Skipper_Joe's Avatar
 
Join Date: Jan 2007
Location: Kharkov, Ukraine
Model: 8300
Carrier: N/A
Posts: 237
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

It looks like you can do it via javax.wireless.messaging package: register your your UiApplication to start on device power up, implement and register MessageListener in the beginning.

I didn't do it myself, but just a suggestion.
Offline  
Old 06-15-2007, 10:44 AM   #3 (permalink)
New Member
 
Join Date: Jun 2007
Model: 8703e
PIN: N/A
Carrier: Iusacell
Posts: 2
Post Thanks: 0
Thanked 0 Times in 0 Posts
Red face PushRegistraty on 8703e

Hi we try to make the aplication start up whit a SMS, we now that posible with the PushRegistry capability, uor JAD file is the current:

Manifest-Version: 1.0
RIM-COD-Module-Name: PushRegistryApp
RIM-COD-Module-Dependencies: net_rim_cldc
MIDlet-Jar-Size: 4637
MIDlet-1: MIDlet PushRegistryApp,,PushRegistryApp
RIM-COD-Creation-Time: 1181920336
MIDlet-Jar-URL: PushRegistryApp.jar
RIM-COD-URL: PushRegistryApp.cod
RIM-COD-SHA1: 36 c5 2f fc c2 b4 f1 55 a6 9f ef 73 2b 9c bc bd 44 68 f0 dc
RIM-COD-Size: 3984
MicroEdition-Configuration: CLDC-1.1
MIDlet-Push-1: sms://:5012,PushRegistryApp, *
MIDlet-Permissions: javax.microedition.io.PushRegistry, javax.microedition.io.Connector.sms, javax.wireless.messaging.sms.receive,javax.wireles s.messaging.sms.send
MIDlet-Version: 0.9
MIDlet-Name: PushRegistryApp
MIDlet-Vendor: Research In Motion Ltd.
MicroEdition-Profile: MIDP-2.0
RIM-MIDlet-Flags-1: 0

and our JAVA souce is:

/*
* PushRegistryApp.java
*
*/

//package test.javax.microedition.midlet;

import javax.microedition.lcdui.*;
import javax.microedition.io.*;
import javax.microedition.midlet.*;
import java.util.*;
import java.io.*;
import javax.wireless.messaging.*;
public final class PushRegistryApp extends MIDlet
{

//The data we expect to receive.
private static final String TEST_DATA = "This is just a test";
private Display theDisplay;
private Form theForm;
private StringItem messages;
private MessageConnection mc;

public PushRegistryApp()
{
}

//Signals the MIDlet that it has entered the Active state.
public void startApp()
{
//Get the display object for this MIDlet.
theDisplay = Display.getDisplay(this);

//Instantiate the form.
theForm = new Form("PushRegistryApp");

//Istantiate the StringItem.
messages = new StringItem("", "starting...");

//Add the StringItem to the form.
theForm.append(messages);

//Open the SMS connection on port 5678.
try
{
mc = (MessageConnection)Connector.open("sms://:5012");
}
catch(IOException ioe){
System.out.println("Failed to open connection: "
+ ioe.toString());
}
//Create and start a new WorkerThread.
Thread t = new WorkerThread();
t.start();

theDisplay.setCurrent(theForm);
}

private class WorkerThread extends Thread
{
public void run() {
//Open the connection.
//Incoming data should be waiting.
String connection = getAppProperty("MIDlet-Push-1");

//The property is '<uri>, <midlet>, <filter>'
//so get just the uri.
connection = connection.substring(0, connection.indexOf(','));

//Get all connections registered with the PushRegistry
//for the current MIDlet suite.
String[] connectionsWithData =
PushRegistry.listConnections(true);

//Test all connections to locate the one matching "sms://5678".
for ( int i = connectionsWithData.length - 1; i >= 0; --i)
{
if ( connectionsWithData[i].equals(connection) )
{
//Found the matching connection.
//Fetch the incoming data.
fetchData(connection);
}
}

//Shut down to wait for data.
message("Done");
}
}

//Fetches the incoming data.
private void fetchData(String connection)
{
try
{
//Open the connection.
Connection c = Connector.open(connection);

if ( c instanceof StreamConnectionNotifier )
{
//Open an InputStream.
StreamConnectionNotifier scn = (StreamConnectionNotifier)c;
StreamConnection sc = scn.acceptAndOpen();
InputStream input = sc.openInputStream();

//Extract the data from the InputStream.
StringBuffer sb = new StringBuffer();
byte[] data = new byte[256];
int chunk = 0;
while ( -1 != (chunk = input.read(data)) )
{
sb.append(new String(data, 0, chunk));
}

//Close the InputStream and StreamConnection.
input.close();
sc.close();

String s = sb.toString();

//Test the data for validity.
//If invalid an exception is thrown.
Assert.assertTrue(TEST_DATA.equals(s),
"Failed to receive proper string: " + s);

//Display the received data.
message("Received: " + sb.toString());
}
} catch (IOException e)
{
message(e.toString());
}

}

//Display a String message to the user.
private void message(String msg)
{
//Display the message in the StringItem.
messages.setText(messages.getText() + "\n" + msg);
}

//Signals the MIDlet to stop and enter the Pause state.
public void pauseApp()
{
}

//Signals the MIDlet to terminate and enter the Destroyed state.
//Unconditional when set to true. The MIDlet must cleanup and release
//all resources.
//Otherwise, the MIDlet may throw a MIDletStateChangeException to
//indicate it does not want to be destroyed at this time.
public void destroyApp(boolean unconditional)
{
try
{
//Close the connection.
mc.close();
}
catch(IOException ioe)
{
System.out.println(ioe);
}
}
}

//Throws an IllegalStateException with the supplied error message.
final class Assert
{
private Assert()
{
}

static public void assertTrue(boolean exp, String failmsg)
{
if ( !exp) throw new IllegalStateException(failmsg);
}
}


We send the current sms : //wma:5012 message test......


But the aplication didint start Up ....

Can any Body help US..... please because the BlackBerry Suport cant.....
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





Copyright 2004-2014 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.