android-developers
[Arriba] [Todas las Listas]

Re: [android-developers] Cómo para poner mqtt payload a variable

To: android-developers@xxxxxxxxxxxxxxxx
Subject: Re: [android-developers] Cómo para poner mqtt payload a variable
From: Marina Cuello <marina.eariel@xxxxxxxxx>
Date: Thu, 3 Aug 2017 10:06:54 -0300
Arc-authentication-results: i=2; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=S3M4ByJP; spf=pass (google.com: domain of marina.eariel@xxxxxxxxx designates 2a00:1450:400c:c09::236 as permitted sender) smtp.mailfrom=marina.eariel@xxxxxxxxx; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com
Arc-authentication-results: i=1; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=S3M4ByJP; spf=pass (google.com: domain of marina.eariel@xxxxxxxxx designates 2a00:1450:400c:c09::236 as permitted sender) smtp.mailfrom=marina.eariel@xxxxxxxxx; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com
Arc-message-signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:reply-to:to:subject:message-id:date :from:references:in-reply-to:mime-version:arc-authentication-results :arc-message-signature:sender:dkim-signature:dkim-signature :arc-authentication-results; bh=tadkRXTFmB31JB63hKEXM2trOSaipcU47DmJaqzrZVc=; b=Y6cCbNOe90KMhfXQcxGez+eVEu3yMGlmETPEh1p+5bYRkvMrJMNiFqKOsgK7zjGbGv 9CbD7rRc78jSt8z8mhBNTK6paYeXOxO+Rb7WjZctsioUULt7hiwWr876n5IOR6b/bvxW owdJhqh9DMaj4QIDBV2JBRhr8/tGLO1rZSCTNlTv0gLNOB/LTpGQif2qsah4FyUXA3cf JuEdYof9RnKBDEO+BnHY5wdqgYCUU2kZZoueifRpw7IblMN6tZRhFJdK+IfTbRvG6Ypg FRf5Y3spmz+ZZznZMzTrkxhXhLQVfpzVXhmhUFgPLhqaMotTde2YufAceX6SzWZWE3TW UNIA==
Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=to:subject:message-id:date:from:references:in-reply-to:mime-version :dkim-signature:arc-authentication-results; bh=ZoWTkhAI+IjQV3B8yYImdHDy0YbRLrB9vbSl/C3mw2o=; b=ntIM7GOJpPdEg7GjFubqzppb2H1tH81dlL9ni6R9LyaqgWAhhJiGROZzJO9SQamJnr KY5BPIT+MRLM3kPUvWzNzvHl3eITxdlpLwymD8r4UMmb6RWiIaUhOwHV1y9tKjolqtia SKaqN32FW6GbRqhjN07Hy3VDUBtvGmiOiSM+Q//5Vdd6tkYMQjn+6ooxZLzWDuETX00C 9dMmlKI/RBA23RgvGPR2Yb6s3G5Apb7nq1me8bjvnmXxTkqGvekkh2IUyYNQ4d8uEi+B rUmldwP1G3h2L8k84zzq7r2IlNTORJ85PHzgy7DjFIKiwmkSOzS/yeLrO0M9LSl7fZ2r 6tww==
Arc-seal: i=2; a=rsa-sha256; t=1501765692; cv=pass; d=google.com; s=arc-20160816; b=fNoUf38Ko68VjJTMWEuTcFp6MZf7a+YEO6aVCtPUAg1Ww5WhIneZaTGHhCRgD7Hwa2 TeOY8XEwJ8ERhb71a+iWiDWlEQqE2hTu5+mN1nS42sxUwGpZfZwqSPNb3YG5K/MV5P0Q XXfXg4H+ybgSVkUUBdgTXBg03I51K8flSYgYH27VURirupUtzvW2bhPXKWVMTpY2dZrF HTqaJ++kEyiKf+JKdDYLHKJ5au4UB0c4bJym9UZefc1UAma/TbFLncnFglFyX7LJKhAI sTAfHgGrJl4N+bVO4x8i1YMA8yEc1HZjlpS/VFI6ZaMcHFd3vwKctlSqpqzEkGcdnBwm I8uw==
Arc-seal: i=1; a=rsa-sha256; t=1501765635; cv=none; d=google.com; s=arc-20160816; b=EhlRLs4wb2ETyiJGtieZ9ruBHwe1DiapQiyfh+cfXt2Tw2TcvqPAND8NWC5NG3LmgU GvIWHntIVvxTg/sqcEIPL22glbupWeOtVFK9ccJTKyvBcxo5aCSiFrT4x+5P1fcS5aDe h98JRDNeFjNrRfwYoSG5PlzUUf4E+QT4KhBsKnxFibEOvkuIPwp2wlFzwdaAz9ZbWQQs nQyVosl1orK1uvkRxvqJYnxd0Ukd5QdzmwjTC/TwzcbfeI89E0avXa5+jKcyRa2pcwRb EnrqN4F8TAlmQ0C63FpFEviuXfnXbGOvp1uaLng3iSVUqhmHmdn8IPDQNsfZOfgmz7zU vQ9w==
Delivery-date: Thu, 03 Aug 2017 09:08:18 -0400
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:mime-version:in-reply-to:references:from:date:message-id :subject:to:x-original-sender:x-original-authentication-results :reply-to:precedence:mailing-list:list-id:list-post:list-help :list-archive:list-subscribe:list-unsubscribe; bh=tadkRXTFmB31JB63hKEXM2trOSaipcU47DmJaqzrZVc=; b=KZGBJ1SpLsCd2cmo5kT6eX5tRc2rOq3FRx7wMdbGb9ZMeau6HyjY0lpG5OR6i7Qio+ ZaRz0nZ7pz7gi4f9TpV22MS4lrNmYnb404x7+cgNWZu5PTqFhmTz+V7ayGYR0mk9eSFn j/wOStd9pokfk2SBsZ6C3GzXM94lsmA3m3NZ3a+GXpWs1szxtwMq0ycA5KushFo0P08h HFisN9Uu4AcJZR3HG//pwcvftgfLD/RkIH/WwTtVbhridIENCxqFhing1w42+wC2Q/GU jn/A/i9f0tYLedC5DfQaM/myI0hCy+8HcWTzISHZ7dtLxtY+5Q9HW9CnKplOxj2SZqV3 ovcA==
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :x-original-sender:x-original-authentication-results:reply-to :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=tadkRXTFmB31JB63hKEXM2trOSaipcU47DmJaqzrZVc=; b=WsVaXgFB399Sjgs6Vs3krxNY1RQN/d+KjxWWx12DAGa5BfNJCgaPdGVVOOcVl6ViZR SNtkyJ8ecdJ9tIJoDRX/wFuv+u6qkHAGvD1L8Z21q4tKN3FmcVZCz3QguwOSKRK1iy4T E4gm4dZUz+cx73+R2KX4fUvE4e7WOogcPUBrRwOrsb/jkz0UtLzf5IAbqjsxX9an3+Ac 3yAgx3uC6EtBAVPB4ZoGvwvYr7Ka8k+vvYocTfujFRQzOW86E1DBvWgcdhaEUTW76pra SjZCD7EYThR+hRxikZvh9D4byn0eY/R0wYpYTEOwbofFkCjVnULeKrfCK5e6YI1eTnFS V4pw==
Envelope-to: traductor@xxxxxxxxxxx
In-reply-to: <1ffedcf4-be81-4ed5-acbd-5067172fb79b@googlegroups.com>
List-archive: <https://groups.google.com/group/android-developer>
List-help: <https://groups.google.com/support/>, <mailto:android-developers+help@googlegroups.com>
List-id: <android-developers.googlegroups.com>
List-post: <https://groups.google.com/group/android-developers/post>, <mailto:android-developers@googlegroups.com>
List-subscribe: <https://groups.google.com/group/android-developers/subscribe>, <mailto:android-developers+subscribe@googlegroups.com>
List-unsubscribe: <mailto:googlegroups-manage+364598216046+unsubscribe@googlegroups.com>, <https://groups.google.com/group/android-developers/subscribe>
Mailing-list: list android-developers@xxxxxxxxxxxxxxxx; contact android-developers+owners@xxxxxxxxxxxxxxxx
References: <1ffedcf4-be81-4ed5-acbd-5067172fb79b@googlegroups.com>
Reply-to: android-developers@xxxxxxxxxxxxxxxx
Sender: android-developers@xxxxxxxxxxxxxxxx
Busqué *MqttMessage en *Google y parece como *getPayload() te
da un *byte variedad.

