Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/319.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 使用Android SDK的eclipse中的Android应用程序NFC错误_Java_Android_Eclipse_Sdk_Nfc - Fatal编程技术网

Java 使用Android SDK的eclipse中的Android应用程序NFC错误

Java 使用Android SDK的eclipse中的Android应用程序NFC错误,java,android,eclipse,sdk,nfc,Java,Android,Eclipse,Sdk,Nfc,我正在使用android SDK在eclipse中开发一个android应用程序,我不断地遇到我无法理解的错误(这是我第一个android应用程序),这些错误可能是由于我缺乏编码技能或XML文件中的设置造成的,所以我不想让读者了解所有这些,但接下来, 输出: 12-27 13:01:07.872:E/AndroidRuntime(621):在android.app.ActivityThread.access$600(ActivityThread.java:130) 12-27 13:01:07.

我正在使用android SDK在eclipse中开发一个android应用程序,我不断地遇到我无法理解的错误(这是我第一个android应用程序),这些错误可能是由于我缺乏编码技能或XML文件中的设置造成的,所以我不想让读者了解所有这些,但接下来, 输出:

12-27 13:01:07.872:E/AndroidRuntime(621):在android.app.ActivityThread.access$600(ActivityThread.java:130)
12-27 13:01:07.872:E/AndroidRuntime(621):在android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
12-27 13:01:07.872:E/AndroidRuntime(621):在android.os.Handler.dispatchMessage(Handler.java:99)上
12-27 13:01:07.872:E/AndroidRuntime(621):在android.os.Looper.loop(Looper.java:137)
12-27 13:01:07.872:E/AndroidRuntime(621):在android.app.ActivityThread.main(ActivityThread.java:4745)上
12-27 13:01:07.872:E/AndroidRuntime(621):位于java.lang.reflect.Method.Invokenactive(本机方法)
12-27 13:01:07.872:E/AndroidRuntime(621):位于java.lang.reflect.Method.invoke(Method.java:511)
12-27 13:01:07.872:E/AndroidRuntime(621):在com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
12-27 13:01:07.872:E/AndroidRuntime(621):位于com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
12-27 13:01:07.872:E/AndroidRuntime(621):在dalvik.system.NativeStart.main(本机方法)
12-27 13:01:07.872:E/AndroidRuntime(621):由以下原因引起:android.view.InflateException:二进制XML文件行#8:膨胀类时出错
12-27 13:01:07.872:E/AndroidRuntime(621):在android.view.LayoutInflater.createView(LayoutInflater.java:613)
12-27 13:01:07.872:E/AndroidRuntime(621):在com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
12-27 13:01:07.872:E/AndroidRuntime(621):在android.view.LayoutInflater.onCreateView(LayoutInflater.java:660)
12-27 13:01:07.872:E/AndroidRuntime(621):在android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
12-27 13:01:07.872:E/AndroidRuntime(621):在android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
12-27 13:01:07.872:E/AndroidRuntime(621):在android.view.LayoutInflater.inflate(LayoutInflater.java:489)
12-27 13:01:07.872:E/AndroidRuntime(621):在android.view.LayoutInflater.inflate(LayoutInflater.java:396)
12-27 13:01:07.872:E/AndroidRuntime(621):在android.view.LayoutInflater.inflate(LayoutInflater.java:352)
12-27 13:01:07.872:E/AndroidRuntime(621):位于com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:256)
12-27 13:01:07.872:E/AndroidRuntime(621):位于android.app.Activity.setContentView(Activity.java:1867)
12-27 13:01:07.872:E/AndroidRuntime(621):位于com.chuggle.clink.MainActivity.onCreate(MainActivity.java:31)
12-27 13:01:07.872:E/AndroidRuntime(621):在android.app.Activity.performCreate(Activity.java:5008)
12-27 13:01:07.872:E/AndroidRuntime(621):在android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
12-27 13:01:07.872:E/AndroidRuntime(621):在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
12-27 13:01:07.872:E/AndroidRuntime(621):。。。还有11个
12-27 13:01:07.872:E/AndroidRuntime(621):由以下原因引起:java.lang.reflect.InvocationTargetException
12-27 13:01:07.872:E/AndroidRuntime(621):位于java.lang.reflect.Constructor.constructNative(本机方法)
12-27 13:01:07.872:E/AndroidRuntime(621):位于java.lang.reflect.Constructor.newInstance(Constructor.java:417)
12-27 13:01:07.872:E/AndroidRuntime(621):在android.view.LayoutInflater.createView(LayoutInflater.java:587)
12-27 13:01:07.872:E/AndroidRuntime(621):。。。还有24个
12-27 13:01:07.872:E/AndroidRuntime(621):由以下原因引起:android.content.res.Resources$NotFoundException:资源不是可绘制的(颜色或路径):TypedValue{t=0x1/d=0x7F060000A=-1R=0x7f060000}
12-27 13:01:07.872:E/AndroidRuntime(621):在android.content.res.Resources.loadDrawable(Resources.java:1892)上
12-27 13:01:07.872:E/AndroidRuntime(621):在android.content.res.TypedArray.getDrawable(TypedArray.java:601)
12-27 13:01:07.872:E/AndroidRuntime(621):在android.view.view.(view.java:3336)
12-27 13:01:07.872:E/AndroidRuntime(621):在android.view.ViewGroup。(ViewGroup.java:427)
12-27 13:01:07.872:E/AndroidRuntime(621):在android.widget.LinearLayout.(LinearLayout.java:176)
12-27 13:01:07.872:E/AndroidRuntime(621):在android.widget.LinearLayout.(LinearLayout.java:172)
12-27 13:01:07.872:E/AndroidRuntime(621):。。。还有27个
12-27 13:01:12.192:I/进程(621):发送信号。PID:621信号:9

