[android-developers] Re: send message from class to activity

2013-08-01 Thread Gary Blakely
Piren,
Thanks for your answer.  After reading up on the Observer pattern as you 
suggested, I ended up using propertyChange listener.  It seems to be a 
handy conduit to trigger an event in an activity from a broadcast receiver.
Thanks,
Gary

On Sunday, July 28, 2013 11:41:21 PM UTC-7, Piren wrote:
>
> An Activity, like BroadcastReceiver is a class, so you've done it before. 
> You just did it using existing mechanisms that make it simpler for you.
>
> You should read up on how to use BroadcastReceiver to send messages (it 
> can listen to whatever you want), though the LocalBroadcastReceiver should 
> be used instead.
> You can also read up on the more general Observer Pattern and how to 
> implement it.
>
> On Monday, July 29, 2013 2:30:12 AM UTC+3, Gary Blakely wrote:
>>
>> I have a class named SMSReceiver that extends BroadcastReceiver.  I 
>> instantiate an object of this class from the onCreate event in 
>> mainActivity.  SMSReceiver listens for stuff and when it finds what it 
>> wants it needs to send a data message back to the Activity and trigger some 
>> event in the activity that will handle it.  SMSReceiver has to stay 
>> instantiated as long as the app is running.
>>
>> I've googled around all over but can't seem to find anything that works. 
>>  I have done a lot of messaging between services and activities but never 
>> from a class back to the activity that instantiated it.  I see a lot of 
>> info on using intents to do this but nothing that would accomplish what I 
>> need to do.
>>
>> What is the best way to accomplish this?
>> Thanks,
>> Gary
>>
>>

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[android-developers] Re: send message from class to activity

2013-07-28 Thread Piren
An Activity, like BroadcastReceiver is a class, so you've done it before. 
You just did it using existing mechanisms that make it simpler for you.

You should read up on how to use BroadcastReceiver to send messages (it can 
listen to whatever you want), though the LocalBroadcastReceiver should be 
used instead.
You can also read up on the more general Observer Pattern and how to 
implement it.

On Monday, July 29, 2013 2:30:12 AM UTC+3, Gary Blakely wrote:
>
> I have a class named SMSReceiver that extends BroadcastReceiver.  I 
> instantiate an object of this class from the onCreate event in 
> mainActivity.  SMSReceiver listens for stuff and when it finds what it 
> wants it needs to send a data message back to the Activity and trigger some 
> event in the activity that will handle it.  SMSReceiver has to stay 
> instantiated as long as the app is running.
>
> I've googled around all over but can't seem to find anything that works. 
>  I have done a lot of messaging between services and activities but never 
> from a class back to the activity that instantiated it.  I see a lot of 
> info on using intents to do this but nothing that would accomplish what I 
> need to do.
>
> What is the best way to accomplish this?
> Thanks,
> Gary
>
>

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [android-developers] Re: Send message with C2DM to selected devices

2011-09-20 Thread Robin Talwar
try not to get auth token everytime

better you cache it or the google server will add captcha in process and u
cant get to captcha through the code. You would have to do some python stuff
for that i am not really clear about it. Hence better u save the
authentication token

On Tue, Sep 20, 2011 at 6:33 PM, Jens  wrote:

> Each device has its own registration ID so you can push messages to a
> specific device.
>
> On Sep 19, 9:24 am, Joshua Partogi  wrote:
> > hi there,
> >
> > I am interested to use C2DM for my application. Is it possible to send
> push
> > messages to selected devices only? Or will it send to all devices that
> has
> > my application?
> >
> > Thank you in advance for your help.
> >
> > --
> > @jpartogi
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>



-- 
Regards
Abhishek Talwar
9953395712

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] Re: Send message with C2DM to selected devices

2011-09-20 Thread Jens
Each device has its own registration ID so you can push messages to a
specific device.

On Sep 19, 9:24 am, Joshua Partogi  wrote:
> hi there,
>
> I am interested to use C2DM for my application. Is it possible to send push
> messages to selected devices only? Or will it send to all devices that has
> my application?
>
> Thank you in advance for your help.
>
> --
> @jpartogi

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Send message with C2DM

2011-04-20 Thread Finn Johnsen
hi

strikes me as a network or firewall problem maybe. from your dev pc i
guess. as its complaining about not reaching mtalk.google.com at that
port.

dont know, just thinking loud.
finn



On Apr 15, 1:57 pm, vokvince  wrote:
> Hello,
>
> I'm working on C2DM, my registration is ok but when I send a message
> with my server, my phone don't receive it.
> My servor return an id =>  id=0:1302860724014808%cacdd2750031
> And in the logcat i've:
>
> 04-15 13:53:25.889: WARN/GTalkService(2672): [GTalkConnection.12]
> doConnect: caught XMPPError connecting to mtalk.google.com:5228.:
> (502)
>
> 04-15 13:53:25.889: WARN/GTalkService(2672):   -- caused by:
> java.net.SocketTimeoutException: Transport endpoint is not connected
>
> Someone can help me please ? How find the issue ? Is it the server or
> the mobile ?
>
> Thx a lot !

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Send message from Android emulator to web

2009-11-20 Thread andu
Thank you.  your response helps me very much.

In addition I found a working code from the internet. It may help ...