Tan si sabes que podría ser una Cadena que dice "conectado", justo
necesitas comparar las cadenas.

Mensaje de cadena = Cadena nueva(mensaje.*getPayload());
Si(mensaje.*equals("Conectado"))
// #pro_verbcj #embutir también podría comprobar *equalsIgnoreCase si no sabes la capitalización.

Si aquello "conectado" no es una cadena pero él es en alguna clase de objeto, estoy
adivinando necesitarás utilizar *serialization. Pero justo estoy utilizando sencillo *Java
conocimiento, no sé vuestro proyecto.

Marina



En *Wed, *Aug 2, 2017 en 4:53 PM, MOHAMMED *ashfaq <*ashfaaaa1@*xxxxxxxxx> escribió:

> hola *im nuevo a *android el desarrollo podría alguien complace ayudarme con abajo
> código. *i Quiere hacer si declaración del *mqtt *payload . Cómo puede *i
> marca *playload = conectó entonces espectáculo es *Textview
>
> ```
> público *void *messageArrived(tema de Cadena, *MqttMessage mensaje) echa
> Excepción
> #unknown{^*subText.*setText(Cadena nueva(mensaje.*getPayload()));
> // *Vibrator.*vibrate(500);
> }
> ```
>
> --
> recibiste este mensaje porque eres *subscribed al *Google Grupos
> "*Android *Developers" grupo.
> A *unsubscribe de este grupo y la parón que recibe *emails de él, enviar un
> *email a *android-*developers+unsubscribe@xxxxxxxxxxxxxxxx.
> A correo a este grupo, envía *email a *android-developers@xxxxxxxxxxxxxxxx.
> Visita este grupo en *https://grupos.*google.*com/Grupo/*android-*developers.
> Para ver esta discusión en la visita de web *https://grupos.*google.*com/*d/
> *msgid/*android-*developers/1*ffedcf4-ser81-4*ed5-*acbd-
> 5067172*fb79*b%40*googlegroups.*com
> <*https://Grupos.*google.*com/*d/*msgid/*android-*developers/1*ffedcf4-ser81-4*ed5-*acbd-5067172*fb79*b%40*googlegroups.*com?*utm_Medio=*email&*utm_fuente=*footer>
> .
> Para más opciones, visita *https://grupos.*google.*com/*d/*optout.
>

-- 
Recibiste este mensaje porque eres *subscribed al *Google Grupos "*Android *Developers" grupo.
A *unsubscribe de este grupo y la parón que recibe *emails de él, enviar un *email a *android-*developers+unsubscribe@xxxxxxxxxxxxxxxx.
A correo a este grupo, envía *email a *android-developers@xxxxxxxxxxxxxxxx.
Visita este grupo en *https://grupos.*google.*com/Grupo/*android-*developers.
Para ver esta discusión en la visita de web *https://grupos.*google.*com/*d/*msgid/*android-*developers/*CACaNmX2*CZozqnhVs%3*D1*t948*RfAtMEobF6*feGvOWQ4*BFRxFQ%2*BWTQ%40correo.*gmail.*com.
Para más opciones, visita *https://grupos.*google.*com/*d/*optout.
I looked for MqttMessage on Google and it seems like getPayload() gives you
a byte array.

So if you know that it could be a String that says "connected", you just
need to compare the strings.

String message = new String(message.getPayload());
if(message.equals("connected")) {
// Do stuff
}

You could also check equalsIgnoreCase if you don't know the capitalization.

If that "connected" is not a string but it's on some kind of object, I'm
guessing you'll need to use serialization. But I'm just using simple Java
knowledge, I don't know your project.

Marina



On Wed, Aug 2, 2017 at 4:53 PM, MOHAMMED ashfaq <ashfaaaa1@xxxxxxxxx> wrote:

> hello im new to android development could someone please help me with
> below code. i want to make if statement from the mqtt payload . how can i
> make playload = connected then show it is Textview
>
> ```
> public void messageArrived(String topic, MqttMessage message) throws
> Exception {
> subText.setText(new String(message.getPayload()));
> // Vibrator.vibrate(500);
> }
> ```
>
> --
> You received this message because you are subscribed to the Google Groups
> "Android Developers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to android-developers+unsubscribe@xxxxxxxxxxxxxxxx.
> To post to this group, send email to android-developers@xxxxxxxxxxxxxxxx.
> Visit this group at https://groups.google.com/group/android-developers.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/android-developers/1ffedcf4-be81-4ed5-acbd-
> 5067172fb79b%40googlegroups.com
> <https://groups.google.com/d/msgid/android-developers/1ffedcf4-be81-4ed5-acbd-5067172fb79b%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups "Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-developers+unsubscribe@xxxxxxxxxxxxxxxx.
To post to this group, send email to android-developers@xxxxxxxxxxxxxxxx.
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/android-developers/CACaNmX2CZozqnhVs%3D1t948RfAtMEobF6feGvOWQ4BFRxFQ%2BWTQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
<Anterior por Tema] Tema Actual [Siguiente por Tema>