XML:


爪哇:

package com.chuggle.clink;
导入java.util.Calendar;
导入android.app.Activity;
导入android.app.pendingent;
导入android.content.Intent;
导入android.content.IntentFilter;
导入android.content.IntentFilter.MalformedMimeTypeException;
导入android.nfc.FormatException;
导入android.nfc.NdefMessage;
导入android.nfc.NfcAdapter;
导入android.nfc.tech.NfcF;
导入android.os.Bundle;
导入android.os.Parcelable;
导入android.util.Log;
导入android.view.Menu;
导入android.view.view;
导入android.view.view.OnClickListener;
导入android.widget.Button;
导入android.widget.EditText;
导入android.widget.TextView;
导入android.widget.ToggleButton;
公共类MainActivity扩展了活动{
NfcAdapter NfcAdapter;
私人吊挂品;
私人意向过滤器[]mesfilt;
私有字符串[][]TList;
@凌驾
创建时受保护的void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
最终EditText消息持有者=(EditText)findViewById(R.id.ToSend);
最终按钮TButton=(ToggleButton)findViewById(R.id.SendButton);
nfcAdapter=nfcAdapter
    12-27 13:01:07.872: E/AndroidRuntime(621):  at android.app.ActivityThread.access$600(ActivityThread.java:130)
12-27 13:01:07.872: E/AndroidRuntime(621):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
12-27 13:01:07.872: E/AndroidRuntime(621):  at android.os.Handler.dispatchMessage(Handler.java:99)
12-27 13:01:07.872: E/AndroidRuntime(621):  at android.os.Looper.loop(Looper.java:137)
12-27 13:01:07.872: E/AndroidRuntime(621):  at android.app.ActivityThread.main(ActivityThread.java:4745)
12-27 13:01:07.872: E/AndroidRuntime(621):  at java.lang.reflect.Method.invokeNative(Native Method)
12-27 13:01:07.872: E/AndroidRuntime(621):  at java.lang.reflect.Method.invoke(Method.java:511)
12-27 13:01:07.872: E/AndroidRuntime(621):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
12-27 13:01:07.872: E/AndroidRuntime(621):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
12-27 13:01:07.872: E/AndroidRuntime(621):  at dalvik.system.NativeStart.main(Native Method)
12-27 13:01:07.872: E/AndroidRuntime(621): Caused by: android.view.InflateException: Binary XML file line #8: Error inflating class <unknown>
12-27 13:01:07.872: E/AndroidRuntime(621):  at android.view.LayoutInflater.createView(LayoutInflater.java:613)
12-27 13:01:07.872: E/AndroidRuntime(621):  at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
12-27 13:01:07.872: E/AndroidRuntime(621):  at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660)
12-27 13:01:07.872: E/AndroidRuntime(621):  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
12-27 13:01:07.872: E/AndroidRuntime(621):  at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
12-27 13:01:07.872: E/AndroidRuntime(621):  at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
12-27 13:01:07.872: E/AndroidRuntime(621):  at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
12-27 13:01:07.872: E/AndroidRuntime(621):  at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
12-27 13:01:07.872: E/AndroidRuntime(621):  at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:256)
12-27 13:01:07.872: E/AndroidRuntime(621):  at android.app.Activity.setContentView(Activity.java:1867)
12-27 13:01:07.872: E/AndroidRuntime(621):  at com.chuggle.clink.MainActivity.onCreate(MainActivity.java:31)
12-27 13:01:07.872: E/AndroidRuntime(621):  at android.app.Activity.performCreate(Activity.java:5008)
12-27 13:01:07.872: E/AndroidRuntime(621):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
12-27 13:01:07.872: E/AndroidRuntime(621):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
12-27 13:01:07.872: E/AndroidRuntime(621):  ... 11 more
12-27 13:01:07.872: E/AndroidRuntime(621): Caused by: java.lang.reflect.InvocationTargetException
12-27 13:01:07.872: E/AndroidRuntime(621):  at java.lang.reflect.Constructor.constructNative(Native Method)
12-27 13:01:07.872: E/AndroidRuntime(621):  at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
12-27 13:01:07.872: E/AndroidRuntime(621):  at android.view.LayoutInflater.createView(LayoutInflater.java:587)
12-27 13:01:07.872: E/AndroidRuntime(621):  ... 24 more
12-27 13:01:07.872: E/AndroidRuntime(621): Caused by: android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x1/d=0x7f060000 a=-1 r=0x7f060000}
12-27 13:01:07.872: E/AndroidRuntime(621):  at android.content.res.Resources.loadDrawable(Resources.java:1892)
12-27 13:01:07.872: E/AndroidRuntime(621):  at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
12-27 13:01:07.872: E/AndroidRuntime(621):  at android.view.View.<init>(View.java:3336)
12-27 13:01:07.872: E/AndroidRuntime(621):  at android.view.ViewGroup.<init>(ViewGroup.java:427)
12-27 13:01:07.872: E/AndroidRuntime(621):  at android.widget.LinearLayout.<init>(LinearLayout.java:176)
12-27 13:01:07.872: E/AndroidRuntime(621):  at android.widget.LinearLayout.<init>(LinearLayout.java:172)
12-27 13:01:07.872: E/AndroidRuntime(621):  ... 27 more
12-27 13:01:12.192: I/Process(621): Sending signal. PID: 621 SIG: 9
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.chuggle.clink"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="14"
        android:targetSdkVersion="16" ></uses-sdk>

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" android:permission="android.permission.NFC" android:enabled="true" android:debuggable="true">
        <activity
            android:name="com.chuggle.clink.MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>
