1

I want to create two separate Android applications to behave like this:

MainAplication will call Aplication2 when a buttom is clicked, then the MainAplication will send some data to Aplication2, Aplication2 will open in front of the MainAplication(top of the screen), will process the information sent and then when a buttom inside Aplication2 is clicked it will disappear and the MainAplication will remain on the top the screen and receive the information procesed.

Can you please give me an idea on how to complete this approach.

A basic idea of what I want to create is this:

Apps Idea

eugenio 25
  • 41
  • 6
  • 1
    Why chunk into two apps? Why not have a separate activity that responds to an intent? Otherwise, you'd need to look into Androids IPC work flow and possibly AIDL. – Phix Nov 18 '12 at 19:31
  • 1
    You don't mean applications, you mean activities, I think? You could use startActivityForResult See Starting *Activities and Getting Results* here http://developer.android.com/reference/android/app/Activity.html – Simon Nov 18 '12 at 19:34
  • Look at [this](http://stackoverflow.com/a/947560/1631457) solution. It solves your problem – Barış Çırıka Nov 18 '12 at 19:56
  • Thanks, but I mean Applications, can you help me with an example? – eugenio 25 Nov 19 '12 at 14:23

2 Answers2

0

It's depend upon how you are going to send this information vai bluetooth , wifi or Sever communication. If you are using a server communication then it's simple. Call a web service and pass your message with NEXT DEVICE ID (DEVICE-2) to server and let server inform to device-2 for its incoming message using notification or you can direct download also and then notify on device-2 and so on..! it's simple !

Hardik Thaker
  • 3,050
  • 1
  • 27
  • 37
0

It sounds like what you want is not really two separate applications but an application with multiple activities which is very common. Android activities work on a thing called a stack. For instance, you start with the main activity which will call a second activity. This second activity is now placed 'on top' of the main activity. So, if you press the 'back' button, it will go back to the main activity, or, you can call a third activity which will be placed on top of the second. Here's a link with a little more information on the subject.

You can call an activity with the following code:

Intent i = new Intent(CurrentActivity.this, NextActivity.class);
startActivity(i);

Where, in the above code, CurrentActivity is the name of the activity you are currently in and NextActivity is the name of the activity you wish to go to.

If you want to go to another activity but return to back to the calling activity, then use:

startActivityForResult(i, REQUEST_CODE_VALUE);

where REQUEST_CODE_VALUE is an int that distinguishes between other startActivityForResult method calls.

Here's a link with a little more information on the activity subject.

Now, if you do want to have two separate applications communicating with each other, then, it depends on what you really seek to do. You could have the two applications communicate over a server or database. Or you could have them send and receive broadcast intents. In that case, look up some information about broadcastreceivers.

I hope this helps!

chRyNaN
  • 3,592
  • 5
  • 46
  • 74
  • Hi Guys first of all Thanks you all for the quick answer, and yes I mean two separate Apps in my Android Phone. Can you give me an Idea of how I can accomplish my approach with broadcastreceivers? any link or code? Thanks – eugenio 25 Nov 19 '12 at 02:26
  • Sorry for the delay, [check this link out](http://www.techotopia.com/index.php/Android_Broadcast_Intents_and_Broadcast_Receivers) for some information on broadcastreceivers and broadcast intents and how to use them together. Also, [this question may be useful](http://stackoverflow.com/questions/2749893/how-to-use-broadcast-receiver-in-different-applications-in-android) to you, considering what your trying to accomplish. – chRyNaN Nov 19 '12 at 23:44
  • Thanks Android Student you were really helpful, (I found the link yesterday :p ) I'll post my implementation once I finish it. Thanks for your quick response. – eugenio 25 Nov 20 '12 at 13:22