Get free daily email updates!

Follow us!

Monday, January 20, 2014

Bluetooth Sample Code For Bluetooth Turn On Or Off In Android - How To Enable Bluetooth

Bluetooth in android is basic level to learn android. In any application you can use Bluetooth for sharing purpose like file sharing, Apps sharing, Audio and video file also. In some of application you have to turn on Bluetooth in between application access process.

At that time you can turn on Bluetooth in a minute by this example.

Useful: How to create and install apk file from your project?

Download Bluetooth Code for android from here:

Create new sample Bluetooth project


1. Create a new project under the File > New > Android Project


2. Open string.xml file under the resource (res) > values folder and past the below code.



    BluetoothSample
    Settings
    Hello world!
    My Message
    GetMessage
    
    Enter Message
    
    TURN_ON
DISCOVERABLE
TURN_OFF
    


3. Open Mail xml file activity_main.xml file under the resource (res) > layout folder and past the below code.



       

    



4. Open Manifest file under your project. Past the Bluetooth permission line to allow Bluetooth in your device.


    
    
    


5. Now open MainActivity.java file and past below code.

package com.example.bluetoothsample;

import android.os.Bundle;
import android.app.Activity;
import android.bluetooth.BluetoothAdapter;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

public class MainActivity extends Activity {

 private static final int Request_Enabled = 0;
 private static final int Request_Discoverable = 0;
 
 
 @Override
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);
 
  
  
  final BluetoothAdapter BTA = BluetoothAdapter.getDefaultAdapter();
//  it through getSystemService(String) with BLUETOOTH_SERVICE
  if(BTA == null)
  {
   final TextView tv1 = (TextView)findViewById(R.id.textView1);
   tv1.append("device not supported");
   
  }
  final Button Btn1 = (Button)findViewById(R.id.button1);
  
  Btn1.setOnClickListener(new View.OnClickListener() {
   
   @Override
   public void onClick(View arg0) {
    
    if(!BTA.isEnabled())
    {
     Intent EnableBintent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
     startActivityForResult(EnableBintent, Request_Enabled);
    }
   }
   
  });
  
  final Button Btn2 = (Button)findViewById(R.id.button2);
  
  Btn2.setOnClickListener(new OnClickListener() {
   
   @Override
   public void onClick(View arg0) {
   
    if(!BTA.isDiscovering())
    {
     Toast.makeText(getApplicationContext(), "Making Your Device Discoverable", Toast.LENGTH_LONG).show();
     
     Intent EnableBintent = new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE);
     startActivityForResult(EnableBintent, Request_Discoverable);
    }
   }
  });
 
  final Button btn3 = (Button)findViewById(R.id.button3);
  
  btn3.setOnClickListener(new OnClickListener() {
   
   @Override
   public void onClick(View arg0) {
    
    BTA.disable();
    
    Toast.makeText(getApplicationContext(), "Bluetooth is closed", Toast.LENGTH_LONG).show();;
    
   }
  });
  
  
  
 }

 @Override
 public boolean onCreateOptionsMenu(Menu menu) {
  // Inflate the menu; this adds items to the action bar if it is present.
  getMenuInflater().inflate(R.menu.main, menu);
  return true;
 }
 
 

}

Note: during this running Bluetooth project in emulator doesn’t work because Bluetooth adepter cant find Bluetooth device. So it’s return null. But you can check in your device directly it must work after install apk file in your mobile.

For more about: Bluetooth adapter return null.

If you have any problem and query then comment in below comment box.

