Questions tagged [android]
Android is Google's mobile operating system, used for programming or developing digital devices (Smartphones, Tablets, Automobiles, TVs, Wear, Glass, IoT). For topics related to Android, use Android-specific tags such as android-intent, android-activity, android-adapter, etc. For questions other than development or programming but related to the Android framework, use this link: https://android.stackexchange.com.
                                	
	android
    
                            
                        
                    
            1,417,452
            questions
        
        
            6377
            votes
        
        
            34
            answers
        
        
            1.5m
            views
        
    What is the difference between px, dip, dp, and sp?
                What is the difference between the units of measure
px, dip, dp, and sp?
            
        
       
    
            4346
            votes
        
        
            130
            answers
        
        
            1.8m
            views
        
    How can I close/hide the Android soft keyboard programmatically?
                I have an EditText and a Button in my layout.
After writing in the edit field and clicking on the Button, I want to hide the virtual keyboard when touching outside the keyboard. I assume that this is ...
            
        
       
    
            4024
            votes
        
        
            12
            answers
        
        
            367k
            views
        
    Proper use cases for Android UserManager.isUserAGoat()?
                I was looking at the new APIs introduced in Android 4.2.
While looking at the UserManager class I came across the following method:
public boolean isUserAGoat()
  
  Used to determine whether the ...
            
        
       
    
            3547
            votes
        
        
            77
            answers
        
        
            1.1m
            views
        
    Why is the Android emulator so slow? How can we speed up the Android emulator?
                I have got a 2.67  GHz Celeron processor, and 1.21  GB of RAM on a x86 Windows XP Professional machine.
My understanding is that the Android Emulator should start fairly quickly on such a machine, but ...
            
        
       
    
            3168
            votes
        
        
            54
            answers
        
        
            828k
            views
        
    How to stop EditText from gaining focus when an activity starts in Android?
                I have an Activity in Android, with two elements:
EditText
ListView
When my Activity starts, the EditText immediately has the input focus (flashing cursor). I don't want any control to have input ...
            
        
       
    
            3091
            votes
        
        
            54
            answers
        
        
            1.3m
            views
        
    Is there a unique Android device ID?
                Do Android devices have a unique ID, and if so, what is a simple way to access it using Java?
            
        
       
    
            2868
            votes
        
        
            35
            answers
        
        
            907k
            views
        
    How can I save an activity state using the save instance state?
                I've been working on the Android SDK platform, and it is a little unclear how to save an application's state. So given this minor re-tooling of the 'Hello, Android' example:
package com.android.hello;
...
            
        
       
    
            2729
            votes
        
        
            64
            answers
        
        
            1.5m
            views
        
    How can I fix 'android.os.NetworkOnMainThreadException'?
                I got an error while running my Android project for RssReader. 
Code:
URL url = new URL(urlToRssFeed);
SAXParserFactory factory = SAXParserFactory.newInstance();
SAXParser parser = factory....
            
        
       
    
            2324
            votes
        
        
            75
            answers
        
        
            1.5m
            views
        
    How do I center text horizontally and vertically in a TextView?
                How do I center the text horizontally and vertically in a TextView, so that it appears exactly in the middle of the TextView in Android?
            
        
       
    
            2254
            votes
        
        
            32
            answers
        
        
            817k
            views
        
    What is 'Context' on Android?
                In Android programming, what exactly is a Context class and what is it used for?
I read about it on the developer site, but I am unable to understand it clearly.
            
        
       
    
            2085
            votes
        
        
            23
            answers
        
        
            763k
            views
        
    Is there a way to run Python on Android?
                We are working on an S60 version and this platform has a nice Python API..
However, there is nothing official about Python on Android, but since Jython exists, is there a way to let the snake and the ...
            
        
       
    
            2080
            votes
        
        
            41
            answers
        
        
            578k
            views
        
    How to lazy load images in ListView in Android
                I am using a ListView to display some images and captions associated with those images. I am getting the images from the Internet. Is there a way to lazy load images so while the text displays, the UI ...
            
        
       
    
            1991
            votes
        
        
            18
            answers
        
        
            283k
            views
        
    "Debug certificate expired" error in Eclipse Android plugins
                I am using Eclipse Android plugins to build a project, but I am
getting this error in the console window:
[2010-02-03 10:31:14 - androidVNC]Error generating final archive:
Debug certificate expired ...
            
        
       
    
            1966
            votes
        
        
            44
            answers
        
        
            1.2m
            views
        
    How to get screen dimensions as pixels in Android
                I created some custom elements, and I want to programmatically place them to the upper right corner (n pixels from the top edge and m pixels from the right edge). Therefore I need to get the screen ...
            
        
       
    
            1715
            votes
        
        
            37
            answers
        
        
            1.5m
            views
        
    Android 8: Cleartext HTTP traffic not permitted
                I had reports from users with Android 8 that my app (that uses back-end feed) does not show content. After investigation I found following Exception happening on Android 8:
08-29 12:03:11.246 11285-...
            
        
       
    
            1617
            votes
        
        
            43
            answers
        
        
            1.2m
            views
        
    How can I open a URL in Android's web browser from my application?
                How to open an URL from code in the built-in web browser rather than within my application?
