android: displaying radio buttons when starting application - android

I have an application in android that shows a list of videos.. However, the list can be stored either in internal storage or in external storage. What I want is that when the application starts, I want two radio buttons and a save button. The radio buttons should ask the user about whether they want to select internal storage or external storage.. And the save button should save the settings. Can anyone tell me how this can be achieved?
Thanks alot

I would highly suggest using SharedPreferences for anything along the lines of user-controlled settings or configurations you would like to save.

What I would do is have an opening activity (that could be made to look like a dialog if you so choose) that presents the option to the user and then passes that option to the next activity that actually runs the program.

Related

Can I save a file directly to the Android home screen?

I am developing a data-logging app using Android Studio. I want to save a file that will appear on the user's home screen.
Is there a way to save/write a text file that will appear directly on the home screen of the phone, rather than in internal storage? I don't want to just create a shortcut—I actually want the file to be saved on the home screen.
Is this possible? If so, how can I do it?
This isn't possible. The Android home screen (also known as the launcher) is just an app like any other app. It doesn't correspond to any location on the filesystem where you could store files.
A user may have multiple home apps installed (though only one can be set as the active one) each with their own independent home layout. Some launcher apps don't even take the sort of traditional icon-centric approach to a home screen that you may be used to.
The only way to achieve this feature would be to do what you said you do not want to do: create a shortcut that opens the file.

How to Store Android Pictures to Prevent User Deletion but Still Give User Access

I'm working on my first real Android application, and I have run into a use case problem for which I cannot seem to find a best practice. The application has a main screen with a RecyclerView that has an ImageView as part of the view that makes up the individual list items. Clicking on an item in the RecyclerView takes you to an Activity with a ViewPager giving details for the selected item and allowing the user to swipe through the details of the items that were displayed in the RecyclerView. As part of the workflow of adding or editing an item, the user can take a picture that is used for generating the thumbnail for the RecyclerView and for display in the details fragment in the ViewPager. I plan to provide the ability for the user to share the detail entry, including the picture, on social media or email or to their Google Photos. My dilema is how the picture should be stored on the user's device. You can store to the public external storage, which is scanned by the media scanner and can be accessed by the user for copying to their computer or sharing.
File file = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), albumName);
However, the user can also delete the pictures stored there which poses a problem for generating thumbnails and display in the detail fragment.
Another approach would be to store the pictures to the applications internal storage, like so:
File file = new File(getExternalFilesDir(null), "DemoFile.jpg");
Of course, this would protect the pictures from being deleted. However, the user would not be able to access that storage location from their computer or from other photo apps on their device.
I could store a copy in both locations. However, that seems like a waste of device space. Are there any best practices for such a use case? Do others have any experience with this scenario that they would be willing to share?
The best approach would be, to upload the picture the User takes to a server via a small .php script, so it is guranteed, that the user cannot simply delete the picture and causing your app to malfunction, while still giving the user the ability to have a local copy of the image(s) on their device.
You could place an empty .nomedia file in the folder of your thumbnails. This will prevent the media scanner from scanning what's inside.
That being said, if you'd like to get these thumbnails automatically deleted when your app gets uninstalled, which I think is what you'd want, you can create a private directory on your external storage that will be tied to your particular application.
By the way, in Android the user is the application itself, so by making a directory private, you're making it private for the application itself (not the actual user of the device). But obviously, if you're saving these thumbnails on a removable sdcard, or if the actual user roots his device, these files won't truly be private.

Android installing an apllication by code......and start an application with some arguments

i'm really freaking out cause i don't know how to find example or documentation for my issue. I developed a kind of Ndroid Market that let you download .zip file and save the in the sd (ex root\download). Each zip contains an icon and an html web application (ex. Icon1.ico and Application1.html). When the download is finished MyMarket unzips the application1.zip file and puts it in a folder.
What I would like to do is to find out how to add the application1.html to the list of my application using icon1.ico as icon, basically I'd like that if someone clicked on the menu button of the phone in the list of my application is shown one with the icon1.ico image, but how to to that? I can't find any code example.
And then the second step. I have to develop both this alternatives and then someone else will choose beetween them
When i click on the icon1 on the list application the default browser is opened and the html application is run inside it....
The most difficul, when i click on the icon1 MyMarket Application is opened but with a parameter, like when in java you run program1 but with one argument that you can retrieve in the argv array. So for esample if i click on the MyMarket icon or on the Icon1 icon the same application is started but then MyMarket check if the "argv" is empty and if it's not and for exmaple there is a string "application1" it open another activity with a webview and run the html file inside it.
but how to to that?
That is not possible for most home screen implementations. The only things shown in a standard launcher are activities, from APK files, flagged as belonging in the launcher. You cannot create these on the fly.
You are welcome to make your own home screen that offers your desired behavior as a feature.

how to open a folder navigation when button clicked in Android App?

How can I open a folder navagation in my Android apps. I dont want to use any third party app like AndExplorer or ASTRO.
I want a button in my app and when click on it,a particular folder may be ("/sdcard/mywebfolder") should upen and user then can browser its content.
Please help me to accomplish it.
Thanks
Parvendra
Well without the use of third party apps you are going to need to code a file explorer or at least a view to display a certain folder's contents.
You could always just let the user select the program for the browsing via an intent, but I could understand not wanting to do that. Only downside is it means more work and more coding.

Allow a user to select a folder on an SD card

I'm looking for a way to allow a user to press a button to browse the contents of the SD card, and then select a folder, whose path will be returned to the application. Similar to how you pull up the "Browse..." dialog on Windows for installations.
Okay, so what I ended up doing was just using a ListActivity with a ListView (choiceMode:simple_list_item_multiple_choice) where the user can check the folders they wish to use. Then I used a custom layout that placed a Submit button below the ListView, which the user can press to confirm the selection.
There is nothing built into Android for it AFAIK. You can integrate something like OpenIntents File Manager, but that is a separate APK that users would need to install.
You can use AndroXplorer, the hook is quite simple, but then again, yes, it is another APK to install

Categories

Resources