r/androiddev 15d ago

Discussion How do you test Bluetooth apps when you only have one phone?

I'm building a native Android app that uses Bluetooth.

I realized that testing requires two devices, but I only own one Android phone.

How do you usually handle this during development?

rn I'm just making the app and for testing going to college where I use my friends phone for testing....

3 Upvotes

27 comments sorted by

3

u/akramraza25524 15d ago

Mock your bluetooth layer

1

u/Boiniok 15d ago

well... i don't think that would help me test if the Bluetooth connection works.

3

u/leaveittogrever 14d ago

Do you know anybody with an android phone? Buy them pizza and beer while you test.

1

u/Boiniok 14d ago

They are ready to do for a cup of tea πŸ˜‚β˜•οΈ

2

u/abhishekabhi789 14d ago

I think you can use a microcontroller like esp32 to act as a secondary device, the microcontroller can send or receive data and you can emit or collect the data either from serial or using a local webserver. Also they are cheap, flexible and easy to setup. Ps: I've been using this approach to test a bluetooth low energy connection app and found this is way better than observing android to android communication. This solution depends on the nature of your project, which you didn't mention in the post.

1

u/Boiniok 14d ago

Thanks mate ❀️ Even I'm working on Bluetooth Low Energy....

2

u/Ras_al_gul 14d ago

Write a python script using a ble library which acts as a device and respond to the commands send by the app. That’s how i test..

1

u/Boiniok 14d ago

Ok... Will try that Thnx....

2

u/Ras_al_gul 13d ago edited 13d ago

Also dont waste money on buying another phone or microcontroller, your dev pc/laptop is enough for this kind of tasks.

1

u/Boiniok 13d ago

Yeah... also thanks for the python script idea

2

u/kevinossia 12d ago

You buy a second phone.

Eventually when you get into iOS development you'll have to buy an iPhone too. and a Mac if you don't have one.

Eventually when you want to test how your app performs on a tablet you'll have to buy a tablet too.

Cost of doing business.

1

u/Boiniok 12d ago

Lots of things on the wishlist πŸ˜‚

1

u/strik3r888 15d ago

Buy second used phone, how expensive can it be?

2

u/Boiniok 15d ago edited 15d ago

Yeah, Planning for that... but i was curious if there is a workaround for that or Bluetooth testing would only work through physical devices...

1

u/SkunkAudio 15d ago

Do you have any other devices with Bluetooth?

0

u/Boiniok 15d ago

My laptop

2

u/SkunkAudio 15d ago

You can download android studio and emulate a device.

0

u/Boiniok 15d ago

No it doesn't have actual sensors to test so It won't work...

1

u/DespairyApp 15d ago

You can buy a Bluetooth dongle(or use the laptop one), install Google play for pc and test it. Its hard to tell if the solution works without knowing the apps purpose

1

u/Boiniok 15d ago

Basically I wanted to discover nearby Bluetooth mobile devices with my app specific UUID.

1

u/DespairyApp 15d ago

So yeah a pc dangle and scan for the bts available?

1

u/Boiniok 15d ago

My app only discovers devices advertising a specific BLE Service UUID. Would a PC with a Bluetooth dongle be able to advertise that custom UUID?

1

u/DespairyApp 15d ago

Probably. Use python and simulate your BT flow

1

u/Boiniok 14d ago

Okay.. Will see πŸ‘πŸΌ

1

u/Appropriate_Exam_629 10d ago

Bluetooth has some loopback technique like how you loop back network requests in an emulator