I tried this:
try {
    Intent myIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(download_link));
    ...
            
        
       
    
            1582
            votes
        
        
            39
            answers
        
        
            910k
            views
        
    How can you get the build/version number of your Android application?
                I need to figure out how to get or make a build number for my Android application. I need the build number to display in the UI.
Do I have to do something with AndroidManifest.xml?
            
        
       
    
            1536
            votes
        
        
            53
            answers
        
        
            1.3m
            views
        
    How do I pass data between Activities in Android application?
                I have a scenario where, after logging in through a login page, there will be a sign-out button on each activity.
On clicking sign-out, I will be passing the session id of the signed in user to sign-...
            
        
       
    
            1481
            votes
        
        
            29
            answers
        
        
            1.5m
            views
        
    Is there a way to get the source code from an APK file?
                The hard drive on my laptop just crashed and I lost all the source code for an app that I have been working on for the past two months.
All I have is the APK file that is stored in my email from when ...
            
        
       
    
            1473
            votes
        
        
            17
            answers
        
        
            299k
            views
        
    What is the difference between match_parent and fill_parent?
                I'm a little confused about two XML properties: match_parent and fill_parent. It seems that both are the same. Is there any difference between them?
            
        
       
    
            1464
            votes
        
        
            22
            answers
        
        
            657k
            views
        
    What is the difference between gravity and layout_gravity in Android?
                I know we can set the following values to the android:gravity and  android:layout_gravity properties:
center
center_vertical
center_horizontal, etc.
But I am confused regarding both of these.
What ...
            
        
       
    
            1462
            votes
        
        
            34
            answers
        
        
            408k
            views
        
    Activity restart on rotation Android
                In my Android application, when I rotate the device (slide out the keyboard) then my Activity is restarted (onCreate is called). Now, this is probably how it's supposed to be, but I do a lot of ...
            
        
       
    
            1446
            votes
        
        
            8
            answers
        
        
            1.3m
            views
        
    Hex transparency in colors [duplicate]
                I'm working on implementing a widget transparency option for my app widget although I'm having some trouble getting the hex color values right. Being completely new to hex color transparency I ...
            
        
       
    
            1388
            votes
        
        
            44
            answers
        
        
            651k
            views
        
    Strange OutOfMemory issue while loading an image to a Bitmap object
                I have a ListView with a couple of image buttons on each row. When the user clicks the list row, it launches a new activity. I have had to build my own tabs because of an issue with the camera layout. ...
            
        
       
    
            1306
            votes
        
        
            42
            answers
        
        
            714k
            views
        
    Run/install/debug Android applications over Wi-Fi?
                I thought there was a way to test your applications in development over Wi-Fi. Is this possible?
I'd love to be able to untether my phone and develop wirelessly.
            
        
       
    
            1305
            votes
        
        
            13
            answers
        
        
            269k
            views
        
    'Must Override a Superclass Method' Errors after importing a project into Eclipse
                Anytime I have to re-import my projects into Eclipse (if I reinstalled Eclipse, or changed the location of the projects), almost all of my overridden methods are not formatted correctly, causing the ...
            
        
       
    
            1295
            votes
        
        
            44
            answers
        
        
            1.8m
            views
        
    How to get current time and date in Android
                How can I get the current time and date in an Android app?
            
        
       
    
            1291
            votes
        
        
            50
            answers
        
        
            694k
            views
        
    Activity has leaked window that was originally added
                What is this error, and why does it happen?
05-17 18:24:57.069: ERROR/WindowManager(18850): Activity com.mypkg.myP has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@44c46ff0 ...
            
        
       
    
            1251
            votes
        
        
            40
            answers
        
        
            297k
            views
        
    Is quitting an application frowned upon?
                Moving on in my attempt to learn Android, I just read the following:
  Question: Does the user have a choice to kill the application 
  unless we put a menu option in to kill it? If no such option ...
            
        
       
    
            1243
            votes
        
        
            45
            answers
        
        
            450k
            views
        
    Android SDK installation doesn't find JDK
                I'm trying to install the Android SDK on my Windows 7 x64 System.  
jdk-6u23-windows-x64.exe is installed, but the Android SDK setup refuses to proceed because it doesn't find the JDK installation.
...
            
        
       
    
            1235
            votes
        
        
            55
            answers
        
        
            618k
            views
        
    How do I "select Android SDK" in Android Studio?
                After a successful import of an Eclipse-Android-Project into "Android Studio 1.4", I get the error
"Please select Android SDK"
when I click on the button to run the application in ...
            
        
       
    
            1229
            votes
        
        
            66
            answers
        
        
            1.1m
            views
        
    You need to use a Theme.AppCompat theme (or descendant) with this activity
                Android Studio 0.4.5
