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
Developer
Posts: 285
Registered: ‎08-06-2010
My Device: Z10

Re: setPayloadText() issue

The reason why injection likely isn't working is that the user has not allowed the permission of "Input Simulation". You must request this prior to trying this method.

 

In general, I prompt users to paste the message themselves rather than request this permission.



Follow me on twitter @RileyGB - https://twitter.com/RileyGB
View my BB10 OpenSource projects - https://github.com/RileyGB/BlackBerry10-Samples
Contributor
Posts: 30
Registered: ‎10-07-2011
My Device: developer
My Carrier: HÍ

Re: setPayloadText() issue

thanks for it.

osm
Contributor
Posts: 13
Registered: ‎08-16-2010
My Device: Not Specified

Re: setPayloadText() issue

try this. 

It is working for me.

 

	private void sendSMS(String destAddr, final String smsText) {
			try {
				MessageConnection mc = (MessageConnection) Connector.open("sms://");
				TextMessage m = (TextMessage) mc.newMessage(MessageConnection.TEXT_MESSAGE);
				m.setAddress("sms://"+destAddr);
				Invoke.invokeApplication(Invoke.APP_TYPE_MESSAGES,
						new MessageArguments(m));
				
				Thread t = new Thread(new Runnable(){
					public void run() {
						synchronized (UiApplication.getUiApplication().getActiveScreen()) {
							Clipboard cb = Clipboard.getClipboard();
							cb.put(smsText);

							EventInjector.invokeEvent(new EventInjector.NavigationEvent(EventInjector.NavigationEvent.NAVIGATION_CLICK, 0, 0, KeypadListener.STATUS_SHIFT));
							
							}
					}
					
				});
				
				synchronized (this) {
					wait(300);
				}
				t.start();
			} catch (Exception e) {

			}
		}

 

Highlighted
Contributor
Posts: 30
Registered: ‎10-07-2011
My Device: developer
My Carrier: HÍ

Re: setPayloadText() issue

thanks for it