77 comments:

  1. Nice it seems to be good post... It will get readers engagement on the article since readers engagement plays an vital role in every blog.. i am expecting more updated posts from your hands.
    Web Design Company Pune

    ReplyDelete
  2. It Is Really Wonderful Blog You Published. Got Very Much Information. Visit to Know More Click Here

    ReplyDelete
  3. Great guidance to enable turn on or off bluetooth in Android. I feel very great to see a nice blog like yours.

    Anyone interested in developing an Android apps? Approach Way2Smile, Most Trusted Android App Development Company.

    ReplyDelete
  4. An intriguing blog that explains how Android Bluetooth Adaptor ensures mobiles are successfully connected and then files, apps, audio and video files are shared. Good programming information and Thanks for the Blog.

    Best Regrads - VigneshWaran P ( iPhone App Development Company)

    ReplyDelete
  5. Thank you for sharing this blog. This is excellent information. It is amazing and wonderful to visit your site. We also provide android app development in Mohali and Chandigarh at the best rate. visit our site for more information.


    Android app development in Mohali
    Android app development in Chandigarh

    ReplyDelete
  6. This post will be very useful to us. I like your blog and helpful to me. Nice thoughts for your great work.

    Android application Development in Mohali
    Android application Development in Chandigarh

    ReplyDelete
  7. Let's make your #MobileApp the hardest working employee. Contact Copper Mobile we have expertise in making of Mobile Apps.

    We have our office in India and the USA. Visit our website or you can contact directly on 408-753-7403 or email us arvind@CopperMobile.com

    #MobileAppDevelopment #AppDevelopment #MobileApplicationDevelopmentCompany #EnterpriseMobileAppDevelopment

    https://www.coppermobile.com/

    ReplyDelete
  8. This post will be very useful to us. I like your blog and helpful to me. Nice thoughts for your great work.
    Mobile App Development Company Islamabad

    ReplyDelete
  9. Excellent article,We provide many many imformation about Dubrin labs limited is one of the proud members of Bangladesh Association of Software and Information Services (BASIS). We develop enterprise grade software and IT solution or organization all around the globe. We build android, iOS, Cross platform, and web application. Durbin labs limited has a reputation as one of the innovative firm for software development in Bangladesh.
    More info you can vist Android App development
    Thanks for sharing such beautiful information with us

    ReplyDelete
  10. If you are searching for best Mobile Application Development Company In Westerville.. Just visit sudhi infomatics website.

    ReplyDelete
  11. Hey this one is a very nice article and its is going to help the audience a lot and will help them with the knowledge of Android application development online and will also enlighten them with the knowledge of the same. If you want one of the Best Android application development service provider in Greater Noida online then Softgains is the place you should go for

    ReplyDelete
  12. This comment has been removed by the author.

    ReplyDelete
  13. This kind of post is really great to enhance coding skills. Thanks for the post.
    Develop any kind of mobile apps with Lamaid - The king of Mobile Applications Development.

    ReplyDelete
  14. Horeca Life: Tourism, Hospitality, Hotel, Restaurant, Café, Food and Beverage Industry professionals who would like to maximize online tools to generate sales, keep in touch with customers, and send relevant communication regularly.
    Cafe Services
    Cafeteria Management
    Hospitality management
    HORECA
    horeca life
    Catering Industry
    food service industry
    Purchase Manager
    Procurement Manager
    Hospitality Services

    ReplyDelete
  15. Thanks for sharing this information. Please Visit : Mobile App Development Company.

    ReplyDelete
  16. Informative Post...!!! Thanks for Sharing.....

    If you want to make custom website & application you can contact us on our Web Development Company and Mobile App Development Company anytime.

    ReplyDelete
  17. “Pro Software Company” is a leading outsourcing company with a highly talented team. We work with clients around the world. We provide Virtual Assistant Services, Website Development, Digital Marketing, Apps Development, SEO, Data Entry services etc.

    Hire Staff for only £2.99 per hour.

    Visit our Website: https://prosoftwarecompany.com/

    ReplyDelete
  18. This comment has been removed by the author.

    ReplyDelete
  19. This comment has been removed by the author.

    ReplyDelete
  20. Comfortably, the post is really the freshest on that deserving topic. I harmonise with your conclusions and definitely will thirstily look forward to your next updates. Checkout here more info about find api developers

    ReplyDelete
  21. Many thanks. How nice of you to talk with this superb understanding.
    Instagram Reels & IGTV
    Teqhow

    ReplyDelete
  22. Thank you for this valuable post it was very helpful. I really appreciate your effort. please keep us update.
    If you a looking Leading Mobile App Development Company in Dubai. Visit: Mobile App Development Companies

    ReplyDelete
  23. Hello Author thankyou so much
    i hope you are doing well?
    please check our portfolio below.
    Top Mobile App Development Company

    Looking Your Kind Response

    Thanks & Regards
    Arabic Ajath

    ReplyDelete
  24. Bluetooth and WIFI are very important aspects in Mobile technologies and you have explained it well - Mobile app development in Virginia USA

    ReplyDelete
  25. Are you like to read a mobile app development related blog. Appinfusion.co.uk is a leading technology blog platform that provides the latest news, blogs and articles on evolving technologies, the latest marketing trends, effective business strategies, web & mobile app development, digital marketing, and more to help businesses stay relevant in the fast-paced world.

    ReplyDelete
  26. This comment has been removed by the author.

    ReplyDelete
  27. Nice blog to learn about enabling turn on or off mode of Bluetooth in Android.
    If you want one of the Best Mobile application development services then Way2Smile Solutions is the place you should go for.


    ReplyDelete
  28. Easily, the post is actually the freshest on that meriting point. I blend with your decisions and unquestionably will eagerly anticipate your next refreshes

    Mobile App Development Company in Austin

    ReplyDelete
  29. This comment has been removed by the author.

    ReplyDelete
  30. Have an exciting app idea and in a hurry to make it a reality? Reach the best mobile app developers for end-to-end development solutions.Engage more and more clients this year to grow Subscription based food delivery app solution With innovative food app solutions, To fulfill your business needs faster, get in touch with Suffescom

    ReplyDelete
  31. Pathology Lab Management Software (LHMS) is A complete and ultimate Pathology Lab Management and Reporting Software. Fully customizable, easy to use and cost effective program that gives you facility to operate your lab activity from any device anywhere anytime.

    ReplyDelete
  32. PMS ERP Billing And Accounting Software with complete inventory and accounts modules. It's fast, reliable and easy to maintain. Ideal for businesses that have a large number of invoices and deals in 100's of SKU's. Typically used by distributors, retailers and small manufacturers.

    ReplyDelete
  33. Nice blog to learn about enabling turn on or off mode of Bluetooth in Android.
    If you want one of the Best Mobile application development company then reach Way2Smile Solutions is the place you should go for.

    ReplyDelete
  34. It's really a valuable blog post. This blog post briefly about the process of enabling Bluetooth with mobile applications. Thanks for sharing this nice article.

    Looking for a Mobile App Development Company in UK? Reach Way2Smile Solutions UK.

    ReplyDelete
  35. Tecocraft - the best mobile & iOS app development services in the us providers which give a bug-free solution that perfectly fit your business needs at an affordable price.

    ReplyDelete
  36. Thanks for sharing this useful info. In22labs (unwind learning labs) is one of the leading E-governance solutions providers in india. We have worked on 100+ portals using the latest technologies. Know more Government apps development providers

    ReplyDelete
  37. We are a bunch of enthusiastic who wish to create websites for schools, colleges, private organizations, resorts, travels, hospitals, government projects, start-ups and all business categories. The main reason we focus on is to improvise on getting results to our customers at a low cost. Approach us Ecommerce development company in Patna.

    ReplyDelete
  38. Dynode Software is a digital marketing service provider. It specializes in Web Development, Graphic Design, Web Designing(UI/UX), Pay Per Click, Search Engine Optimization, Content Marketing, Social Media Marketing, Digital Consulting, Marketing Strategy, Advertising services. Approach digital marketing in Patna .

    ReplyDelete
  39. This is really awesome but that's why you always crank out my friend. Great posts about real estate auction software that we can sink our teeth into and really go to work.

    Thanks for sharing, as otherwise I would not have thought about trying IT consulting companies in NYC.

    ReplyDelete
  40. Dynode Software is a Web Development service provider. It specializes in Software Development, Blockchain Technology, Mobile App Development, Web Development services. Get best web design and development services in Patna.

    ReplyDelete
  41. Lots of good advice here,let me add here i have learnt about your blog. thanks for mentioning the food delivery app development services.I am just sharing my reviews on Subscription Based Food Delivery app.
    If you are looking for the Smartest Ways to Build an App Like Uber then you can read my article I have mentioned the best smart way. I appreciate the work you have put into this.

    ReplyDelete
  42. Dynode Software is the best Software Development Company in Patna . It specializes in Web Development, Software Development, It Services, CRM Consulting And SI, UX/UI Design, Social Media Marketing, Branding, Web Designing(UI/UX) services. The company has its head office located at Patna and was founded in the year 2004.

    ReplyDelete
  43. PMS ERP is the best Desktop Accounting Software in Patna for small businesses. It has ease of use and nice interface. It is a Windows-based billing, inventory management, and accounting system and it easily installs on a single computer or multiple terminals.

    ReplyDelete
  44. Thanks for this great and useful information. RisingMax is one of the leading IT consulting companies in NYC offering real estate auction software, and information about software development cost breakdown all over the world. Reduce your cost by up to 55-65% by outsourcing your software development with us.

    ReplyDelete
  45. Thanks for sharing this informative article, We can help you get started right away because we have a lot of experience developing food delivery mobile apps for businesses of all sizes. Our skilled Mobile application development company will work with you to match customer preferences with your needs and create a food delivery app that establishes your position in the food delivery industry

    ReplyDelete
  46. Thank you for your post. This is excellent information. It is amazing and wonderful to visit your site. For more infoMobile App Development

    ReplyDelete
  47. Conversational AI Platforms and Contact Centre Solutions

    Technology is taking over every aspect of our day to day living. It is extremely difficult for us to function for one day without our mobile, laptops or tablets. We heavily rely on gadgets to get our work done and help us go through the day. Conversational AI platforms are applications that enhance human interaction with machines. It is increasingly being used by many companies like Google and Apple. They recognise it as an asset for customer satisfaction, productivity and increasing efficiency. People have been increasingly depending on conversational AI platforms like Alexa, Siri and Google Maps.

    Undoubtedly, technology makes our lives easier and efficient. The workflow is smoother and productivity is better with the help of technology. A business is most successful when the customers are happy and it blooms when they come back for more! It is important that businesses provide their customers with a great experience so that they come back wanting more. A business, while selling products, has to keep in mind the customer’s satisfaction with it. It is also equally important that they take care of the customer’s needs after the product is sold. A call centre takes care of the customer’s needs after the product is sold.

    There are a lot of problems that are associated with running a call centre but it is an integral part of running a business. Contact centre solutions are well updated versions and the new normal form of a traditional call centre. It provides a lot of functions that are lacking in a call centre; for example, a contact centre saves all your data in one place so that anyone can access it anytime, from anywhere. It makes data analysation easier and much more efficient. Other than that, a contact centre lets you communicate through various channels rather than just one channel. For instance, you can communicate with your customers through emails and SMS rather than just through calls.

    Integrating conversational AI platforms with contact centre solutions will significantly improve your workflow and efficiency.

    ReplyDelete
  48. Contact Centre Could Solutions – What is it and how can it benefit your business?

    Customer satisfaction and loyalty are critical for running a profitable company in today's cutthroat and competitive marketplace.

    A company Contact Center is the first port of call if consumers wish to connect, whether it's by a phone call, a letter, or a social media tweet. They are at the forefront of consumer service, so it goes without saying that they must be staffed and run with extreme caution.

    Organizations are well aware of the value of operating a successful call centre, and they are now looking to emerging tools to improve customer service. Contact Centre Cloud Solutions – is one of the most common and cost-effective ways to streamline and simplify the operation.

    What exactly is a contact centre cloud solution?

    A contact centre cloud solution system enables a truly novel way of leveraging the newest and most up-to-date technologies to deliver world-class customer experience from the contact centre.

    Cloud-based contact centre systems that enable companies to have exceptional customer services across all channels.

    Customers nowadays often contact businesses through a variety of means; while voice calls are the most prevalent mode of communication, businesses must keep all other channels – email, social media, text, and so on – accessible and staffed in order to offer genuinely comprehensive and distinguished customer support.

    Businesses will buy and combine the most up-to-date call centre software into their current programmes using CCaaS. A Call Centre Software takes advantage of the cloud's capabilities to include a comprehensive solution that incorporates services like automated call delivery, dialer, logger, audio, and omni channel capability, all of which can be scaled up or down on demand.

    What are the advantages of CCaaS for businesses?

    The benefits of choosing a CCaaS kit are too many to overlook, whether your company is launching a new contact centre or updating current contact centre solutions
    via call centre software.

    Costs – The cost savings of using Contact Centre Cloud Solutions was immediately apparent. Businesses no longer need to invest in hardware because Contact Center as a Service is provided through the cloud, eliminating the need for routers, servers, and other related infrastructure. The simple pay-per-use model or a monthly license based service makes it much more appealing because it encourages businesses to select and choose the price that best suits their needs and budget.

    Dynamic scalability is possible thanks to the as-a-service model. Companies will quickly incorporate agents or deal with unexpected workload surges using CCaaS. CCaaS allows for nearly automatic resource scaling up or down to meet the needs of the customer.

    Organizations will provide real-time tracking and accurate information on any aspect of the contact centre by analytics. These insights are crucial for identifying service and efficiency gaps within agents, as well as laying the groundwork for implementing key changes.

    Better Customer Experience – CCaaS technology helps businesses to better support their clients – multi-channel coverage enables more engaged customer outreach, proactive caller profiling enables faster dispute solving, and real-time monitoring of agents and calls will increase the efficiency of the engagement.

    We live in an era of limitless options and hyper-informed buyers. Businesses must have an out-of-this-world consumer experience to attract consumers and ensure brand loyalty.

    Customers today want to be able to communicate with businesses anytime they want, whenever they want, and with continuity in their service response, and the best way to handle this dynamic connectivity situation is to implement cutting-edge technologies.

    ReplyDelete
  49. Side effects of cancer treatment - Uncancer

    There are several side effects cancer treatments and cancer can cause. When treatment affects healthy tissues or organs, side effects are unavoidable. These can be different for each person and for different medicines and kinds of treatment. Long-term side effects are rare in modern chemotherapy. Following are common side effects of cancer treatment:

    Nausea Vomiting

    Nausea and vomiting are very common side effects that can be caused by chemotherapy. They go away slowly during the recovery phase of the chemo cycle or after the end of treatment. Presumably, doctors prescribe medications to manage nausea and vomiting so this can be controlled.

    Fatigue

    Fatigue is another common side effect of chemotherapy. Some people notice that they feel a little more tired than usual during this post-chemo cycle. This fatigue goes away over time after treatment is finished.

    Mental Health

    Chemotherapy can affect mental health as some people may have a mild decline in the ability to think, learn, reason, and remember after chemotherapy. This condition is often called the chemo brain. It can take a few years to return to normal.

    Hair loss

    Chemotherapy can cause serious damage to hair follicles. It causes the hair to weaken, become brittle, and fall out. Even any hair that regrows after that may be of a different texture or color. This condition continues until the cancer treatment ends, after which hair almost always regrows.

    Neuropathy

    A nerve pain caused by damaged nerves is known as neuropathy. It causes tingling, numbness, and an unusual burning sensation to the hands and feet. Some people also experience weakness and pain during daily activities.

    Mouth sores

    After having a chemotherapy cycle, some people develop painful oral sore for 1-2 weeks. The sores may bleed or become infected and the soreness can vary in severity. Some people can try using non-abrasive toothpaste or numbing gel or rinse their mouth with warm saltwater.

    Constipation and diarrhea

    Cancer treatment like chemotherapy can trigger a bowel movement which causes constipation and diarrhea. Some people avoid foods that irritate the stomach. The diet includes fiber supplements and stool softener food which can make digestion smooth.

    These are the commonside effects of cancer treatment. If these side effects get worse then we suggest that you should rush to your doctor immediately.

    ReplyDelete
  50. Eventify is an end-to-end management fully customisable platform for your events. It is easy to use and has been integrated with technology solutions that maximizes the impact of your B2B events and conferences of all sizes. https://eventify.io/

    ReplyDelete
  51. Use Gamification to motivate your attendees to engage in your event. You can Increase your event engagement by creating tasks or challenges within the event management platform and award points for completion. This motivates the attendees to actively take part in the event.
    https://eventify.io/custom-challenges/

    ReplyDelete
  52. Eventify provides tag based networking process that is completely integrated into the event app, connects like-minded in-person and virtual attendees.

    https://eventify.io/build-your-event-app-and-go-live-in-less-than-30-minutes/

    ReplyDelete
  53. An event app brings all the attendees on a single platform. It gives the attendees an opportunity to connect, network, and make strong relations. Also, before the event starts the attendees will be able to look for the other attendees who’ll be attending the event. The attendees will be getting ample time to look through the other attendees – to decide with whom they would like to connect and who can help them grow professionally.

    know more about mobile event app https://eventify.io/planning-a-b2b-event-youll-find-these-digital-tools-useful/

    ReplyDelete
  54. Soar greater heights with Eventify! A fully customizable end-to-end management platform to keep you in the air always. Keep your events at the top. Leave the management on us and enjoy a hassle-free experience. There’s surely a great view from the top!
    https://eventify.io/

    ReplyDelete
  55. Make use of the power of Eventify event management platform for your In-Person, Hybrid and Virtual events to make your event successful.
    https://eventify.io/lead-scanning/

    ReplyDelete
  56. Would like to appreciate your efforts to impart content so beautifully. Its true if you trade in stock market by gettingstock market tips from experts, Chances are higher you will end up in profit. share market tips provided by expert are well timed and well researched.

    ReplyDelete
  57. This comment has been removed by the author.

    ReplyDelete
  58. Bluetooth Sample Code For Bluetooth Turn On Or Off In Android - How To Enable Bluetooth

    Very interesting post...

    Well, we are here to share our blog

    Find Out: How Having a Mobile App is Beneficial for your Business!

    mobile app development company

    ReplyDelete
  59. Nice post thanks for sharing with us..
    If you have any requirement regarding App development like Android and iOS app development , so just click on link
    ecommerce mobile app development company in USA

    ReplyDelete

  60. Dynode Software develops TMS which is a cloud-based logistics management & collaboration platform. Transportation management system helps shippers digitalize their operations and reduce their logistics spend by efficiently managing individual steps of dispatching. Approach us for cloud based transport management system in Patna.

    ReplyDelete
  61. In this regard, Mobile Application Development needs to be according to the interest of the customers. For this, you should have a full-proof quality assurance tester for your mobile apps. It is as necessary as your idea’s validation. That’s why it’s essential to have a comprehensive guide regarding the mobile application.

    ReplyDelete
  62. Build your own online transportation management system with our ready to launch transport marketplace software script at an affordable cost. This is similar to the DST logistic marketplace. Approach us for Transport Management Software.

    ReplyDelete
  63. Find the best-fixed mortgage rate in London that works perfectly for you. We make it easy to compare rates in London big banks and top brokers for free.Best mortgage rate in London

    ReplyDelete
  64. The all-in-one event app management platform that makes your in-person or virtual B2B events & conferences more successful than ever before. Registration & ticketing, event networking, attendee check-in and many more. event app

    ReplyDelete
  65. Check out the main features and USP of our cutting-edge event app builder platform. You can use Eventify to create fully customised mobile event and conference apps. https://eventify.io/event-app/

    ReplyDelete

function foo()
{
}