package com.chuggle.clink;
import java.util.Calendar;
import android.app.Activity;
import android.app.PendingIntent;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.IntentFilter.MalformedMimeTypeException;
import android.nfc.FormatException;
import android.nfc.NdefMessage;
import android.nfc.NfcAdapter;
import android.nfc.tech.NfcF;
import android.os.Bundle;
import android.os.Parcelable;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.ToggleButton;

public class MainActivity extends Activity {
    NfcAdapter nfcAdapter;
    private PendingIntent pint;
    private IntentFilter[] mesfilt;
    private String[][] TList;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        final EditText messageholder = (EditText) findViewById(R.id.ToSend);
        final Button TButton = (ToggleButton) findViewById(R.id.SendButton);
        nfcAdapter = NfcAdapter.getDefaultAdapter(this);
        if (nfcAdapter == null) return;
        pint = PendingIntent.getActivity(this, 0,
        new Intent(this, getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0);
        IntentFilter ndef = new IntentFilter(NfcAdapter.ACTION_TECH_DISCOVERED);
        try {
            ndef.addDataType("*/*");
        } catch (MalformedMimeTypeException e) {
            throw new RuntimeException("fail", e);
        }
        mesfilt = new IntentFilter[] {
                ndef,
        };
        TList = new String[][] { new String[] { NfcF.class.getName() } };
        if (nfcAdapter == null) return;
        TButton.setOnClickListener( new OnClickListener() {
            @Override
            public void onClick(View arg0) {
                // TODO Auto-generated method stub
                sendMessage(messageholder.getText().toString());
            }
        });
    }
    String resolveIntent(Intent intent) {
        NdefMessage[] msgs = null;
        if(intent.equals(NfcAdapter.ACTION_NDEF_DISCOVERED)){
            Parcelable[] rawMsgs = intent.getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES);
            if(rawMsgs!=null){
                msgs = new NdefMessage[rawMsgs.length];
                for(int i=0;i<rawMsgs.length;i++){
                    msgs[i] = (NdefMessage) rawMsgs[i];
                }
            }
        } 
        else {
        return("Recieving Error");
        }
        return msgs.toString();
    }
    public void sendMessage(String OrToSend){
        Calendar rightNow = Calendar.getInstance();
        OrToSend = OrToSend+" --"+rightNow.getTime().toString();
        byte[] textBytes = OrToSend.getBytes();
        NdefMessage MessageToSend = null;
        try {
            MessageToSend = new NdefMessage(textBytes);
        } catch (FormatException e) {
            e.printStackTrace();
            MessageUpdate("Message Error, Cannot Send");
        }
        nfcAdapter.setNdefPushMessage(MessageToSend, this);

    }
    @Override
    public void onResume() {
        super.onResume();
        nfcAdapter.enableForegroundDispatch(this, pint, mesfilt, TList);
    }

    @Override
    public void onNewIntent(Intent intent) {
        Log.i("Foreground dispatch", "Discovered tag with intent: " + intent);
        Log.i(intent.toString(), resolveIntent(intent));
    }
    @Override
    public void onPause() {
        super.onPause();
        nfcAdapter.disableForegroundDispatch(this);
    }
    public void MessageUpdate(String NewString){
        TextView M1 = (TextView)findViewById(R.id.M1);
        TextView M2 = (TextView)findViewById(R.id.M2);
        TextView M3 = (TextView)findViewById(R.id.M3);
        TextView M4 = (TextView)findViewById(R.id.M4);
        TextView M5 = (TextView)findViewById(R.id.M5);
        TextView M6 = (TextView)findViewById(R.id.M6);
        TextView M7 = (TextView)findViewById(R.id.M7);
        TextView M8 = (TextView)findViewById(R.id.M8);
        TextView M9 = (TextView)findViewById(R.id.M9);
        TextView M10 = (TextView)findViewById(R.id.M10);
        TextView M11 = (TextView)findViewById(R.id.M11);
        TextView M12 = (TextView)findViewById(R.id.M12);
        TextView M13 = (TextView)findViewById(R.id.M13);
        TextView M14 = (TextView)findViewById(R.id.M14);
        TextView M15 = (TextView)findViewById(R.id.M15);
        TextView M16 = (TextView)findViewById(R.id.M16);
        TextView M17 = (TextView)findViewById(R.id.M17);
        TextView M18 = (TextView)findViewById(R.id.M18);
        TextView M19 = (TextView)findViewById(R.id.M19);
        TextView M20 = (TextView)findViewById(R.id.M20);
        TextView M21 = (TextView)findViewById(R.id.M21);
        M21.setText(M20.getText());
        M20.setText(M19.getText());
        M19.setText(M18.getText());
        M18.setText(M17.getText());
        M17.setText(M16.getText());
        M16.setText(M15.getText());
        M15.setText(M14.getText());
        M14.setText(M13.getText());
        M13.setText(M12.getText());
        M12.setText(M11.getText());
        M11.setText(M10.getText());
        M10.setText(M9.getText());
        M9.setText(M8.getText());
        M8.setText(M7.getText());
        M7.setText(M6.getText());
        M6.setText(M5.getText());
        M4.setText(M3.getText());
        M2.setText(M1.getText());
        M1.setText(NewString);
    }
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.activity_main, menu);
        return true;
    }

}
android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x1/d=0x7f060000 a=-1 r=0x7f060000}