Android:is it possible to share the bitmap image without saving it - android

I am creating bitmap image in my application and i dont want to save it on phone. If user want he can share it with other apps.I tried many things but m not able to share the image with other app without saving it. Is there really any way by which we can share the image with other android application without saving it? or we must have to save it first and then share. Kindly suggest.

The Bitmap saved is not on disk, but only in RAM. Other apps are not allowed to read your's app's allocated RAM. The ways for your app to export volatile data are:
Write byte data to a large Parcel, and put it in an Intent extra.
provide data over to a network socket or via a custom content/file provider etc.
But even for these methods to work, you need other apps to know how to fetch data. Which is very unlikely unless the other app is also programmed by you.

Related

Approaches to storing data in Android

I have started learning Android development and I have a very newbie question. I understand that Android can store data in SQLite for example, but what other approaches are there to the storage of data within your application?
Do Android apps ever have data 'embedded' within the application, in which case what sort of data structure or concept would this use?
I am thinking of a scenario where the data is static but is perhaps not a large enough dataset to warrant a database..e.g. an app with general knowledge questions and answers
Any guidance much appreciated
Rowan
Yes You are correct You can use SqLite Database for storage
other ways to store data is SharedPreferences
But in your case you wanrted to save questions and answers which is static one so you can create a text file and put that in your assets folder and you can read that file as any other text file in java
Refer this link how to read file from assets folder
1.Sqlite Database
2.Shared preferences
3.Internal memory
4.external memory i.e sd card
i would suggest you to go with Database. as it will let you store as much data as your app needed, There are some other option also present like
Sharedpreference i.e. cookies in general term. It let u store only few KB data and not good to store much data. When u retrieve data from cookies. All data will be store into ram and use app memory. that is use less when u do not need all data to retrieve and store into ram and then remove
Store into file and ship that file with your app. Yeah. this could be better idea again. you need to read it byte by byte. and hence reading to mid or last line will store all data into ram and hence will take memory.
Use Web Service to download data. It will let you store Large data and you have to download using Web APi. Hence it could be better idea. But this requires active Internet connection to play game to run app.
There must be some other option also present. You can search. surely you will find them :)
Overall Database it good solution for all app. As it will let you do search store delete and let you do other operation in less amount of memory. In Mobile Development Memory is very Important thing we have to take care of.
Let me know if you have other unclear thought.
item
You could also store info in a server.
Pros :
You can change the content without needing user-side update of the app.
Cons :
Your app (mostly the UI) would need to manage connection problems.
You may need to implement async tasks for querying data from server.

Android: Transfer pictures between applications

I have two application need to transfer data together using intent. I get problem with transfering large data - pictures, as it is limitted in android.
My first app stores picture as binary data in database (no local path existing). Now I want to transfer this picture to the second app (which impossible using intent as big).
Does someone give me an advice to solve this problem?
I have an idea that my second app will read directly from DB.
Is it possible? Any example is appireciated.
Thank you.
This case you have to use ContentProvider, which allow you share data provider for your first app to the second.
This is a good link for you: http://mrbool.com/android-content-provider-how-to-use-content-provider-for-data-access/30446
As explain in the Google documentation, it's the mechanism in use to get Picture from the PictureGallery of Android, so I presume this approach is the best available on Android platform.

Keep Camera from saving photo

I have an application that captures pictures by dispatching an intent. Upon return of control to the activity, I retrieve the intent, extract the data, transform it into a bitmap and use it in my application. Just some straight forward code.
The pictures taken are subject to some privacy obligations and my application takes care to delete all data. The problem is that all pictures taken by the Camera application seem to automatically be saves into internal storage. I was successful in deleting screenshots taken by the device and by clearing all thumbnails. What remains to be done is keep the Camera application from storing picture in the first place.
The problem as I see it is that I relinquish control to the application and, hence, cannot influence it in any way. I tried launching ACTION_IMAGE_CAPTURE_SECURE but that failed. I would much prefer the approach of keeping the application from storing the image to the approach of having to scan the internal storage location for images and delete them as I tried it and failed.
Note: I have assigned all the right permissions. Should you need code, I will be happy to post it but there is nothing that cannot be found already in other threads. If there is no solution to my preferred approach, how would I go about deleting all images located in the internal storage at DCIM\Camera? Thank you!
If you need to override that behavior, don't take the pictures via intent. Take them yourself, using the android.hardware.Camera API.

Saving information into file and load it on start?

Basicaly what im intrested in doing is when i give my app some GeoPoint i want to save i want it to save this to a file on the phone.. But i have no idea how i will do this saving, I need to save the longitude, latitude, and two strings for each object and when i make a save.. And this is for each point i want to save.. And this brings me how i will make the loading when the app starts.. Maybe i could make it save all information for each object on separate lines and it would be easier to load it?
I never had experience with saving and loading this is totaly new to me so how would i solve something like this?
You've asked a general question so the best I can do is give you a general answer. You'll want to do this reading and writing in your onCreate and onDestroy methods for your activities. For details on storing persistent data on the android phone, please read the android Data Storage article.

Caching images in android?

I'm currently building an android application, and I'm making some HttpRequests to grab images from an API. Right now I'm just storing them in an object container, and then storing them in ArrayLists, but I want to store it into a temporary cache for the application so that when I quit out of that particular activity and go back into the launcher activity, when I go back into that activity, I won't have to make another httprequest for the image.
However, I don't know where to start, what to read up on, or anything regarding temporary storage. I've only used SharedPreferences, and passing extras along intents. Can anyone point me to any good places to get started with, either documentation or sample code?
edit: I forgot to mention that I'd like the data to be deleted when I quit out of the application. I'm not too sure what caching even means, so I don't know if this happens by default when people talk about "caching"
You could refer to Android - How do I do a lazy load of images in ListView.
There are a cache example in Fedor's LazyList.zip from the answers.
The Activity class has some great information on cache directories and the Lifecycle. If your cache is more than a couple megabytes you should consider using external storage.

Categories

Resources