android: get files icons saved in the system itself - android

I know the following happens in Windows [desktop]:
the system has an icon for each extension, and a default one for new ones.
When a new program is installed, it saves its icons to its extensions in the system [ex. upgrading Word 2007 to 2010 changes the icons for .docx files]
Now I want to know how to get those icons in android. I'm not sure if it follows the same scenario, BUT, i have a file explorer app which displays those icons. From my use of it, i know that those icons cannot be hard coded [except for the folder icon]. For example, after installing Tango, its icon took over the .ini files
My question is, How to get those icons? I'm kinda doing a file explorer app [that serves certain needs no other app does]

Android doesn't provide that functionality. You have either hard-code drawables for most-used file types into your application or download them from Internet.

You'd have to create your own icons, scan for the file types found, match those to some internal list and display the according icon (Drawable) in a Imageview in your ListView. Assuming you are using a ListView to display the files found here ofcourse.

Related

NativeScript 8.0.4 Android App Icon WILL NOT Change from default

I'm tearing my hair out over here. I've developed applications with earlier versions of nativescript and this has never been issue... This is my last effort before I just downgrade to an older version
I have ran the command tns resources generate icons ../icon.png and it claims to have successfully generated the icons and I can see them in the directory... build and deployed to phone. Still has the default nativescript icon
I went to App_Resources/Android/src/main/res and manually updated the ic_launcher.png file in every mipmap directory... build and deployed to phone, same result! Default icon
Tried deleting the platform/android directory and rebuilding. No luck
I searched from the root directory and I cannot figure out how the heck this default icon is appearing still!!!
Note: I was able to change the splash screen
Any help... please, thank you
I ended up solving this issue eventually, so for anyone this might help in the future... In the newer versions of NativeScript there is now a new folder in res called "mipmap-anydpi-v26" which uses vector graphics. If your on SDK 26+ it will automatically use this vector graphic and IGNORE every other PNG icon in all the other folders.
Your options to remedy this are either:
A) Delete this folder from the directory, which will force it to fall back to the regular PNG icon that's appropriate for the device resolution
B) Edit the file in the folder and update the SVG to use yours
I had a similar issue on nativescript 8.1.1, nativescript/android 8.1.1 with svelte 3.44.0. After running ns resources generate icons <icon-path> and ns resources generate splashes <splash-path>as show in this stack post here. Only the splashes were generated successfully. However the icons didn't work as described, hence I had to generate my app launcher icons using this service. Then I downloaded the zip file, unzipped it and copied the contents of the 'res' directory in the unzipped file to <project-directory>/App_Resources/Android/src/main/res to replace all the directories with the same names (i.e. mipmap-anydpi-v26, mipmap-hdpi etc). Then rebuilt and reran my application and everything worked fine.
Since 8.x Nativescript ships with the adaptive icons - since the old icons are outdated on more recent android phones, and usually look weird
1.Open a project in Android Studio and in the Project Explorer pane right-click on the app directory or any of the directories inside the app directory. In the context menu that opens select New > Image Asset
2.Once Asset Studio opens you'll see the new default app icon
3.The main thing to know about adaptive icons is that there are two layers, a foreground and background. The default foreground will be titled ic_launcher_foreground.xml and it is an SVG. Go ahead and click the ... button next to the path (image below) and select your app icon that you're going to use.
4.Now you can go ahead and set the other settings for your icon such as trim and the resize percentage. You'll also be able to change the default green background layer, select the Background Layer tab and you can repeat the same process. From experience, in a lot of cases you can use the Color radio button to set the color you'd like to use for your background layer.
5.Once you are finished with your icon configuration you can complete the wizard which will generate the various resources needed for your app. The new files will be located under the android app directory in src/main/res/ where you should see several mipmap- directories.
6.Now move all the files in mipmap- directories to your Nativescript's App_Resources mipmap folder
7.Once you have copied over the newly created icon files to the NativeScript project there is one final change you need for your application. The only change is to set the android:icon value to #mipmap/ic_launcher which is the resource location of the new files we added from the Android project from Android Studio.
Hope this helps to solve your issue
I always use NativeScript Sidekick to generate my icons. I don't know if that will yield different results from the tns command, but at least it's something else to try.

Custom Directory Image

I'm currently trying to figure out how to set a custom image for a external storage directory I'm creating some time in the app. If you're probably using a file browser like ES File Explorer you will see that some apps like WhatsApp but also smaller projects have an extra little picture or app logo added to their folder.
Is this possible to set by code?
You can't set one that other apps use. There's no such concept as an image for a directory. Inside your own app you can do whatever you want, you have to write any file explorer yourself.

Accessing data from device in Android Studio

it's my first question here. I searched a lot on the site but didn't find any answer for my question.
Basically, I want to load a directory containing jpeg and mp3 in the tablet and retrieve the path from these files and put them in a SQLite database. I have no trouble using the database but I don't know how to retrieve the paths of the files or even to verify the existence of the directory. Any hint on how to access these files without putting them in the application drawable and sound folder would be appreciated. Thanks!
Goto the Android Device Monitor in the android studio and new poup window will open with the devices list in the left pane and in the right pan select the File Explorer Tab and that's it

Where application icons are stored in an Android device?

Just out of curiosity, I wanted to know where on the file system of an Android device the application icons are stored.
Like I have shortcuts to various applications on the homescreen of my device, where those icons files (or images) are stored. Is it only inside the application package (.apk) or Android stores it some where else?
If it is in application package only does Android loads all the imagess from each of the apk and loads it when it is started for the first time?
When an app file is installed, the .apk file is analyzed and various items of information are extracted by the launcher. (This process does not involve loading and running the app itself.) Among these items is the app icon, which the launcher typically caches in its own private area. Exactly how this is done depends on the launcher currently active on your device. You might be able to browse through the source for your launcher to find out more details about how it caches these items extracted from the app .apk files, but I'm not sure what practical use there would be to that exercise.
The launcher's use of its own cache greatly speeds up start-up, as otherwise every installed app would have to be scanned at every reboot to extract the requisite information for the launcher to show itself. However, the cache is the source of occasional problems, such as the icon not updating right away when an updated app (with a new icon and possibly a new app name) is installed. (See, for example, this thread and this one.)
Think about what happens when you create your own app. Typically, you create icons for your app for all drawable resource buckets (or at least the ones you want to support). Then these files get packaged with AAPT into the apk with the rest of your project. Then after installing your app, the OS will pick the icon that matches your phone configuration and create a shortcut on your installed apps page.

Where can I find android dial pad image assets to create a custom dialer app?

I am trying to create a custom dialer app for Android and need the buttons/assets in their normal and selected (when depressed a different color is presented).
Can someone please tell me if there is a place to find such assets.
Usually you can find the assets inside the SDK directory. On mac it will be YOUR_SDK_DIR/platforms/android-(VERSION)/data/res, where VERSION is the version of the SDK you want the drawables.

Categories

Resources