communication

Communicate with Activity from Service (LocalService) - Android Best Practices

此生再无相见时 提交于 2019-11-27 19:47:35
Common scenario - Activity with a background Service to poll server. The Service will run periodically via AlarmManager and also perform tasks for the Activity (user hits a button, go fetch something from server). I'd like to know the best practices here. I think the best design would be the Android LocalService example: http://developer.android.com/reference/android/app/Service.html#LocalServiceSample However in the example the Activity has a reference to the activity mBoundService but there is no reverse connection ( the Service has no way to call the Activity ). What is the best way for the

Peer-to-Peer communication options

眉间皱痕 提交于 2019-11-27 17:53:30
can anybody confirm what are the currently allowed methods for peer-to-peer communications within the Android framework? I need to transfer json strings and I'm currently using SMS which works ok but the problem is that the data also ends up as lots of text messages. I've read Reto Meier's first edition of Professional Android Application Development where he says that the data transfer options were not implemented due to security concerns. Has this changed at all and how would you do peer-to-peer transfer of data? Ollie C Have you looked at Qualcomm's AllJoyn library ? It is designed to work

communicate c program and php

和自甴很熟 提交于 2019-11-27 14:15:02
I want to have a web page (written in php because it's what i know) that displays an input value. I want that value to be passed to a c programa that's already running. I though of using sockets to communicate between both process, but how do I manage to do that? how can I use fsockopen to connect to a local socket. Some simple solutions I can think of are: Redis You could use redis as your ipc using hiredis as your c client library. I never used hiredis library before but did it just now for you to test and the library is really good. I could have known it because redis is the best piece of C

Android - getTargetFragment and setTargetFragment - What are they used for

你。 提交于 2019-11-27 12:37:48
I tried searching but i'm still a little lost. I usually do fragment to fragment communication through an Activity via interfaces or a BroadcastReceiver . Anyway, my question is what is the use of getTargetFragment ? Can someone provide a use case or just a quick example so i can comprehend its usage? kandinski Use case = 2 fragments hosted by the same activity. Where startActivityForResult() establishes a relationship between 2 activities, setTargetFragment() defines the caller/called relationship between 2 fragments. setTargetFragment(target) lets the "called" fragment know where to send the

using serial port RS-232 in android?

╄→尐↘猪︶ㄣ 提交于 2019-11-27 12:10:11
I want to send signals via serial port using the JavaComm API classes on an Android device, and here is how I imagine it: 1- the Android device would be: Archos 3.2 which has android 2.2 and USB host mode. 2- include RxTx lib package with my Android app. and include RxTx native code using Android NDK. 3- a short cable which is usb-->serial. Could you explain to me where I might face problems? I just ported the JavaCOMM ( GNU RXTX ) library to the Android. Here is the link http://v-lad.org/projects/gnu.io.android/ You still might need to rebuild your kernel and maybe recompile the shared

is assignment operator '=' atomic?

北城余情 提交于 2019-11-27 11:49:31
I'm implementing Inter-Thread Communication using global variable. //global var volatile bool is_true = true; //thread 1 void thread_1() { while(1){ int rint = rand() % 10; if(is_true) { cout << "thread_1: "<< rint <<endl; //thread_1 prints some stuff if(rint == 3) is_true = false; //here, tells thread_2 to start printing stuff } } } //thread 2 void thread_2() { while(1){ int rint = rand() % 10; if(! is_true) { //if is_true == false cout << "thread_1: "<< rint <<endl; //thread_2 prints some stuff if(rint == 7) //7 is_true = true; //here, tells thread_1 to start printing stuff } } } int main()

Relaying a request in asp.net (Forwarding a request)

你离开我真会死。 提交于 2019-11-27 09:45:29
问题 I have a web application that communicates between two different web applications (one receiver and one sender, the sender communicates with my application, and my application communicates with both). A regular scenario is that the sender sends a HttpRequest to my application, and I receive it in an HttpHandler. This in turn sends the HttpContext to some businesslogic to do some plumbing. After my business classes are finished storing data (some logging etc), I want to relay the same request

Tablet(iPad/Android)-Server Communication Protocol

孤街浪徒 提交于 2019-11-27 09:38:48
I am going to build a client-server application. The client here is an iPad (or an android-based) tablet. The server is a normal pc. Both the clients and the server are connected to the same network (using WiFi). Is there a standard way (protocol) for communication between the clients and the server? Are there any framework that can be used to ease this communication? Thank you The answer depends by what you define by "server", "client", and "protocol". Technically, the answer is "yes"; from a practical standpoint the framework you are looking for is called "socket", but regarding the protocol

Calling Java app with “subprocess” from Python and reading the Java app output

北慕城南 提交于 2019-11-27 08:59:21
What is the nicest way to read the output (i.e. via System.out.println) of a Java app which is called from Python with subprocess.Popen("java MyClass", shell=True) without writing and reading a file? (Using Jython etc is not a possible solution) p1 = subprocess.Popen(["/usr/bin/java", "MyClass"], stdout=subprocess.PIPE) print p1.stdout.read() I just found the solution: p = subprocess.Popen("java MyClass", shell=True, stdout=subprocess.PIPE) output, errors = p.communicate() S.Mark's is fine too! 来源: https://stackoverflow.com/questions/2388423/calling-java-app-with-subprocess-from-python-and

MPI asynchronous broadcast from unknown source

强颜欢笑 提交于 2019-11-27 08:53:31
问题 I have a C-project that has n numbers of processors working on a kind of tree search. At any given time of the program, any of these processes may find something of interest and want to send this to all other processors asynchronously. How can I listen for new messages on the other processes without having to loop through all possible senders each loop iteration? I have read other questions about this, for example this one (MPI - Asynchronous Broadcast/Gather), however, all I've seen so far