# public void postData() {
# // Create a new HttpClient and Post Header
# HttpClient httpclient = new DefaultHttpClient();
# HttpPost httppost = new HttpPost("http://www.yoursite.com/
script.php");
#
# try {
# // Add your data
# List nameValuePairs = new
ArrayList(2);
# nameValuePairs.add(new BasicNameValuePair("id", "12345"));
# nameValuePairs.add(new BasicNameValuePair("stringdata",
"AndDev is Cool!"));
# httppost.setEntity(new UrlEncodedFormEntity
(nameValuePairs));
#
# // Execute HTTP Post Request
# HttpResponse response = httpclient.execute(httppost);
#
# } catch (ClientProtocolException e) {
# // TODO Auto-generated catch block
# } catch (IOException e) {
# // TODO Auto-generated catch block
# }
# }

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Send message from Android emulator to web

2009-11-19 Thread Nithin
Hi,

HttpUrlConnection is for just to manage HTTP connection. For sending
data to server , use HttpClient, HttpPost, HttpEntity etc. I will give
a very brief idea about this.

DefaultHttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost();
post.setEntity(httpEntity);
HttPResponse response = client.execute(post);
HttpEntity respEntity = response.getEntity();

This is a very brief code snippet. You have to modify according to
your requirement. And there are lot of other ways to do this. This is
just one way to do.

Thanks

On Nov 19, 4:38 pm, andu  wrote:
> I have been trying to send message from the android emulator to the
> web server by using HttpURLConnection. In the server side I use php to
> read the sent message and keep it in database (mysql). when I send the
> message, a blank row is added in the database, but the message sent
> doesn't appear. I think the emulator can communicate with the server
> but I don't know what happens to the message. Please help me.
>
> Here is my Android and PHP code:
>
>         URL url = new URL("http://10.0.2.2/receiveSampleAndroid.php";);
>
>         HttpURLConnection httpCon = (HttpURLConnection)url.openConnection();
>         httpCon.setDoInput(true);
>         httpCon.setDoOutput(true);
>         httpCon.setRequestMethod("POST");
>         httpCon.setUseCaches(false);
>         httpCon.setRequestProperty("Connection", "Keep-Alive");
>         DataOutputStream out = new DataOutputStream(httpCon.getOutputStream
> ());
>         DataInputStream in      = new 
> DataInputStream(httpCon.getInputStream());
>
>         String value = "msg content";
>         String Boundary = "`";
>         out.write(value.getBytes());
>         out.write(Boundary.getBytes());
>         out.flush();
>
>         int responseCode = httpCon.getResponseCode();
>
>         switch(responseCode)
>         {
>                 case HttpURLConnection.HTTP_OK:
>                 case HttpURLConnection.HTTP_CREATED:
>                         Toast.makeText(getBaseContext(), "Message is sent",
> Toast.LENGTH_LONG).show();
>                         int httpReslut = 1;
>                         int ch;
>                         in.readByte();
>                         in.readByte();
>                         in.readByte();
>                         break;
>
>                 default:
>                         //not ok
>         }
>
>         httpCon.disconnect();
>         in.close();
>         out.close();
>
> My PHP Code is:
>
> 
> if(isset($_POST))
> {
>
> $string = file_get_contents('php://input');
> $boundary = "`";
> $data = explode($boundary,$string);
>
> /**
> Content of the Message is Store in local variable
> ***/
>
> $id = $data[0];
>
> $name = $data[1];
>
> $fname = $data[2];
>
> /**
> Connect to database, Sample_android and
>
> ***/
>
> mysql_connect("localhost","root","root") or die("Server Connection
> Error");
> mysql_query("use sample_android") or die("Can not communicate with the
> database.");
>
> //Insert patient record in patient_record table
> $sql_InsertPatientRecord = "insert into sample(id, name, fname) values
> ('$id', '$name', '$fname')";
> mysql_query($sql_InsertPatientRecord);
> mysql_close();
> echo "Message is inserted";
>
> }
>
> ?>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Send message

2008-12-04 Thread andrex

I solved, Just look the class notification, and notificionManager, if
somebody has a quesuion about how, just ask
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Send message

2008-11-27 Thread Stefan Selariu
Hi Andrex,
I don't think that the emulator support sending SMSs to the same emulator.
I tried this using the Mms.apk

On Wed, Nov 26, 2008 at 7:11 PM, andrex <[EMAIL PROTECTED]> wrote:

>
> Hi Stefan thanks, but Can I send me a message, to the emulator how run
> the application? or what can I do if i want to send an alert to the
> user, something like a wap push message or maybe a reminder. I'll be
> thanks for the answers
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Send message

2008-11-26 Thread andrex

Hi Stefan thanks, but Can I send me a message, to the emulator how run
the application? or what can I do if i want to send an alert to the
user, something like a wap push message or maybe a reminder. I'll be
thanks for the answers
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Send message

2008-11-26 Thread Stefan Selariu
It works for me, but only if I have two emulators. From emulator 5556 I can
send to emulator 5554.

On Wed, Nov 26, 2008 at 6:58 AM, andrex <[EMAIL PROTECTED]> wrote:

>
> Hi all, can anyone help me, I want to send an auto message or an alert
> to the phone. I've trying this
>
>SmsManager sm = SmsManager.getDefault();
>sm.sendTextMessage("5554",null, "My text Message", null,
> null);
>
> I put 5554 because is the emulator direcction. No errors, but the
> emulator don't receive the message. Any idea?
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---