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
Filter by
Sorted by
Tagged with
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?
capecrawler's user avatar
  • 67.8k
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 ...
Ovidiu Latcu's user avatar
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 ...
Mark's user avatar
  • 39.8k
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?
Tyler's user avatar
  • 31.5k
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; ...
Bernard's user avatar
  • 45.4k
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....
bejoy george's user avatar
  • 29.6k
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?
Pablo Fernandez's user avatar
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.
Brigadier's user avatar
  • 23.3k
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 ...
Bite code's user avatar
  • 587k
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 ...
lostInTransit's user avatar
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 ...
hap497's user avatar
  • 159k
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 ...
Niko Gamulin's user avatar
  • 66.3k
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-...
david.s's user avatar
  • 17.4k
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)); ...
Arutha's user avatar
  • 26.3k
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?
Fahad Ali Shaikh's user avatar
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-...
UMAR-MOBITSOLUTIONS's user avatar
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 ...
Frank Bozzo's user avatar
  • 15.2k
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
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 ...
Paresh Mayani's user avatar
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 ...
Isaac Waller's user avatar
  • 32.8k
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
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.
Naftuli Kay's user avatar
  • 89.4k
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
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?
M7M's user avatar
  • 13k
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 ...
Pentium10's user avatar
  • 206k
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 ...
delete's user avatar
  • 18.7k
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 ...
ant2009's user avatar
  • 25.5k
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....
michael's user avatar
  • 108k
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 ...
herpderp's user avatar
  • 16k
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 ...
simplified.'s user avatar
  • 12.1k
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 ...
gav's user avatar
  • 29.1k
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" ...
Richard's user avatar
  • 28.8k
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 ...
Tom Leese's user avatar
  • 19.5k
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" ...
EyesClear's user avatar
  • 28.3k
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), ...
Hesam's user avatar
  • 53k
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.
Andrea Baccega's user avatar
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 ...
Rob's user avatar
  • 15.2k
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 ...
Ozzie's user avatar
  • 11.7k
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 ...
Manu's user avatar
  • 10.7k
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<...
Pongpat's user avatar
  • 13.3k
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?
lostInTransit's user avatar
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.
Bee's user avatar
  • 14.3k
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?
mahdi 's user avatar
  • 16.3k

1
2 3 4 5
28350