Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8615001
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T05:15:47+00:00 2026-06-12T05:15:47+00:00

Making my Bluetooth application I need access to some broadcast actions on the Android

  • 0

Making my Bluetooth application I need access to some broadcast actions on the Android side of my code.

All this is run in my Core, so I have a ViewModel that will call through my interface

public interface IConnectionService
{
    //Properties
    string IntentName { get; }

    //Events
    event EventHandler<SearchConnectionItemEventArgs> SearchItemFoundEvent;

    //Methods
    void RunIntent();
    void SearchConnection();
    void Connect(string macAddress);
}

RunIntent prompts the user to turn on Bluetooth (Could be another technology) and I would then like to have an event trigger when Bluetooth state is changed

Android.Bluetooth.BluetoothAdapter.ActionStateChanged

And also when I search for new devices I need

Android.Bluetooth.BluetoothDevice.ActionFound

But I cant put the [Android.Runtime.Register(“ACTION_FOUND”)] and [Android.Runtime.Register(“ACTION_STATE_CHANGED”)] on my class, this only works if I try to put it on my View, but if I do that I need logic in my view?

Is it possible to put it in the core somehow?

My class implementing my interface

using System;
using Android.Bluetooth;
using Android.Content;
using Cirrious.MvvmCross.Android.Platform.Tasks;
using Test.Core.Interfaces;
using Test.Core.Models;

namespace Test.Core.Android
{
    public class AndroidBluetooth : MvxAndroidTask, IConnectionService
    {
    #region Private Fields

    private readonly BluetoothAdapter _bluetoothAdapter;

    #endregion
    #region Public Fields

    #endregion
    #region Properties

    public string IntentName { get { return "Turn on Bluetooth"; }}

    #endregion
    #region Constructor

    public AndroidBluetooth()
    {
        _bluetoothAdapter = BluetoothAdapter.DefaultAdapter;
    }

    #endregion
    #region Events

    public event EventHandler<SearchConnectionItemEventArgs> SearchItemFoundEvent;
    private void ItemFound(SearchConnectionItemEventArgs e)
    {
        if(SearchItemFoundEvent != null)
        {
            SearchItemFoundEvent(this, e);
        }
    }

    #endregion

    #region Methods
    public void RunIntent()
    {
        if (_bluetoothAdapter == null)
        {
            //No bluetooth support on phone
        }
        else if(!_bluetoothAdapter.IsEnabled)
        {
            var intent = new Intent(BluetoothAdapter.ActionRequestEnable);
            StartActivity(intent);
        }
    }

    public void SearchConnection()
    {

        if (_bluetoothAdapter == null)
        {
            //No bluetooth support on phone
        }
        else if (!_bluetoothAdapter.IsEnabled)
        {
            //Bluetooth not turned on
            RunIntent();
        }
        else
        {
            FindBondedDevices();
        }
    }

    private void FindBondedDevices()
    {
        var pairedDevices = _bluetoothAdapter.BondedDevices;

        if (pairedDevices.Count <= 0) return;

        foreach (var item in pairedDevices)
        {
            ItemFound(new SearchConnectionItemEventArgs {Name = item.Name, MacAddress = item.Address});
        }
    }

    private void FindNewDevices()
    {
        if (_bluetoothAdapter == null)
        {

        }
        else if (!_bluetoothAdapter.IsEnabled)
        {

        }
        else
        {
            _bluetoothAdapter.StartDiscovery();
            //Bind event for new devices
        }
    }

    public void Connect(string macAddress)
    {

    }
    #endregion
}
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T05:15:49+00:00Added an answer on June 12, 2026 at 5:15 am

    Disclaimer: I’m not familiar with this part of Android – I’ve never used the Bluetooth stack.

    From your description it sounds like you already know the answer – these Attributes need to go on methods within the Activity/View.

    Of course, once they’ve been added to the Activity/View then it is easy to route these method calls through to the ViewModel – just use the ViewModel property within the View.


    It’s probably easier to try to get this part of your working as a standalone sample first – and then work out how to make it cross-platform and/or mvvm.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently making an Android utility related to Bluetooth, and I need to
May i achieve that server side application (using android bluetooth API)connect to particular client
I am making an android application and i am confused in this section of
Making a simple Java code for Blackjack and need some advice. OK I am
I need to connect my android to a bluetooth device. I use the BluetoothChat
I am new to Android, and I need some advices for start up. I
So I have my Android Bluetooth application that has it's host and clients. The
I´m making an Android App with a Google Map. This app must alert you
i am working on making bluetooth application which makes use of bluetooth api. i
making an infinite loop in javascript, and jQuery... this is my current code: $(#bg2).css({opacity:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.