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.
Related
I am creating an android app that can be used by common users and also admin.
Suppose, if admin adds a new place name, that name should be added to database and when common user uses the app, he should be able to see the place name that is added.
I used MySqlLite database. But the problem is that if the app is uninstalled all data is lost. So I want some persistent data storage in which all the places that are added by admin are saved permanently.
Regards,
Sindhu
With the data being needed across multiple devices, your only option is to create/use a backend API.
Parse would have been a good choice but since that is getting shut down soon then it wouldn't be wise to use that.
Take a look at these alternatives here
You could also write one yourself, but unless you have some experience in that sort of thing then it will take some time to learn.
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?
I´m currently trying to share information between different applications in Android, the goal I´d like to achieve is having the same behavior the KeyChain data share have in iOS but in Android.
I´ve already given a try using SharedPreferences and using "shareUserId" attribute inside Manifest, (by default Android applications behave as sandBoxes and they are not allowed to share data, they also haven´t a common context, so a "fake" one must be built) issues here come by the fact that is mandatory to know every app´s packageName so the data share happens between those apps with the same shareUserID value. I mean, I would like to access this resources without having to ask for the application that stored them.
Context appOne = createPackageContext("com.xxx.zzz.appOne", CONTEXT_INCLUDE_CODE);
mSharedPref = appOne.getSharedPreferences("Test", Context.MODE_PRIVATE);
Other way I tried was using the AccountManager in order to store that information so other applications could reach it. Bad news were that this account will be shared among all applications installed in the system and i will like this behavior to be more restrictive in terms that I would like to be able to choose which apps will have access to this information and those who won´t.
Reference to related post
(Should you use AccountManager for storing Usernames and Passwords for an Android app?)
Is there anyway to achieve this goal? Any help or hint will be appreciated, been stuck in here for a couple of days... If extra information is needed feel free to ask for it. Thanks in advance.
I have a requirement, wherein I have 4 android apps, which are sending notifications to a user, at a fixed time of the day. A user could have one, or more of these apps installed on his phone.
I want only one of the apps(any one) to show this notification to the user, because multiple apps popping up notifications is a bad user experience.
For this I need to share some data across the apps.
I was thinking of a mutex/lock based approach, the problem is, where do I store it?
Problems:
Shared Prefs: I don't know which app wrote the data first, and from which app's context should I read.
SQLite: Same Problem as above and app uninstalls need to be handled and SD card might be missing
Server: Mostly offline app, dont want to add internet permission just for this
I see files at a common location as the only way to store this information.
Is there any better way
As you said that the easiest ways is with file,
I did this before and i too wasn't able to find more easy way.
when you show the notification first time then Just make a new file anywhere which can be common for any app and then check if file is exist.
if it exist then don't show the notification and if not then show and make file again, also remember to delete the file from any of your app when day changed, use AlarmManager for this.
hope it helps.
I have 5(any number) android applications which will share some data.
Now when 1st/2nd/3rd..(i couldn't know) android application will get installed by user, it will save a string in the memory(internal memory),
When any other application will get installed, it should know that one of the app has already written data and now it should act as user of this data.
To sum up, first app installed will act as provider and others as users...but all the applications can be potential provider and other as users..
Is this feasible?
i tried using file/shared preference/content providers...but in file, you should know file path before using it which is dependent on package name..
In shared preference, we have to create package context..
In content provider, we have to import provider package..
My real motive is, actually in each app, i register the user first time...
now i want , if user install 2nd app from me, it can just use data of first app and do not ask for register..
but the problem is i don't know which app will be installed first by user..
Please help if i can use some other approach??
i found one thread related to this...
https://groups.google.com/forum/?fromgroups=#!topic/android-developers/W-oOa0x9amg
http://android.bigresource.com/Android-How-to-share-data-between-applications-with-no-dependency-HRMMGMIkL.html
This thread pretty much answers my question, in terms of feasibility and options i have for this scenario.