I have developed an app which downloads some files from server. I'm using android download manager to download files to mobile device. I want to build a settings screen asking default location to store files using preference activity. How can i implement it.
I want to show all the storage options available in mobile in preference activity. Currently i'm using below line to store the files using download manage.
Here is the code:
request.setDestinationInExternalFilesDir(context, Environment.DIRECTORY_DOWNLOADS + DownloadEntries.getFile_dest_path(), filepaths.get(i));
Please help. I'm new to android.
What you need is something called PreferenceFragment
Preference fragment is just an easy way of creating a settings screen in Android.
You can refer here for the Preference Fragments.
Since Preference Fragments doesn't support file pickers by default, you can use this library here for the file picker.
So you can tell the user to pick a folder and you can create your file in there.
Related
I'm trying learn more about java as much as I can but I don't know if I'm searching wrong questions.
Basically I want to understand how apps can possibly put files on the SDcard that the user can edit and that will directly affect the app.
For example. The SD card folder contains colors.xml, is it possible for the user to edit that file to change say the background of the app? Or is there a better way? Such as an in app text editor that can directly edit the color.xml?
Thank you.
You can use PreferenceActivity or PreferenceFragment (in case you want Fragment):
https://developer.android.com/reference/android/preference/PreferenceActivity.html
https://developer.android.com/reference/android/preference/PreferenceFragment.html
They are default Android UI to modify settings stored in SharedPreferences:
https://developer.android.com/reference/android/content/SharedPreferences.html
My case now is for example select item, when i select that item, the item will become colour and after i uninstall and reinstall back, the item still is that coloured. I want to know is it possible the item selected of android application still can keep with using the method android_id? I mean this method.
private String android_id = Secure.getString(getContext().getContentResolver(),Secure.ANDROID_ID);
Because I plan to do is every android phone can use the function one time only. Hope can understand my question. I am using android studio.
Yes you can, basically you just need external configuration file that will be saved on external folder outside your application folder. For example you can save your configuration file in sd card. Then on your startup application, always check that file
I am developing a simple android app, I want to use file picker when I press button, so how can I implement file picker in my app.
I spent some time earlier figuring this out so to wrap up
Intents provide the ability to hook into third-party app components
for content selection. This works well for media files, but if you
want users to be able to select any file, they must have an existing
"file explorer" app installed. Because many Android devices don't have
stock File Explorers, the developer must often instruct the user to
install one, or build one, themselves. aFileChooser solves this issue.
You can clone it from iPaulPro/aFileChooser.
I am working on an android app and when a user clicks on a link and/or file, I want to give them the choice of choosing which app they want to use to open that link and/or file. At the moment it works the way it was intended to, but I am having trouble trying to let the user select a checkbox which lets them choose the default app to open that file with so they won't have to keep selecting it each time. I was thinking of having a checkbox in the dialog and then committing the value of it to the Shared prefs along with the app choice. After that, each time they click that file, the default app will be opened. In essence I am trying to get a dialog like this one,
But I keep getting this one,
Here is the code:
Intent intent = new Intent(Intent.ACTION_VIEW).setDataAndType(uri, mimeChoice);
startActivity(Intent.createChooser(intent,getActivity().getString(R.string.open_with_title)));
like tambykojak point out, the "The Android OS will take care of this depending on the Intent you've constructed" and thereĀ“s no option for default app. But you will construct your own custom dialog by gettin the apps installed determined by the package:
for example:
Facebook: "com.facebook.katana"; Whatsapp: "com.whatsapp"; Twitter: "com.twitter.android"; Google Playstore: "com.android.vending"; Chrome: "com.android.chrome" etc...
And saving the "default" option in preferences.
More info:
How to force Share Intent to open a specific app?
How to filter specific apps for ACTION_SEND intent (and set a different text for each app)
I know you can use
Invoke.invokeApplication(Invoke.APP_TYPE_CAMERA, null);
to get the blackberry camera application to be shown and allow the user to take photos. From which you can use a FileJournalListener to find any created files.
(As shown/implied in this forum post: http://supportforums.blackberry.com/t5/Java-Development/How-to-use-FileJournalListener/td-p/295424)
There are times however, when the user chooses not to take a photo but selects one from the file system. Since this wasn't created at the time I opened it, using the FileJournalListener is not going to meet my needs.
What should I use to get the selected file?
EDIT: The functionality I'm trying to produce I've seen in the Twitter for blackberry application
I think you should create a file picker first,
http://docs.blackberry.com/en/developers/deliverables/11958/Create_a_file_picker_856986_11.jsp
After that in the application, user could select whether to capture new picture or browse from their storage.
If user select the later, open up this file picker and for every images found user can view the image, and the application can save the path where the images located for further processing.