How to delete all temp files which created by createTempFile when exit an App in android?
Delete the files in onDestroy if isChangingConfigurations() is false or isFinishing is true . Example:
Technical answers from my Stack Overflow history, with source links and licenses.
Showing 30 of 268 answers
Exported May 9, 2026
Delete the files in onDestroy if isChangingConfigurations() is false or isFinishing is true . Example:
A valid Android package name is described in the AndroidManifest documentation for the package attribute: The name should be unique. The name may contain uppercase or lowercase letters ('A' through 'Z'), numbers, and...
No answers provide a way to change the title typeface of an AlertDialog . Here is what I have done: Create the below class: Add the following utility method: Finally, set the typeface when creating your AlertDialog :
Here is, what I think, a better solution than what @Adem posted. Java: XML:
Old question, improved answer:
You can get the last access time using stat or lstat . The two methods, android.system.Os.stat(String path) and android.system.Os.lstat(String path) , were made public in Android 5.0. On previous Android versions you...
You will need to parse the font file. I will first paste example code on getting the font name. Then I will paste the code I extracted and modified from Apache FOP . Example usage: Copy the following classes to your...
Change to You are using the value from R.color instead of the value you set in your XML.
On Android M+ you can use the BatteryManager service via getSystemService(BATTERY_SERVICE) . On devices running pre-M you can use a sticky broadcast as mentioned by others. Example:
The MenuBuilder is a hidden class but does contain a method to show icons. You will need to use reflection to show the icons in the menu. Try adding this in showPopop(View, int) :
Update your support library to 23 and your compileSdkVersion to 23 in build.gradle. Then sync your project with gradle files. Also, Google Play Services is now 7.8.0
How to do it from code:
There isn't a magical tool that will refactor obfuscated code into a buildable project. Most likely, you won't be able to decompile and de-obfuscate an APK to be clean and maintainable code. This is a good thing. There...
Is there an option to delete the cache of all apps or certain apps in Android M? A third-party app cannot delete the cache of another app in Android 6.0+. The protection level of Manifest.permission.CLEAR_APP_CACHE...
Set the user-agent header: Example: Stack Exchange Inbox Reputation and Badges source: https://stackoverflow.com/a/7523425/1048340 Perhaps this is related:...
You should not use PackageManager#getInstallerPackageName to check if the app was installed from Google Play or for licensing purposes for the following reasons: 1) The installer packagename can change in the future....
When the library project is built, the VectorDrawable creates PNG files for each density and places the original VectorDrawable in drawable-anydpi-v21 . If you place your VectorDrawable in drawable-anydpi-v21 in your...
The documentation states: Starting in KITKAT, no permissions are required to read or write to the returned path; it's always accessible to the calling app. This only applies to paths generated for package name of the...
Is there an equivalent command for retrieving Advertising Id? There is no equivalent command but it is possible if you use grep . The following command works on rooted devices
I want to be able to bypass this step and let my app get root permission programmatically without having to click on the "Grant" button on the SuperSu dialog. You can't. The user must grant your app root access. Unless...
SnapChat uses Google's SafetyNet Attestation API and does not specifically check if XPosed is installed. SnapChat runs SafetyNet the first time the app is launched. To make sure SnapChat does not specifically check for...
If you pull the Play Store APK from your device you can decompile it. I decompiled the APK and did a simple search for your error message. The error message can be found in the class...
You can read the binary from stdout instead of saving the png to the sdcard and then pulling it: This should save a little time, but not much. source: Read binary stdout data from adb shell?
This will set the color for the title, icon, and divider. Bound to change with any new Android version. Remember to call dialog.show() before calling this method.
SystemUI uses the following to determine if freeform multi-window mode is available: See:...
Using packageInfo.applicationInfo.theme will return the theme for the entire app and not each activity. This is hacky, but should get the theme for the current activity/context: I know this is an old question, but...
What I want to know is if there is a possibility to read kerning pairs from typeface using Android API. There is no public API to read kerning pairs from a TTF file. However, I pulled the relevant code from Apache FOP...
The below class is an improvement on the answers that have already been posted. This makes it easier to read and create a ColorFilter from a Bitmap . Example usage:
The accepted answer never closes the InputStream . Here is a utility method for getting a Bitmap in the assets folder:
Using string.indexOf(s) will get the first occurrence. Instead of having a map of keywords and using indexOf you could use a regular expression. I wrote this up real quick as an example: Screenshot of example EditText...