top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

scan BLE (Bluetooth Low Energy) advertisers passively within my Android App

+1 vote
613 views

I want to scan BLE (Bluetooth Low Energy) advertisers passively within my Android App. But I couldn't found how to do this.

I would appreciate if someone could give me some help.

posted Jul 29, 2014 by Abhay

Looking for an answer?  Promote on:
Facebook Share Button Twitter Share Button LinkedIn Share Button

Similar Questions
+1 vote

My app cashes when i click submit, it doesnt verify the fields as it should.
It works the way i want to but if i click on submit without entering anything it crashes.

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        Button addBtn = (Button) findViewById(R.id.addBtn);
        addBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                EditText amoutGiven = (EditText) findViewById(R.id.amountG);
                EditText manyPeople = (EditText) findViewById(R.id.mPeople);
                EditText moenyGiven = (EditText) findViewById(R.id.moneyG);
                TextView changeTxt  = (TextView) findViewById(R.id.changeTxt);
                Button nxtBtn     = (Button) findViewById(R.id.nxtBtn);
                Button tryBtn     = (Button) findViewById(R.id.tryBtn);
                android.view.inputmethod.InputMethodManager imm = (android.view.inputmethod.InputMethodManager)getSystemService(INPUT_METHOD_SERVICE);
                imm.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);

                if (amoutGiven.getText().length()==0){
                    amoutGiven.setError("This field is required");
                }

                if (manyPeople.getText().length()==0){
                    manyPeople.setError("This field is required");
                }

                if (moenyGiven.getText().length()==0){
                    moenyGiven.setError("This field is required");
                }

                int num1 = Integer.parseInt(amoutGiven.getText().toString());
                int num2 = Integer.parseInt(manyPeople.getText().toString());
                int num3 = Integer.parseInt(moenyGiven.getText().toString());
                int total = num1 * num2;
                int change = num3 - total;

                changeTxt.setVisibility((changeTxt.getVisibility() == View.VISIBLE)
                        ? View.INVISIBLE : View.VISIBLE);

                if (change < 0 ){
                    changeTxt.setText("Your numbers dont add up");
                    tryBtn.setVisibility((tryBtn.getVisibility() == View.VISIBLE)
                            ? View.INVISIBLE : View.VISIBLE);
                    tryBtn.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            startActivity(new Intent(MainActivity.this, MainActivity.class));

                        }
                    });

                }else {

                    changeTxt.setText( "Give Back Change oF: R" + change +"" );
                    nxtBtn.setVisibility((nxtBtn.getVisibility() == View.VISIBLE)
                            ? View.INVISIBLE : View.VISIBLE);
                    nxtBtn.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            startActivity(new Intent(MainActivity.this, MainActivity.class));    
                        }
                    });    
                }    
            }
        });    
    }
}
+1 vote

I found that most released apps(including system apps) can be debugged on the emulator by the way following:
1. install the app on the emulator, and launch it
2. run adb shell ps to get the pid of the app
3. run adb jdwp, if you find the pid in the output, then you can attach to the app by running
adb forward tcp:1234 jdwp:$pid_you_find and jdb -connect com.sun.jdi.SocketAttach:hostname=localhost,port=1234
4. you can use commands such as "classes" to see the classes of the app, even "stop" to set breakpoint and "eval" to run many functions and see the members of the objects.
I have 2 questions:
1. Why these tricks fail on the phones? What's the difference between the rom of emulator and phones?
2. How to avoid my app being debugged through such way?

+2 votes

Is there a way to only show the remember networks in wifi scanned results from settings/wifi?

+3 votes

I found a config value in packages/app/Bluetooth/res/values/config.xml and a hide class

  • false
  • android.bluetooth.BluetoothHeadsetClient, this provides HFP client API, such as dial, accept call.

I set profile_supported_hfpclient to true, and remake and flash the system. I write a test app to using BluetoothHeadsetClient API, and it can dial and accept call. However, the voice is not working when calling. The speaker doesn't make sound, and the voice received by mic isn't transferred by Bluetooth SCO.

So does android support HFP client fully? How can I make voice works well

...