Sending parameters from one apk to other - android

I am able to launch an apk from the button click of other apk. but i have to send parameters also.Like if i am giving values in a text and when i click the button then it should send the parameters to other apk as well it should start other apk. I know how to send parameters between activities in the same package. Please guide me how do i do it.
Update:
I have successfully run that apk's. I just had to put package name instead of class name.

Use
i.putExtra(param, value);//Put extra values to your intents, if you are using intents to launch another app.

You need to use content providers to share data across different applications in Android. Here
is an example as to how to use them. You need to have a URI which identifies your dataset and use the same URI in another application to retrieve data from it.

Use Intents, as explained in Android Developer Documentation or many tutorials over the internet.
You should use Bundles to pass parameters, as you can read there.

You can use files in a common directory to comminucate different apps or basicly you can have serversocket in your first app that runs the other one, so the second one can connect it and transfer data to/from first app.

Related

Android transfer object data through different device, same app

I want to implement a feature in an app where users can add friends and check and compare each other stats from the java objects created, which involves a few subclasses.
I was wondering if anyone know what the best way to approach this would be?
The only thing that pops out is using Firebase. Where the user would click a button to upload the data to Firebase with a UUID link, and then give the UUID to the other user, where he/she would have to manually type the UUID in a textfield, and it gets the data from Firebase.
Would method be viable and is there any other better options?
Thanks
I would probably create a file (you can invent any ending) with all info you need displayed in json. That file can be shared via Whatsapp or what ever and imported in your app?
But I don't know what "stats" that are that the users can compare but I think they will change from time to time? So I would guess an online service would be better because otherwise to update, they have to share again and again?

Sharing String between two applications

I have two applications and I want to be able to share a String value between them. For example: user changes the String in app A, when app B is launched, I want it to read the updated String (and vice versa).
I was trying to use SharedPreferences with Context.MODE_WORLD_WRITABLE, but it's been deprecated.
How can I achieve this?
EDIT: App A has to save the value without launching app B. App B has to be able to read that value without launching app A.
I looked at ContentProviders, but they look too complex, especially for a simple String sharing.
One option is use webserver for this. for example store value in web server from app1 and access this value from app2
option two is use content providers. Through the content provider, other apps can query or even modify the data (if the content provider allows it)
Simply put:
one application needs to send intent with data
the other one needs to listen for it with brodcast receiver.
Content provider is probably not the thing you are looking for.
here is good tutorial for brodcast receiver
Try http://developer.android.com/training/sharing/send.html or http://developer.android.com/guide/topics/providers/content-providers.html to share data between 2 applications

How to create option for your app in another app in android

whenever my app will run, it will create one option in another app to get data from another app.
Well, I am not sure this is possible or not, Please guide
one more I know how to share data in between two app by using sent action but I want to create one separate option in another app for my app when my app start running in android
Is it possible ?
Please guide , Thanks in advance
A content provider component supplies data from one application to others on request. Such requests are handled by the methods of the ContentResolver class. A content provider can use different ways to store its data and the data can be stored in a database, in files, or even over a network.
Link1
Link2
You can do this thing this way :
Intent i=new Intent();
i.setPackage(TARGET_APP's package name);
context.startActivity(i);
You can set value this way with this intent
i.putExtra("KEy",value)
http://developer.android.com/reference/android/content/Intent.html#putExtra%28java.lang.String,%20double[]%29
On the other hand, if you want to read some data from an app, it's possible if and only if that app allows you to do so. Data generated by the app is private by default.
Another way to do this by using content provider
May be this link will help you more about content provider
http://www.tutorialspoint.com/android/android_content_providers.htm

android: questions about ContentProvider

As I understand it, ContentProvider - is the data on the global level of the whole device?
The questions:
1) Is it possible to develop and distribute only ContentProvider (no Activity, ie not as a complete application, but only as data)? Does anybody do so? And when?
As for the user it will look like? What is the difference between build of ContentProvider and build of normal application?
2) If another developer wants to use my ContentProvider, then how he will be able to access the column names and other data necessary to work with my ContentProvider? I have to give the library?
Sorry for my English.
Thanks
1) Is it possible to develop and distribute only ContentProvider (no
Activity,...
You have to add at least one Activity to your App to be launched by user.In fact forsecurityreason all services,receivers,... that you declare in manifest,will not register unless your App run explicitly by user and this needs to a Main/Launcher Activity.So you have to add such Activity to your App.
2) If another developer wants to use my ContentProvider,...
You have to publish documentation in about your App.
1) Is it possible to develop and distribute only ContentProvider?
Ans:- You need to add at least one activity to your application and all the resource in the menifest will be registered once your app will be launched explicitly.
2) If another developer wants to use my ContentProvider..
Ans:- You need to provide the proper documentation for accessing the content. Other developer can use the content of your app b using the URI which is defined with your ContentProvider.

The easiest way to pass data between application in Android

What's the easiest way to pass data(string value) between two android applications with less or even without permissions? Also in my case first application sends data to un-existed application which is installing and it can't listen for intent right now.
Thanks.
Your question is tricky when you can't ensure that both applications are running. In cases like that, you must rely on some form of persistent storage.
If you're concerned with only a small amount of data, Android provides a SharedPreferences class to share preferences between applications. Most notably, you can add a OnSharedPreferenceChangeListener to each application so they can be notified when the other changes the value.
You can find more information on various different forms of persistent storage on the Android website (http://developer.android.com/guide/topics/data/data-storage.html).
So as you are mentioning intent and extras put to it is the way to go.
If you want to let an application receive data even if it's still installing there is no straight-forward way.
One way is as follows:
In the receiver-part of your code, send a received successfully-extra to the sender-application. If the sender-application does not get the received successfully-message after some time, store the data and wait until the application is installed. you may store this data on sd-card and let the other application read that on first use.
you can also do a check if the application is installed with PackageManager.

Categories

Resources