We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Python code: `import kivy from kivy.lang import Builder from kivy.uix.gridlayout import GridLayout from kivy.properties import NumericProperty from kivy.app import App from kivy.core.window import Window from android import activity from kivy.logger import Logger from jnius import autoclass,cast NfcAdapter = autoclass('android.nfc.NfcAdapter') PythonActivity = autoclass('org.kivy.android.PythonActivity') PendingIntent = autoclass('android.app.PendingIntent') Intent = autoclass('android.content.Intent')
import android
from kivy.clock import Clock from kivy.utils import platform import threading #from nfc_manager import NFCBase from android.runnable import run_on_ui_thread
#kivy.resources.resource_find('./res') from kivy.resources import resource_add_path,resource_find
resource_add_path(os.path.abspath('./res'))
BUILDVERSION = autoclass('android.os.Build$VERSION').SDK_INT NfcAdapter = autoclass('android.nfc.NfcAdapter')
JString = autoclass('java.lang.String') Charset = autoclass('java.nio.charset.Charset') locale = autoclass('java.util.Locale')
IntentFilter = autoclass('android.content.IntentFilter')
Ndef = autoclass('android.nfc.tech.Ndef') NdefRecord = autoclass('android.nfc.NdefRecord') NdefMessage = autoclass('android.nfc.NdefMessage')
app = None
Builder.load_string(''' : cols: 1 Label: id: 'L1' text: 'Welcome to the Hello world' Button: text: 'Click me! %d' % root.counter on_release: root.my_callback() ''')
class HelloWorldScreen(GridLayout): counter = NumericProperty(0) def my_callback(self): print 'The button has been pushed' self.counter += 1
class HelloWorldApp(App):
def build(self): Window.bind(on_keyboard=self._hook_kb) #self.nfc_init() return HelloWorldScreen() def _hook_kb(self,window,key,*args): if key == 27: return True else: return False def on_start(self): self.nfc_init() pass def nfc_init(self): activity.bind(on_new_intent=self.on_new_intent) self.j_context = context = PythonActivity.mActivity self.nfc_adapter = NfcAdapter.getDefaultAdapter(context) if True == self.nfc_adapter.isEnabled(): Logger.info('YY') else: Logger.info('NN') self.nfc_pending_intent = PendingIntent.getActivity(context, 0, Intent(context, context.getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0) Logger.info('nfc init --Tyler') #return True def on_new_intent(self, intent): #print 'on_new_intent()', intent.getAction() # get TAG details Logger.info('nfc action start --Tyler') tag = cast('android.nfc.Tag', intent.getParcelableExtra(NfcAdapter.EXTRA_TAG)) #details = self.get_ndef_details(tag) def on_pause(self): #print 'paused' #self.nfc_adapter.disableForegroundDispatch(PythonActivity.mActivity) return True def on_resume(self): Logger.info('App restart --Tyler') self.nfc_init() #self.nfc_adapter.enableForegroundDispatch(PythonActivity.mActivity, self.nfc_pending_intent, None, None)
if name == 'main': MyApp = HelloWorldApp() #activity.bind(on_new_intent=MyApp.on_new_intent) MyApp.run() `
and p4a file: --requirements pyjnius,python2,kivy,sdl2_mixer,android --package org.nfctest.test --name nfctest --arch armeabi-v7a --whitelist intent-filter.xml --version 0.3 --private . --bootstrap sdl2 --copy-libs --window --debug --activity-launch-mode singleTask --intent-filters /opt/projects/nfctest/intent-filter.xml --permission INTERNET --permission NFC --permission VIBRATE --permission ACCESS_WIFI_STATE --permission CHANGE_WIFI_STATE --permission CHANGE_NETWORK_STATE
--requirements pyjnius,python2,kivy,sdl2_mixer,android --package org.nfctest.test --name nfctest --arch armeabi-v7a --whitelist intent-filter.xml --version 0.3 --private . --bootstrap sdl2 --copy-libs --window --debug --activity-launch-mode singleTask --intent-filters /opt/projects/nfctest/intent-filter.xml --permission INTERNET --permission NFC --permission VIBRATE --permission ACCESS_WIFI_STATE --permission CHANGE_WIFI_STATE --permission CHANGE_NETWORK_STATE
Why I can't get the log "nfc action start --Tyler"
step by step, I write it like this,via this link 'kivy+NFC'
The text was updated successfully, but these errors were encountered:
I tried many times to google,but I can't get the right result what I want. That's so sad for me.
Sorry, something went wrong.
No branches or pull requests
Python code:
`import kivy
from kivy.lang import Builder
from kivy.uix.gridlayout import GridLayout
from kivy.properties import NumericProperty
from kivy.app import App
from kivy.core.window import Window
from android import activity
from kivy.logger import Logger
from jnius import autoclass,cast
NfcAdapter = autoclass('android.nfc.NfcAdapter')
PythonActivity = autoclass('org.kivy.android.PythonActivity')
PendingIntent = autoclass('android.app.PendingIntent')
Intent = autoclass('android.content.Intent')
import android
from kivy.clock import Clock
from kivy.utils import platform
import threading
#from nfc_manager import NFCBase
from android.runnable import run_on_ui_thread
#kivy.resources.resource_find('./res')
from kivy.resources import resource_add_path,resource_find
resource_add_path(os.path.abspath('./res'))
BUILDVERSION = autoclass('android.os.Build$VERSION').SDK_INT
NfcAdapter = autoclass('android.nfc.NfcAdapter')
JString = autoclass('java.lang.String')
Charset = autoclass('java.nio.charset.Charset')
locale = autoclass('java.util.Locale')
IntentFilter = autoclass('android.content.IntentFilter')
Ndef = autoclass('android.nfc.tech.Ndef')
NdefRecord = autoclass('android.nfc.NdefRecord')
NdefMessage = autoclass('android.nfc.NdefMessage')
app = None
Builder.load_string('''
:
cols: 1
Label:
id: 'L1'
text: 'Welcome to the Hello world'
Button:
text: 'Click me! %d' % root.counter
on_release: root.my_callback()
''')
class HelloWorldScreen(GridLayout):
counter = NumericProperty(0)
def my_callback(self):
print 'The button has been pushed'
self.counter += 1
class HelloWorldApp(App):
if name == 'main':
MyApp = HelloWorldApp()
#activity.bind(on_new_intent=MyApp.on_new_intent)
MyApp.run()
`
and p4a file:
--requirements pyjnius,python2,kivy,sdl2_mixer,android --package org.nfctest.test --name nfctest --arch armeabi-v7a --whitelist intent-filter.xml --version 0.3 --private . --bootstrap sdl2 --copy-libs --window --debug --activity-launch-mode singleTask --intent-filters /opt/projects/nfctest/intent-filter.xml --permission INTERNET --permission NFC --permission VIBRATE --permission ACCESS_WIFI_STATE --permission CHANGE_WIFI_STATE --permission CHANGE_NETWORK_STATE
Why I can't get the log "nfc action start --Tyler"
step by step, I write it like this,via this link 'kivy+NFC'
The text was updated successfully, but these errors were encountered: