Answer the question
In order to leave comments, you need to log in
Why can't I open an application compiled into apk format when importing bluetooth?
Good day. The question is this: Why, when compiling the python code, I don’t see an application on android, but at the same time I found out that if I remove import bluetooth and all its components, it will work? There is one more question, what Do I need to make bluetooth work on android? Here is the code itself:
from kivy.app import App
from kivy.uix.label import Label
from kivy.uix.widget import Widget
from kivy.uix.button import Button
import bluetooth
class Widgets(Widget):
def __init__(self):
super(Widgets, self).__init__()
def btn_clk1(self):
a = self.lbl.text
client=bluetooth.BluetoothSocket( bluetooth.RFCOMM )
ADDR = "00:68:58:00:6F:EA"
client.connect((ADDR,1))
client.send(a)
client.close()
def btn_clk2(self):
server_sock=bluetooth.BluetoothSocket( bluetooth.RFCOMM )
port = 1
server_sock.bind(("",port))
server_sock.listen(1)
client_sock,address = server_sock.accept()
print ("Accepted connection from ",address)
data = client_sock.recv(1024)
self.lbl.text = data
client_sock.close()
server_sock.close()
class SimpleKivy(App):
def build(self):
return Widgets()
SimpleKivy().run()
#File name: kivyn.py
#kivy 1.9.1
<Widgets>:
lbl: my_label
labe: my_labels
Button:
size: 100,75
pos: 0,0
text: "client"
color: 0,1,0,1
font_size: 40
on_press: root.btn_clk1()
Button:
id: 1
size: 170,75
pos: 100,0
text: "server"
color: 1,0,0,1
font_size: 40
on_press: root.btn_clk2()
TextInput:
id: my_label
size: 300,300
pos: 300,0
text: ""
color: 1,0,0,1
font_size: 40
TextInput:
id: my_labels
size: 300,300
pos: 300,300
text: "adr"
color: 1,0,0,1
font_size: 40
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question