How to play audio through Bluetooth speaker even when headset is plugged in?

I have my phone connected to a Bluetooth speaker and the headphones plugged in. Now I’d like to play audio through the Bluetooth speaker. When I set the audio stream to AudioManager.STREAM_MUSIC it just plays over the headphones. It doesn’t matter if it plays on the headphones as well but I need it to play […]

Eclipse LogCat getting spammed by OpenGLRenderer

I am developing an android app (Phonegap) and whenever I am testing on the device that is plugged in I cannot see the error on the log because of OpenGLRenderer prepareDirty populating the log. It’s very annoying, how to get rid of it? Device: Lenovo Tab A7 see screenshot:

convert Mat to Bitmap Opencv for Android

I’m trying to covert a MAt to a Bitmap use following code : Bitmap bmp = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); Mat tmp = new Mat (width,height,CvType.CV_8UC1,new Scalar(4)); try { //Imgproc.cvtColor(seedsImage, tmp, Imgproc.COLOR_RGB2BGRA); Imgproc.cvtColor(seedsImage, tmp, Imgproc.COLOR_GRAY2RGBA, 4); Utils.matToBitmap(tmp, bmp);} catch (CvException e){Log.d(“Exception”,e.getMessage());} my seedsImage is a Mat object. And the Exception and got is 10-09 22:15:09.418: D/Exception(2461): […]

phonegap android application name appears before splash screen

This is my first attempt to create a simple android app using phonegap 1.9.0. The problem I’m facing is that when I start my app (both using emulator and my android phone) it displays the application name and icon before it proceeds to the splash screen I’ve set up. It looks like this: http://imgur.com/iZ1i3 How […]

When is the intent ACTION_DEVICE_STORAGE_LOW broadcasted?

In my application, I have registered a broadcast receiver to receive the system intent ACTION_DEVICE_STORAGE_LOW. I was expecting this to be broadcasted whenever the phone had low internal memory. So, I downloaded a few extra apps (my phone has a very small internal memory) which caused the OS to display the notification that the system […]

Use android.R.layout.simple_list_item_1 with a light theme

I have learned that when using android:entries with a ListView, it uses android.R.layout.simple_list_item_1 as the layout for a list item and android.R.id.text1 as the ID of the TextView inside that layout. Please, correct me if I’m wrong. Knowing this, I wanted to create my own adapter but use the same layout resources, in order to […]

keep android button selected state

I know this is a question that has been asked many times before, but I can’t seem to solve it in my code. I have two buttons, and when one is pressed, I would like to keep it in its selected state, and vice versa. I have tried doing it using but the setSelected and […]

Crop image to square – Android

How can I cut rectangular image (600 x 300) from left and right to fit in square ImageView ? I don’t want to resize image, I just want to crop it, to be 300 x 300. [SOLUTION] As @blackbelt said Bitmap cropImg = Bitmap.createBitmap(src, startX, startY, dstWidth, dstHeight); is great for cropping images. So how […]

ProgressDialog and AlertDialog cause leaked window

I have an Activity which shows a welcome message if started for the first time: @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); showWelcomeMessageIfNecessary(); } private void showWelcomeMessageIfNecessary() { final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); final Editor edit = prefs.edit(); if (!prefs.getBoolean(“welcomemessage”, false)) { edit.putBoolean(“welcomemessage”, true); edit.commit(); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage(R.string.messages_welcome_content).setCancelable(false).setPositiveButton(R.string.errors_ok, new DialogInterface.OnClickListener() { […]

FragmentTransaction .attach and .detach for Actionbar tabs

I’m trying to get the code here to work. It compiles fine. It will run. And it will load tab 1 (of 3). However, when I click on the 2nd or 3rd tab, I get this: java.lang.NoSuchMethodError: android.app.FragmentTransaction.detach this happens in the code here public void onTabUnselected(Tab tab, FragmentTransaction ft) { if (mFragment != null) […]

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