0

I have two standalone applications i.e A and B. A needs some functionality from B. Application A calls an intent of Application B. Application B receives the request and process it and send back the result to A. Just like the Zxing Barcode Application.

How could i achieve the above? Any idea?

Shah
  • 661
  • 2
  • 9
  • 19
  • possible duplicate of [How to call one android application from another android application](http://stackoverflow.com/questions/2728465/how-to-call-one-android-application-from-another-android-application) – Gangnus Jan 30 '14 at 11:04

2 Answers2

0

Actually, it reminds me of startActivityForResult method.

http://developer.android.com/reference/android/app/Activity.html#startActivityForResult(android.content.Intent, int)

Rather good example: http://www.vogella.com/articles/AndroidIntent/

xvar
  • 103
  • 1
  • 1
  • 7
0
    final Intent intent = new Intent(Intent.ACTION_MAIN, null);
    final ComponentName cn = new ComponentName("com.your.package","package.class");
    intent.setComponent(cn);
    intent.setAction(Intent.ACTION_MAIN);
    intent.addCategory(Intent.CATEGORY_LAUNCHER);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    startActivityForResult(intent);

or

Intent intent = getPackageManager().getLaunchIntentForPackage("com.your.package");
startActivityForResult(intent );

Replace com.your.package with Application B package id.

Tarun
  • 13,727
  • 8
  • 42
  • 57
  • I have two different projects. Infact I want to integrate my new application B into Application A. I use your code, but it stop the application. P.S: I am beginner in android development. – Shah Jul 29 '13 at 10:27
  • Try running the second option and replace `com.your.package` with the application B package. – Tarun Jul 29 '13 at 10:28
  • I have used some library in application B. and now by integrating with Application A, it doesn't work. What could be the problem? – Shah Jul 29 '13 at 14:37
  • I can now call an activity in B from A but I don't get the result back in my calling activity. I used startActivityforResult() and I get back to the calling activity after finishing from B but couldn't get the results. – Shah Jul 30 '13 at 11:22