MessageSender mgsSender = new MessageSender(); new AsyncTask<Void, Void, Void>() { @Override protected Void doInBackground(Void... params) { MessageSenderContent mgsContent = createMegContent(registration_Id, your_title); mgsSender.sendPost(mgsContent) return null; } }.execute();
MessageSender mgsSender = new MessageSender(); new AsyncTask<Void, Void, Void>() { @Override protected Void doInBackground(Void... params) { mgsSender.sendPost(mgsContent); } return null; } }.execute();
data.setMsg(msg); java.io.StringWriter sw = new StringWriter(); Marshaller.marshal(data, sw); xmlString = sw.toString(); MessageSender msgsender = new MessageSender(); msgsender.sendMessageToApplication(xmlString);
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_user_list); content = (TextView)findViewById(R.id.output); content.setText("Select user to chat:"); refreshButton = (Button)findViewById(R.id.refreshButton); intent = new Intent(this, GCMNotificationIntentService.class); registerReceiver(broadcastReceiver, new IntentFilter("com.javapapers.android.gcm.chat.userlist")); messageSender = new MessageSender(); gcm = GoogleCloudMessaging.getInstance(getApplicationContext()); refreshButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { // get user list Bundle dataBundle = new Bundle(); dataBundle.putString("ACTION", "USERLIST"); messageSender.sendMessage(dataBundle, gcm); } }); unregisterReceiver(broadcastReceiver); }
static CompletableFuture<IMessageSender> createMessageSenderFromEntityPathAsync(URI namespaceEndpointURI, String entityPath, MessagingEntityType entityType, ClientSettings clientSettings) { Utils.assertNonNull("namespaceEndpointURI", namespaceEndpointURI); MessageSender sender = new MessageSender(namespaceEndpointURI, entityPath, null, entityType, clientSettings); return sender.initializeAsync().thenApply((v) -> sender); }
static CompletableFuture<IMessageSender> createMessageSenderFromEntityPathAsync(MessagingFactory messagingFactory, String entityPath, MessagingEntityType entityType) { Utils.assertNonNull("messagingFactory", messagingFactory); MessageSender sender = new MessageSender(messagingFactory, entityPath, entityType); return sender.initializeAsync().thenApply((v) -> sender); }
/** * Creates a transfer message sender asynchronously. This sender sends message to destination entity via another entity. * * This is mainly to be used when sending messages in a transaction. * When messages need to be sent across entities in a single transaction, this can be used to ensure * all the messages land initially in the same entity/partition for local transactions, and then * let service bus handle transferring the message to the actual destination. * @param messagingFactory messaging factory (which represents a connection) on which sender needs to be created. * @param entityPath path of the final destination of the message. * @param viaEntityPath The initial destination of the message. * @return a CompletableFuture representing the pending creating of IMessageSender instance. */ public static CompletableFuture<IMessageSender> createTransferMessageSenderFromEntityPathAsync(MessagingFactory messagingFactory, String entityPath, String viaEntityPath) { Utils.assertNonNull("messagingFactory", messagingFactory); MessageSender sender = new MessageSender(messagingFactory, viaEntityPath, entityPath, null); return sender.initializeAsync().thenApply((v) -> sender); }