Skip to main content

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.

Filter by
Sorted by
Tagged with
6391 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?
capecrawler's user avatar
  • 67.9k
4352 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. Can someone provide a ...
4030 votes
12 answers
369k 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 ...
Ovidiu Latcu's user avatar
  • 72.2k
3553 votes
78 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 ...
3172 votes
54 answers
831k 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 ...
Mark's user avatar
  • 39.8k
3095 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?
Tyler's user avatar
  • 31.5k
2870 votes
35 answers
910k 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; ...
Bernard's user avatar
  • 45.4k
2734 votes
65 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....
bejoy george's user avatar
  • 29.7k
2327 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?
Pablo Fernandez's user avatar
2258 votes
32 answers
821k 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.
Brigadier's user avatar
  • 23.4k
2084 votes
23 answers
767k 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 ...
Bite code's user avatar
  • 591k
2082 votes
41 answers
579k 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 ...
lostInTransit's user avatar
1992 votes
18 answers
284k 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 ...
hap497's user avatar
  • 160k
1968 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 ...
Niko Gamulin's user avatar
  • 66.4k
1726 votes
39 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-...
david.s's user avatar
  • 17.5k
1623 votes
44 answers
1.2m views

How can I open a URL in Android's web browser from my application?

How to open a 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)); ...
Arutha's user avatar
  • 26.4k
1591 votes
39 answers
924k 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?
Fahad Ali Shaikh's user avatar
1537 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-...
UMAR-MOBITSOLUTIONS's user avatar
1490 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 ...
Frank Bozzo's user avatar
  • 15.3k
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?
vnshetty's user avatar
  • 20.1k
1464 votes
22 answers
660k 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 ...
Paresh Mayani's user avatar
1462 votes
34 answers
409k 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 ...
Isaac Waller's user avatar
  • 32.7k
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 ...
SweSnow's user avatar
  • 17.3k
1389 votes
44 answers
652k 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. ...
1312 votes
42 answers
723k 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.
Naftuli Kay's user avatar
  • 90.3k
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 ...
Tim H's user avatar
  • 13.5k
1300 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?
M7M's user avatar
  • 13.1k
1298 votes
50 answers
700k 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 ...
Pentium10's user avatar
  • 207k
1250 votes
40 answers
298k 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 ...
1242 votes
67 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 ...
ant2009's user avatar
  • 23.8k
1242 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. ...
1236 votes
55 answers
626k 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 ...
delete's user avatar
  • 18.9k
1222 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....
michael's user avatar
  • 109k
1215 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 ...
1204 votes
35 answers
820k 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 ...
herpderp's user avatar
  • 16k
1194 votes
37 answers
790k 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 ...
simplified.'s user avatar
  • 12.1k
1161 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 ...
gav's user avatar
  • 29.1k
1159 votes
40 answers
697k 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" ...
Richard's user avatar
  • 28.8k
1132 votes
17 answers
630k 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 ...
Tom Leese's user avatar
  • 19.6k
1130 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; ...
1125 votes
45 answers
839k 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" ...
EyesClear's user avatar
  • 28.3k
1107 votes
14 answers
923k 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), ...
Hesam's user avatar
  • 53.2k
1107 votes
21 answers
845k 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.
Andrea Baccega's user avatar
1098 votes
22 answers
823k 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 ...
Rob's user avatar
  • 15.2k
1079 votes
36 answers
791k 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 ...
Ozzie's user avatar
  • 11.7k
1067 votes
29 answers
372k 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 ...
Manu's user avatar
  • 10.7k
1061 votes
32 answers
710k views

How can I disable landscape mode in Android?

How can I disable landscape mode for some of the views in my Android app?
lostInTransit's user avatar
1061 votes
23 answers
611k 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<...
Pongpat's user avatar
  • 13.3k
1058 votes
34 answers
606k 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.
Bee's user avatar
  • 14.4k
1053 votes
23 answers
293k views

How do I rotate the Android emulator display? [duplicate]

How can I rotate the Android emulator display to see it in landscape mode?
mahdi 's user avatar
  • 16.3k

1
2 3 4 5
28382