I'm trying to make an Android app that uses collision detection. To do this, I'm trying to set a rectangle to an ImageView. The only things I've found are ways to set a rectangle to a sprite or a specific point. One of the ImageViews that I need to detect moves across the screen even though it isn't a sprite. Is there a way to set a rectangle to an ImageView so I can detect when the two rectangles collide?

This is the code I used for making the ImageView move:

int x=brickimg.getRight()-brickimg.getLeft();
   int y=brickimg.getBottom()-brickimg.getTop();
   final TranslateAnimation translate = new TranslateAnimation(
           Animation.ABSOLUTE,x1, Animation.ABSOLUTE,
           -4000, Animation.ABSOLUTE,0,
           Animation.ABSOLUTE,y);//How far it goes on the axis. The first x goes left, second x goes right, first y goes up, second goes down
   translate.setDuration(1200);//speed of the animation

I'm trying to get familiar with RxJava. Here's the use case that i'm trying to achieve:

I have a button on my screen and i'm trying to collect the number of taps. So if a user taps the button, a click is registered and a log is produced. Now if the user clicks the button twice, then it registers both clicks, collects them and outputs 2 instead of 1.

Essentially, i'm trying to accumulate the number of clicks, over a span of time and then spit out the final results. I'm guessing "buffer" is the method that I need to be using. I whipped up a quick example in Android (code follows), but the buffer method doesn't seem to be as simple as just collect all event inputs and spit out a collection.

