Android: how to play music at maximum possible volume?

I know the question can be regarded as “politically incorrect”, but I’m designing an app which “by design” must get the attention of people within the maximum possible distance range, otherwise it will not be used… šŸ™‚ I’m currently using SoundManager class, and this is the code which plays my ogg clip: public void playSound(int […]

SwiperefreshLayout in Android

i am using SwipeRefreshLayout in my below layout: <?xml version=”1.0″ encoding=”utf-8″?> <LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android” android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:background=”@color/homePageBackground” android:orientation=”vertical” > <android.support.v4.widget.SwipeRefreshLayout android:id=”@+id/swipeRefreshLayout_listView” android:layout_width=”match_parent” android:layout_height=”match_parent” > <LinearLayout android:layout_width=”match_parent” android:layout_height=”wrap_content” android:orientation=”vertical” > <fragment android:id=”@+id/announcementHomefragment” android:name=”in.test.app.AnnouncementFragment” android:layout_width=”match_parent” android:layout_height=”wrap_content” /> <ScrollView android:layout_width=”match_parent” android:layout_height=”wrap_content” android:background=”@color/homePageBackground” > <RelativeLayout android:layout_width=”match_parent” android:layout_height=”wrap_content” android:layout_marginBottom=”15dp” android:background=”@color/homePageBackground” > <TextView android:id=”@+id/newsTitle” android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:layout_gravity=”center” android:layout_marginLeft=”15dp” android:layout_marginTop=”5dp” android:gravity=”center” android:text=”@string/new_list” android:textAppearance=”?android:attr/textAppearanceSmall” […]

Android licensing sample returns code 3. What does it mean?

I tried licensing sample. It said “application error=3”. I found the sheet of licensing response codes at developer.android.com, but how does number 3 corresponds to the above list? What does that code mean?

Android Contact Picker with only Phone Numbers

I found on SO that to launch a filtered version of contact picker (which only shows contacts that have phone numbers), I can just use this: Intent pickContactIntent = new Intent( Intent.ACTION_PICK, ContactsContract.Contacts.CONTENT_URI ); pickContactIntent.setType(ContactsContract.CommonDataKinds.Phone.CONTENT_TYPE); startActivityForResult(pickContactIntent, CONTACT_PICKER_RESULT); So this works. I’m just trying to figure out how to retrieve the name and phone number of […]

setting audio file as Ringtone

I have save file in sdcard/media/audio/ringtones folder. That file will appear in list of ringtone selection from settings/sound/phone Ringtone. But I want to set that file as a ringtone from my code. Here is my code. File k = new File(path, filename); ContentValues values = new ContentValues(); values.put(MediaStore.MediaColumns.DATA, k.getAbsolutePath()); values.put(MediaStore.MediaColumns.TITLE, “TwiAppclip”); values.put(MediaStore.MediaColumns.MIME_TYPE, “audio/*”); values.put(MediaStore.Audio.Media.ARTIST, “cssounds […]

How can EditText accept only integer or float value?

I am new to Android development. In my project, Iā€™m using EditText, but I want to force it to only accept an integer or float value. How can I do that?

Validate an email inside an EditText

This question already has an answer here: how to check edittext's text is email address or not? 14 answers

Tint menu icons

I’m building an Android app and I use the icons from the Action Bar Icon Pack to use in the action bar. I define them through the xml files in the menu folder. Is there a way to “tint” these icons so that they are all the same color? So far, I have to do […]

Android How can I call Camera or Gallery Intent Together

If I want to capture image from native camera, I can do: Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri); intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1); startActivityForResult(intent, IMAGE_CAPTURE); If I want to get image from gallery, I can do: Intent intent = new Intent(); intent.setType(“image/*”); intent.setAction(Intent.ACTION_GET_CONTENT); startActivityForResult(Intent.createChooser(intent, “Select Picture”), SELECT_PICTURE); I am wondering how can put the above two together. […]

LinearLayout.LayoutParams how to use dip…?

I’m trying to set the height of my LinearLayout to 45 dip. How can I do this when extending LinearLayout? Right now I just did: LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, 45);

Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.