这是我的HelloPlugin.js文件.
var HelloPlugin = {
callNativeFunction: function(success,fail,resultType) {
return cordova.exec(success, fail, "HelloPlugin", "nativeAction", [resultType]);
}
};
Run Code Online (Sandbox Code Playgroud)
我收到以下异常:
: Uncaught ReferenceError: cordova is not defined at file:///android_asset/www/HelloPlugin.js:3
Run Code Online (Sandbox Code Playgroud)
先感谢您.
嗨,我正在开发一个用于读取和写入NFC标签数据的应用程序.我在从NFC标签读取数据时遇到问题.当我尝试读取数据时,我的应用程序第一次崩溃,当我第二次扫描标签时应用程序读取数据.请帮我解决这个问题.这是我的代码.提前致谢.
public class Read extends Activity {
Tag detectedTag;
TextView txtType,txtSize,txtWrite,txtRead;
NfcAdapter nfcAdapter;
IntentFilter[] readTagFilters;
PendingIntent pendingIntent;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(R.layout.read);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.custom_title);
nfcAdapter = NfcAdapter.getDefaultAdapter();
detectedTag =getIntent().getParcelableExtra(NfcAdapter.EXTRA_TAG);
txtType = (TextView) findViewById(R.id.txtType);
txtSize = (TextView) findViewById(R.id.txtsize);
txtWrite = (TextView) findViewById(R.id.txtwrite);
txtRead = (TextView) findViewById(R.id.txt_read);
pendingIntent = PendingIntent.getActivity(getApplicationContext(), 0,
new Intent(this,getClass()).
addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0);
IntentFilter tagDetected = new IntentFilter(NfcAdapter.ACTION_TAG_DISCOVERED);
IntentFilter filter2 = new IntentFilter(NfcAdapter.ACTION_NDEF_DISCOVERED);
readTagFilters = new IntentFilter[]{tagDetected,filter2};
}
protected void onNewIntent(Intent intent) {
if(getIntent().getAction().equals(NfcAdapter.ACTION_TAG_DISCOVERED)){
detectedTag = …Run Code Online (Sandbox Code Playgroud)