public class DemoFragment
    extends Fragment {

    private int _tapCount = 0;
    private Observable<List<Integer>> _bufferedObservable;
    private Observer<List<Integer>> _observer;

    public void onActivityCreated(@Nullable Bundle savedInstanceState) {

        _bufferedObservable = _getBufferedObservable();
        _observer = _getObserver();

    // the library butterknife allows this
    public void onButtonTapped() {
        _log("GOT A TAP");

    private Observable<List<Integer>> _getBufferedObservable() {
        return Observable.create(new Observable.OnSubscribe<Integer>() {

            public void call(Subscriber<? super Integer> subscriber) {
                subscriber.onNext(1);   // send one tap here

        }).buffer(2, TimeUnit.SECONDS); // collect all taps in the last 2s

    private Observer<List<Integer>> _getObserver() {
        return new Observer<List<Integer>>() {

            public void onCompleted() {
                _log(String.format("%d taps", _tapCount));
                _tapCount = 0; // reset tap count

            public void onError(Throwable e) {}

            public void onNext(List<Integer> integers) {
                if (integers.size() > 0) {
                    for (int i : integers) {
                        _tapCount += i;
                } else {
                    _log("No taps received");

    // ... other method that help wiring up the example (irrelevant to RxJava)

Can anyone help me understand the misconception in my understanding here?

Problem 1: I'm expecting _getObserver()'s onNext to send me a list with the accumulated number of taps. So if the button was hit 5 times, then i'm expecting a List with 5 items, each of which have the value "1". I'm guessing this is incorrect at many levels

Problem 2: I basically do a console log if no events were received by checking List<Integer> integers size. If list is not empty, i throw in a console log, saying "not taps received". It appears that the Observable NEVER stops. It's almost like a timer, where it constantly keeps going on and on, even when no button tap was registered. Is there way to stop the Observable, if no event was registered in the last 10s?

Problem 3: The number of emits seem to almost exponentially increase. It's almost like its gathering the button empty taps from all previous times.

I have a fragment that contain a simple EditText and when I run my programm the EdtiText will be not Editable but if Edit it within the code it works like this :


Also when I don't use fragment (mean in the normaly Activity) then the EditText will be Editable. So my Layout that contain the EDitText is:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" >

    android:layout_height="wrap_content" >

        android:hint="@string/search" >

        <requestFocus />

        android:background="@drawable/search_setting" />


    android:layout_height="fill_parent" >

it's called search_text. and my fragment is :

public class ListElecteur extends Fragment {

private ListView listElecteurs;
private EditText search ;

public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {

    final View view = inflater.inflate(R.layout.list_electeurs_fragment,
            container, false);

    return view;

ah, I forgot, when I typed in myEditText the current Tab take the focus so any thing wrote in myEditText :(, do you have an idea. Thanks.

I am new to android and i am making listview based app. In my app i have items from Acitity_2 to Activity_1. Activity_1 has the list view. when user click on ADD button of activity1 then Activity_2 will be called. Activity_2 has the EditText. The value of EditText should update the ListView. But it only takes last value of the Edittext.

Here is the code of Activity_2:

          Intent intent = new Intent(ItemDetails.this, MainActivity.class);
          intent.putExtra("values", values);

Code for Activity_1

        /** Defining the ArrayAdapter to set items to ListView */
    adapter = new ArrayAdapter(this, android.R.layout.simple_list_item_multiple_choice, list);
  // list.add("Aluminium foil");

        String itemVal=getIntent().getStringExtra("values");



Please help me to solve this.Thanks in advance.

Let's say i want to write a quick app that turns on Wifi when I am near into some place and turns it off when I get out of that place.

Ok, so I am using a Geofence (150m radius) and I am getting a very, very inaccurate location:

enter image description here

However, if I turn the Wifi on or I turn "Scanning always available" (in Wifi settings) then the location gets almost perfect:

enter image description here

So I am trying to know if what I want to do is possible (only having 3G/GSM location, because I do not have Wifi neither GPS turned on).

Any ideas? Something that am I missing?

In my Listview, i want to load images while scrolling also as Pinterest app does. I know there are solutions like using UIL and Volley to stop image loading on scroll to avoid lag but then how Pinterest people are handling this situation without any lag?

Anyone has any idea about this?

I would just like to know if it is possible or not. If it is possible can you please point me where to start?

The idea: I would like to make a service that will run when my tablet boots up. This service will automatically run a remote desktop access app (from google play market) and it will establish a connection with predefined settings, so I do not have to manually start the remote desktop app and click "Connect". Is this possible even if I do not have the source code of the remote desktop app? Can you please help me?

Or is there another way to establish remote desktop connection from my Android tablet right when the tablet boots up?

PS: I am not doing this for somebody else, it is just for my needs, so please dont look at this as it is nonsense because no one will run any app like this on startup anyways. :)

Thank you

I have an Android application that needs to access data from different screens. The main problem is, each one needs to be able to modify the data, and there is quite a bit of it - 3 million integers divided among six arrays.

The options that I can think of are:

  1. Put each screen in a separate view, and use a ViewAnimator as the topmost layout, switching between the child views as necessary; this way, the arrays are defined in the main activity and are accessible (both reading and writing) by all of the screens.

  2. Put each screen in its own Activity, and pass the data from one screen to another by putting it into a Bundle that is included in the startActivityForResult call (and any changes would be passed back through the returned Intent's Extras in onActivityResult). The problem with this is, the data has to be copied quite a few times, which, it seems to be, involves quite a bit of overhead in terms of both time and memory.

  3. Create a Class to hold the data; create a variable of that Class in the main activity, and pass that variable back and forth - but is the variable itself being passed to the second activity, or a copy of it (so any changes would then not be reflected in the variable in the main activity)?

Is there a preferred method for a situation like this? Am I leaving something out?

In my Application, i tried to create a Array with multiple check boxes.My app worked when i click CheckBoxAll select all checkboxes and when i uncheck CheckBoxAll deselect all chekboxes.But, if i deselect one of the chekboxes when all of them are checked,CheckBoxAll its not un-checking..

This is my array

 ArrayList<CheckBox> boxes = new ArrayList<CheckBox>();

checkBoxAll = createCheckBox(R.id.checkBoxAll);
        checkBoxCompany = createCheckBox(R.id.checkBoxCompany);
        checkBoxType = createCheckBox(R.id.checkBoxType);
        checkBoxName = createCheckBox(R.id.checkBoxName);
        checkBoxPhone = createCheckBox(R.id.checkBoxPhone);
        checkBoxAddress = createCheckBox(R.id.checkBoxAddress);
        checkBoxEmail = createCheckBox(R.id.checkBoxEmail);
        checkBoxwebSite = createCheckBox(R.id.checkBox4WebSite);

and this is my function

 public void checkAllListener() {
        checkBoxAll.setOnCheckedChangeListener(new OnCheckedChangeListener() {

            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                // TODO Auto-generated method stub

                for(CheckBox chk : boxes) {

Welcome all

i need to add a onScreen Joystick to my game.

I found some code examples of joysticks but none of them moves a view on the screen, and i dont know how to move a view in the screen with the exact movement and acceleration of the joystick movement.

This is one of the examples i found:


Source code: http://goo.gl/m0bTse

I have no idea of how to move a view (my game spaceship) in the screen with the joystick movement.

Thanks a lot

I'm working with Azure Mobile Services, I need to get emails from table depending on a list of Id. I have a method that get specific item from the table by looping the list of Id and geting each item. But everithing executes beforeonComplete. This is my code:

private ArrayList<String> administratorsEmail = new ArrayList<String>();

public boolean getAdminsEmail(List<String> adminList)

    for(String ids : adminList)
        UsersTable.lookUp(ids, new TableOperationCallback<Users>()
            public void onCompleted(Users entity, Exception exception, ServiceFilterResponse response)
                if (exception == null)


I need to fill the administratorsEmail list. I need to execute some code after the list administratorsEmail has been filled completely. But I can't put code in onComplete method because it would execute the same times than the loop.

I need to know when OnCompleted has finished. Any body could give a better idea or some help for this?

Thank you!

I have a listview that contains a botton in each row.

The button open a dialog for single value choice when clicked.

The thing is when I move down the list, values in the buttons are moving. The first value is repeated each 8 rows.

Here is my getView() Code :

public static class ViewHolder {
    public Button listaCerrada;

    public View getView(final int position, View convertView, ViewGroup parent) {
    final ViewHolder holder;
    try {
        if (convertView == null) {
            holder = new ViewHolder();
            LayoutInflater vi = (LayoutInflater) ctx
            convertView = vi.inflate(R.layout.row_lista_form, null);

            holder.listaCerrada = (Button) convertView
        } else {
            holder = (ViewHolder) convertView.getTag();

        holder.listaCerrada.setOnClickListener(new OnClickListener() {

            public void onClick(View v) {
                // Get list Values
                String datoValido = metrica.getlForms().get(position)
                AlertDialog.Builder adb = new AlertDialog.Builder(ctx);
                // HAY:HAY;NO HAY:NO HAY
                String[] parts = datoValido.split(";");
                ArrayList<String> values = new ArrayList<String>();
                for (String s : parts) {
                    String[] part2 = s.split(":");

                final CharSequence[] items = values
                        .toArray(new CharSequence[values.size()]);

                adb.setSingleChoiceItems(items, 0,
                        new DialogInterface.OnClickListener() {

                            public void onClick(DialogInterface dialog,
                                    int which) {


                adb.setNegativeButton("Cancelar", null);



    } catch (Exception e) {
    return convertView;

Recently started getting a rather odd Catlog which doesn't describe what's going wrong very well.

I have it posted here: http://pastie.org/9415113

The error seems to be this part here:

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.brad.myapplication/com.example.brad.myapplication.MyActivity}: java.lang.NullPointerException
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
        at android.app.ActivityThread.access$600(ActivityThread.java:130)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:137)
        at android.app.ActivityThread.main(ActivityThread.java:4745)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:511)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
        at dalvik.system.NativeStart.main(Native Method)
 Caused by: java.lang.NullPointerException
        at com.example.brad.myapplication.MyActivity.onCreate(MyActivity.java:55)
        at android.app.Activity.performCreate(Activity.java:5008)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
        at android.app.ActivityThread.access$600(ActivityThread.java:130)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:137)
        at android.app.ActivityThread.main(ActivityThread.java:4745)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:511)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
        at dalvik.system.NativeStart.main(Native Method)

Line 55:

        DebugCarTxt = (EditText) findViewById(R.id.DebugCar);

        // you should  instantiate 'DatabaseHandler'  here
        DatabaseHandler db = new DatabaseHandler(this); // "this" refer to the context
        Car cars = db.getCurrentCar();

        db.createCar(new Car(cars.get_id(),cars.get_address(),cars.get_postcode(),cars.get_image()));
//this is line 55       String rows= "id : "+ cars.get_id()+ " address : "+cars.get_address() + "postcode : "+cars.get_postcode()+" image : "+cars.get_image();

I use my worklight app as a container for a server page. However, the server page prompts a window authentication challenge dialog. So basically when your enter this page, a dialog window would show to ask for your credentials. It shows on the mobile browser, but does not show inside the app for android and ios. I did some research. There is only native solution. It seems that authentication pupup does not work with UIWebView. Does worklight has a solution / workaround for this? Thanks.

I am having problems working properly with the Android File API.

Here is what I want to achieve, I am downloading videos from Amazon which should be saved locally after they have been fully downloaded. I am doing this in pretty straighforward manner (code has been shortened and I just show the essential lines):

inputStream = connection.getInputStream();
fileOutputStream = context.openFileOutput("my_video", Context.MODE_PRIVATE);
// Read bytes (and store them) until there is nothing more to read(-1)
do {
    int numread = inputStream.read(buffer);
    if (numread <= 0){
    fileOutputStream.write(buffer, 0, numread);
} while (true);

where inputStream and fileOutputStream are instance variables.

This actually works pretty well if the video gets fully downloaded. In that case, everything is fine and I can access the video locally afterwards.

However, it can happen in the app that the video download gets interrupted and thus needs to be cancelled. If this is the case, I would like to delete the file which is there but obviously not complete.

The code to delete the file is as follows:

FileProvider fileProvider = new FileProvider();
File newFile = new File(context.getFilesDir(), "my_video");     
Uri contentUri = FileProvider.getUriForFile(context, FILE_PROVIDER, newFile);
fileProvider.delete(fileToDelete, null, null);

The last line fileProvider.delete(fileToDelete, null, null); is throwing a NullPointerException, I debugged it and saw that the fileProvider is initialized, so I strongly assume that there is an issue with the URI that I am using to call delete, but I don't know what's wrong with it. Does anyone know how to do a proper delete using the file provider?

Update: I hope this isn't too much of an overkill, I am now posting my whole VideoDownloader class:

public class VideoDownloader {

  private final int TIMEOUT_CONNECTION = 5000;//5sec
  private final int TIMEOUT_SOCKET = 30000;//30sec

  private static final String FILE_PROVIDER = "com.orangewise.fileprovider";

  private Context context;
  private String videoURL;
  private String targetFileName;

  private HttpURLConnection connection;
  private InputStream inputStream;
  private FileOutputStream fileOutputStream;

  private boolean downloadFinished;

  public VideoDownloader(Context context, String videoURL, String targetFileName) {
    this.context = context;
    this.videoURL = videoURL;
    this.targetFileName = targetFileName;
    this.downloadFinished = false;

  public boolean isDownloadFinished(){
    return this.downloadFinished;

  public void startDownload(){
    downloadVideoFile(this.context, this.videoURL, this.targetFileName);    

  private void downloadVideoFile(Context context, String videoURL, String targetFileName) {
    URL url = null;
    try {
        url = new URL(videoURL);

        // Open a connection to that URL.
        connection = (HttpURLConnection) url.openConnection();


        inputStream = connection.getInputStream();
        fileOutputStream = context.openFileOutput(targetFileName, Context.MODE_PRIVATE);

        byte[] buffer = new byte[3 * 1024];
        int counter = 0;

        // Read bytes (and store them) until there is nothing more to read(-1)
        do {
            int numread = inputStream.read(buffer);
            if (numread <= 0){
            fileOutputStream.write(buffer, 0, numread);
        } while (true);
        downloadFinished = true;

        // Clean up
    } catch (Exception e) {
        Log.d(Constants.ERROR, "ERROR [" + getClass().getName() + "]: Caught exception (" + e + ") when trying to download video: " + e.getMessage());

  public Uri getUriForFile(){
    return getUriForFile(context, targetFileName);

  private Uri getUriForFile(Context context, String fileName){

    File newFile = new File(context.getFilesDir(), fileName);       
    Uri contentUri = FileProvider.getUriForFile(context, FILE_PROVIDER, newFile);

    return contentUri;

  public void cancel(){
    // 1. cancel the connection
    Log.d(Constants.LOG, "DEBUG [" + getClass().getName() + "]: Cancel connection");

    try {

            // Remove the file if it has not been fully downloaded
            FileProvider fileProvider = new FileProvider();
            Uri fileToDeleteUri = getUriForFile();
            fileProvider.delete(fileToDeleteUri, null, null); // returns 1 if the delete succeeds; otherwise, 0.
            Log.d(Constants.LOG, "DEBUG [" + getClass().getName() + "]: Leave the file, it has been completely download");
    catch (Exception e) {
        Log.d(Constants.ERROR, "Exception ( " + e + " ) caught: " +  e.getMessage() + "; ");

private void closeStreams() throws IOException{     
    // Close the streams
    try {           
    } catch (NullPointerException e) {
        Log.d(Constants.ERROR, "Null pointer exception caught: " +  e.getMessage());
    Log.d(Constants.LOG, "DEBUG [" + getClass().getName() + "]: Clean up performed");

Another update: Here is my stack trace:

07-23 17:31:29.114: E/com.organgewise.just4kidstv.LOG(6152): java.lang.NullPointerException
07-23 17:31:29.114: E/com.organgewise.just4kidstv.LOG(6152):    at android.support.v4.content.FileProvider.delete(FileProvider.java:497)
07-23 17:31:29.114: E/com.organgewise.just4kidstv.LOG(6152):    at com.orangewise.just4kidstv.util.VideoDownloader.cancel(VideoDownloader.java:134)
07-23 17:31:29.114: E/com.organgewise.just4kidstv.LOG(6152):    at com.orangewise.just4kidstv.util.VideoDownloadTask.cancel(VideoDownloadTask.java:20)
07-23 17:31:29.114: E/com.organgewise.just4kidstv.LOG(6152):    at com.orangewise.just4kidstv.activities.VideoPlayerActivity.onStop(VideoPlayerActivity.java:64)
07-23 17:31:29.114: E/com.organgewise.just4kidstv.LOG(6152):    at android.app.Instrumentation.callActivityOnStop(Instrumentation.java:1170)
07-23 17:31:29.114: E/com.organgewise.just4kidstv.LOG(6152):    at android.app.Activity.performStop(Activity.java:3873)
07-23 17:31:29.114: E/com.organgewise.just4kidstv.LOG(6152):    at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:2623)
07-23 17:31:29.114: E/com.organgewise.just4kidstv.LOG(6152):    at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:2694)
07-23 17:31:29.114: E/com.organgewise.just4kidstv.LOG(6152):    at android.app.ActivityThread.access$2100(ActivityThread.java:117)
07-23 17:31:29.114: E/com.organgewise.just4kidstv.LOG(6152):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:968)
07-23 17:31:29.114: E/com.organgewise.just4kidstv.LOG(6152):    at android.os.Handler.dispatchMessage(Handler.java:99)
07-23 17:31:29.114: E/com.organgewise.just4kidstv.LOG(6152):    at android.os.Looper.loop(Looper.java:130)
07-23 17:31:29.114: E/com.organgewise.just4kidstv.LOG(6152):    at android.app.ActivityThread.main(ActivityThread.java:3687)
07-23 17:31:29.114: E/com.organgewise.just4kidstv.LOG(6152):    at java.lang.reflect.Method.invokeNative(Native Method)
07-23 17:31:29.114: E/com.organgewise.just4kidstv.LOG(6152):    at java.lang.reflect.Method.invoke(Method.java:507)
07-23 17:31:29.114: E/com.organgewise.just4kidstv.LOG(6152):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
07-23 17:31:29.114: E/com.organgewise.just4kidstv.LOG(6152):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
07-23 17:31:29.114: E/com.organgewise.just4kidstv.LOG(6152):    at dalvik.system.NativeStart.main(Native Method)

So i created an app with an activity and mutiple fragments. In one fragment i tried to add an menu to it, but this menu is shown as a popup menu with 3 dots and not shown as action item to be clicked immediately(like in a normal menu). The menu icon isn´t shown, too.

Here is my code:


    return view;
    public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
        super.onCreateOptionsMenu(menu, inflater);
        inflater.inflate(R.menu.twitter_menu, menu);


<menu xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:id="@+id/menuitem_getBack" 
        android:icon="@drawable/twitter_logo" />

I want the menu to be shown with its icons in the actionbar.

What am i doing wrong ?

Hi Android Spotify developers. Could you please advise which API to use (LibSpotify beta or New Android SDK beta + Web API) to develop application with Spotify functionality for Android?

As I see from API description LibSpotify provides more information than Web API. I could not find search playlists and TopList in Web API (in LibSpotify it is sp_search_create and sp_toplistbrowse_create). This adds pros for using Libspotify.

On the other hand, as per Spotify API Announcements, “LibSpotify beta for Android is being deprecated and will be removed from the Spotify Developer Site”. Does it mean that there is no sense to use Libspotify? When Libspotify will be completely deprecated?

I want to implement App Licensing in my app. As we know, for that we need to install "Google Play Licensing Library" from the Extras Folder of SDK Manager. But, i was unable to import the Library Project and the Sample Project, so i deleted that package thinking that re-installation would fix that.

Now My SDK Manager is not showing me that package.

Is there any way to install it back again?

OR i have to get a new SDK.

Please Help.

I am developing an android application. In this application I create my own private key by passing pass phrase, user id and keys. When creating the private key, it says "Error: org.bouncycastle.openpgp.PGPException: cannot create cipher: CAST5/CFB/NoPadding"

I have checked the logcat as well as the warning section in the Eclipse but there is error there. SO why I am getting this error and how to solve it. Any help is greatly appreciated!

I am using bcpg-jdk15on-150.jar and bcprov-jdk15on-150.jar,

which I have downloaded from http://www.bouncycastle.org/latest_releases.html


the solution of renaming one or both the jar files does not work. When I run the application it says Unable to execute dex: Multiple dex files define Lorg/bouncycastle/apache/bzip2/BZip2Constants; and Conversion to Dalvik format failed: Unable to execute dex: Multiple dex files define Lorg/bouncycastle/apache/bzip2/BZip2Constants; I think there is a problem with the duplication of some files within the two jar files. Can anyone suggest me a solution regarding this?


I am trying to create an application that sends data from my Android phone to Google glass. The data is basically a text message. Right now I am able to pair my Android phone to glass by using the Bluetooth API. Now i need to send a message from my phone to Glass but without opening any application on Glass. Basically the text message should appear as a notification to glass.

I do not intend to use Internet. I plan to send all data only via Bluetooth.

At present, here is what my code looks like ( as far as pairing is concerned)

private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
    public void onReceive(Context context, Intent intent) {
        String action = intent.getAction();
        // When discovery finds a device
        if (BluetoothDevice.ACTION_FOUND.equals(action)) {
            // Get the BluetoothDevice object from the Intent
            BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
            // If it's already paired, skip it, because it's been listed already
            if (device.getBondState() != BluetoothDevice.BOND_BONDED) {
                mNewDevicesArrayAdapter.add(device.getName() + "\n" + device.getAddress());
        // When discovery is finished, change the Activity title
        } else if (BluetoothAdapter.ACTION_DISCOVERY_FINISHED.equals(action)) {
            if (mNewDevicesArrayAdapter.getCount() == 0) {
                String noDevices = getResources().getText(R.string.none_found).toString();

Please suggest few ideas

I`m using echo cancellation in andoid with speex, the JNI code that I wrote is

#include <jni.h>
#include <speex/speex_echo.h> 

#define FRAME_SIZE 256
#define FILTER_LENGTH 800

SpeexEchoState *echoState;

// Initialization of echo cancelation
void Java_telefonie_voip_VoIPActivity_InitEcho(JNIEnv * env, jobject jobj)
    echoState = speex_echo_state_init(FRAME_SIZE, FILTER_LENGTH);

//  Queue the frame to soundcard for playing (receiving)
void Java_telefonie_voip_VoIPActivity_Playback(JNIEnv * env, jobject jobj, jshortArray     inputFrame)
    speex_echo_playback(echoState, inputFrame);

jshortArray Java_telefonie_voip_VoIPActivity_Capture(JNIEnv * env, jobject jobj,     jshortArray inputFrame)
    jshortArray outputFrame;

    speex_echo_capture(echoState, inputFrame, *&outputFrame);

    return outputFrame;

// Destroing echo cancelation
void Java_telefonie_voip_VoIPActivity_DestroyEcho(JNIEnv * env, jobject jobj)

when I use a buffer of 4096 in java with a sampling rate 8000, without using the echo canceller audio is working well (with echo of course) So when I include the echo canceller in make input frame (2048 buffer) in Capture(short) and echo frame in playback, the audio will be destroyed and i only listen to noise!! Is there any one know what buffer to use? or where is the problem and how can I resolve this? thanks