Android documentation for creating custom dialog boxes: http://developer.android.com/guide/topics/ui/dialogs.html
If you want a custom dialog, you can instead display an ...
            
        
       
    
            1216
            votes
        
        
            38
            answers
        
        
            1.7m
            views
        
    How do I display an alert dialog on Android?
                I want to display a dialog/popup window with a message to the user that shows "Are you sure you want to delete this entry?" with one button that says 'Delete'. When Delete is touched, it should delete ...
            
        
       
    
            1216
            votes
        
        
            30
            answers
        
        
            1.0m
            views
        
    Can't create handler inside thread that has not called Looper.prepare()
                What does the following exception mean; how can I fix it?
This is the code:
Toast toast = Toast.makeText(mContext, "Something", Toast.LENGTH_SHORT);
This is the exception:
java.lang....
            
        
       
    
            1202
            votes
        
        
            35
            answers
        
        
            812k
            views
        
    Android "Only the original thread that created a view hierarchy can touch its views."
                I've built a simple music player in Android. The view for each song contains a SeekBar, implemented like this: 
public class Song extends Activity implements OnClickListener,Runnable {
    private ...
            
        
       
    
            1193
            votes
        
        
            37
            answers
        
        
            786k
            views
        
    findViewById in Fragment
                I am trying to create an ImageView in a Fragment which will refer to the ImageView element which I have created in the XML for the Fragment. However, the findViewById method only works if I extend an ...
            
        
       
    
            1162
            votes
        
        
            18
            answers
        
        
            418k
            views
        
    Fling gesture detection on grid layout
                I want to get fling gesture detection working in my Android application.
What I have is a GridLayout that contains 9 ImageViews. The source can be found here: Romain Guys's Grid Layout.
That file I ...
            
        
       
    
            1156
            votes
        
        
            40
            answers
        
        
            691k
            views
        
    How to make links in a TextView clickable
                I have the following TextView defined:
<TextView 
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" android:text="@string/txtCredits"
   ...
            
        
       
    
            1131
            votes
        
        
            108
            answers
        
        
            905k
            views
        
    R cannot be resolved - Android error
                I just downloaded and installed the new Android SDK. I wanted to create a simple application to test drive it.
The wizard created this code:
package eu.mauriziopz.gps;
import android.app.Activity;
...
            
        
       
    
            1131
            votes
        
        
            16
            answers
        
        
            629k
            views
        
    Download a file with Android, and showing the progress in a ProgressDialog
                I am trying to write a simple application that gets updated. For this I need a simple function that can download a file and show the current progress in a ProgressDialog. I know how to do the ...
            
        
       
    
            1124
            votes
        
        
            45
            answers
        
        
            833k
            views
        
    How to add dividers and spaces between items in RecyclerView
                This is an example of how it could have been done previously in the ListView class, using the divider and dividerHeight parameters:
<ListView
    android:id="@+id/activity_home_list_view"
...
            
        
       
    
            1106
            votes
        
        
            14
            answers
        
        
            917k
            views
        
    How to manage startActivityForResult on Android
                In my activity, I'm calling a second activity from the main activity by startActivityForResult. In my second activity, there are some methods that finish this activity (maybe without a result), ...
            
        
       
    
            1106
            votes
        
        
            21
            answers
        
        
            840k
            views
        
    Static way to get 'Context' in Android?
                Is there a way to get the current Context instance inside a static method? 
I'm looking for that way because I hate saving the 'Context' instance each time it changes.
            
        
       
    
            1096
            votes
        
        
            22
            answers
        
        
            818k
            views
        
    How to convert a Drawable to a Bitmap?
                I would like to set a certain Drawable as the device's wallpaper, but all wallpaper functions accept Bitmaps only. I cannot use WallpaperManager because I'm pre 2.1.
Also, my drawables are downloaded ...
            
        
       
    
            1078
            votes
        
        
            35
            answers
        
        
            788k
            views
        
    Android Studio: Add jar as library?
                I'm trying to use the new Android Studio but I can't seem to get it working correctly.
I'm using the Gson library to serialize/deserialize JSON-objects. But the library somehow isn't included in the ...
            
        
       
    
            1065
            votes
        
        
            28
            answers
        
        
            369k
            views
        
    Place cursor at the end of text in EditText
                I am changing the value of an EditText on keyListener.
But when I change the text the cursor is moving to the beginning of the EditText.
I need the cursor to be at the end of the text.
How to move ...
            
        
       
    
            1062
            votes
        
        
            23
            answers
        
        
            608k
            views
        
    How to create RecyclerView with multiple view types
                From Create dynamic lists with RecyclerView:
When we create a RecyclerView.Adapter we have to specify ViewHolder that will bind with the adapter.
public class MyAdapter extends RecyclerView.Adapter<...
            
        
       
    
            1058
            votes
        
        
            32
            answers
        
        
            706k
            views
        
    How can I disable landscape mode in Android?
                How can I disable landscape mode for some of the views in my Android app?
            
        
       
    
            1055
            votes
        
        
            34
            answers
        
        
            601k
            views
        
    How to check if a service is running on Android?
                How do I check if a background service is running?
I want an Android activity that toggles the state of the service -- it lets me turn it on if it is off and off if it is on.
            
        
       
    
            1054
            votes
        
        
            23
            answers
        
        
            292k
            views
        
    How do I rotate the Android emulator display? [duplicate]
                How can I rotate the Android emulator display to see it in landscape mode?