I have two Android Application(Application A,Application B) as shown in below figure. I want to call application B by clicking on Button from first Application A and when Application B launches then the text box will contain the text which I want to pass from Application A.
**Note-
I have access of Application A so I can modify the code of Application A . I have no access to application B.
I have seen many post on Stackoverflow.com and other sites that explain passing data to second application but I saw it is only possible when you have access to modify the code of both class. Here in my case I have no access to Application 2, It is just a APK which is installed on my phone.
I want to just implement like we did in automating a web page through Selenium where we can access a text field and enter value in that text field and .
Application B only for example purpose. It can be any Application having text boxes.
Actually I want to automate the login process of an application(Applicaion B) with the help of Application A .Application A have a number of credential and by selecting a credential from Application A it will launch the Application B and enter the credentioal to Login screen of Application B . **
Hope I am able to explain my problem.If some more input require I can explain.
Apps won't be able to access other apps' data from May 5, according to Google's new policy. Many users may not be aware that any single app on your smartphone can see every other app that you have installed on your device.
putExtra() method is used for send the data, data in key-value pair key is variable name and value can be Int, String, Float etc. getStringExtra() method is for getting the data(key) which is send by above method. according the data type of value there are other methods like getIntExtra(), getFloatExtra()
You have 2 options:
Application B expects an input (via intent). Then you can launch the app B and pass the value via intent:
intent.putExtra("Key", "Your data here");
You need to know which key the application B uses, otherwise you can't do this.
Application B doesn't expect an input. This is not easy and requieres root-access to the phone:
With the permission INJECT_EVENTS it is possible to type text or send clicks to any window. You can do this:
Instrumentation m_Instrumentation = new Instrumentation();
m_Instrumentation.sendKeyDownUpSync( KeyEvent.KEYCODE_B ); //send key B
you can find more to this topic here. If you need help to compile your app, these 2 links will help you: How to compile Android Application with system permissions, Android INJECT_EVENTS permission
Pass the data to the below intent. And then get it from the other app.
PackageManager pm = context.getPackageManager();
Intent appStartIntent = pm.getLaunchIntentForPackage(appPackageName);
context.startActivity(appStartIntent);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With