###前提・実現したいこと
EclipseでNFC読み取り機能を開発しようとしたところ以下のエラーが発生しました。
###発生している問題・エラーメッセージ
activity_mainは解決できないか、フィールドではありません
###該当のソースコード
package
1 2import android.R; 3import android.app.Activity; 4import android.content.Intent; 5import android.nfc.NfcAdapter; 6import android.os.Bundle; 7import android.widget.TextView; 8 9public class MainActivity extends Activity { 10/** Called when the activity is first created. */ 11@Override 12public void onCreate(Bundle savedInstanceState) { 13super.onCreate(savedInstanceState); 14setContentView(R.layout.activity_main); 15 16Intent intent = getIntent(); 17String action = intent.getAction(); 18if(action.equals((NfcAdapter.ACTION_TECH_DISCOVERED))) { 19byte[] rawId = intent.getByteArrayExtra(NfcAdapter.EXTRA_ID); 20String text = bytesToText(rawId); 21TextView nfcIdTextView = (TextView)findViewById(R.id.nfc_id_textview); 22nfcIdTextView.setText(text); 23} 24} 25 26private String bytesToText(byte[] bytes) { 27StringBuilder buffer = new StringBuilder(); 28for (byte b : bytes) { 29String hex = String.format("%02X", b); 30buffer.append(hex).append(" "); 31} 32 33String text = buffer.toString().trim(); 34return text; 35} 36} 37
Manifest
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.nfc_project" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="21" /> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name=".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>
###試したこと
ネットで調べたところ import Android Rを削除するや、コンパイラーのバージョンが1.6であること、
AndroidSDKマネージャでtoolをアップデートするなどしましたが一向にエラーが解決しません。
###補足情報(言語/FW/ツール等のバージョンなど)
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/10/24 05:51
2016/10/24 05:53
2016/10/24 06:06
2016/10/24 06:13
2016/10/24 06:53
2016/10/24 06:57
2016/10/24 07:00
2016/10/24 07:12
2016/10/24 07:19