1

I realize there are many questions about this subject, butI have searched every single article on stackoverflow and google regarding this issue, and still cannot fix my issue.

So basically I am trying to create an app that utilizes NFC Technology for an individual project while I am studying abroad. My first task right now is to simply get reading and writing to an NFC tag to work. The studying abroad is only relevant because it makes it even more difficult because of the language barrier to get in person help here.

The first activity I tried linking to was TagsActivity. That didn't work so I figured I would create another simple activity to try to link to, that's what ToTag is. Neither worked. Both are in the Manifest file already, that seems to be a fix to many similar issues to mine.

I've been stuck on this same issue for days, and now today it took me over an hour to finally fix the R.java issue, but after fixing that this issue is still here.

I'm just gonna post almost all of the relevant code because I really am stumped as to why it is not working.

MainActivity

package com.example.myapp;


import java.util.ArrayList;
import java.util.List;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Intent;
import android.content.IntentFilter;
import android.nfc.NdefMessage;
import android.nfc.NdefRecord;
import android.nfc.NfcAdapter;
import android.nfc.Tag;
import android.os.Build;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ProgressBar;
import android.widget.Toast;

public class TagsActivity extends Activity {

private Button mEnableWriteButton;
private EditText mTextField;
private NfcAdapter mNfcAdapter;
private ProgressBar mProgressBar;
private boolean isWriteReady = false;

private static final String MIME_TYPE = "application/com.myapp.nfc.tag";

public void processWriteIntent(Intent intent){
    if(isWriteReady &&          NfcAdapter.ACTION_TAG_DISCOVERED.equals(getIntent().getAction())){

        Tag detectedTag = getIntent().getParcelableExtra(NfcAdapter.EXTRA_TAG);

        String tagWriteMessage = mTextField.getText().toString();
        byte[] payload = new String(tagWriteMessage).getBytes();

        if(detectedTag != null && NfcUtils.writeTag(
                NfcUtils.createMessage(MIME_TYPE, payload), detectedTag)) {

            Toast.makeText(this, "Wrote '" + tagWriteMessage + "' to a tag!",
                    Toast.LENGTH_LONG).show();
            setTagWriteReady(false);
        }
        else{
            Toast.makeText(this, "Write failed. Please try again.", Toast.LENGTH_LONG).show();
        }
    }
}

public void processReadIntent(Intent intent){
    List<NdefMessage> intentMessages = NfcUtils.getMessagesFromIntent(intent);
    List<String> payloadStrings = new ArrayList<String>(intentMessages.size());

    for(NdefMessage message : intentMessages){
        for(NdefRecord record : message.getRecords()){
            byte[] payload = record.getPayload();
            String payloadString = new String(payload);

            if(!TextUtils.isEmpty(payloadString)){
                payloadStrings.add(payloadString);
            }
        }
    }

    if(!payloadStrings.isEmpty()){
        Toast.makeText(TagsActivity.this, "Read from tag: " + 
                TextUtils.join(",", payloadStrings), Toast.LENGTH_LONG);
    }
}


/**
 * This method enables this activity to write a tag
 * 
 * @param isWriteReady
 * 
 */
public void setTagWriteReady(boolean isWriteReady){
    this.isWriteReady = isWriteReady;
    if(isWriteReady){
        IntentFilter[] writeTagFilters = new IntentFilter[] {
                new IntentFilter(NfcAdapter.ACTION_TAG_DISCOVERED) };
        mNfcAdapter.enableForegroundDispatch(TagsActivity.this, NfcUtils.getPendingIntent(TagsActivity.this),
                writeTagFilters, null);
    }
    else {
        //Disable dispatch if not writing tags
        mNfcAdapter.disableForegroundDispatch(TagsActivity.this);
    }


}



@Override
public void onNewIntent(Intent intent){
    //onResume gets called after this to handle the intent
    setIntent(intent);
}

@Override 
public void onResume(){
    super.onResume();
    if(isWriteReady && NfcAdapter.ACTION_TAG_DISCOVERED.equals(getIntent().getAction())){
        processWriteIntent(getIntent());
    }
    else if(!isWriteReady &&
            (NfcAdapter.ACTION_TAG_DISCOVERED.equals(
                    getIntent().getAction())
                    || NfcAdapter.ACTION_NDEF_DISCOVERED.equals(
                            getIntent().getAction() ))) {
        processReadIntent(getIntent());
    }

}


@SuppressLint("NewApi")
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_tags);

    /*Intent intent = getIntent();
    String message = intent.getStringExtra(MainActivity.EXTRA_MESSAGE);

    // Create the text view
    TextView textView = new TextView(this);
    textView.setTextSize(40);
    textView.setText(message);

    // Set the text view as the activity layout
    setContentView(textView); */

    //Make sure we're running on Honeycomb or higher to use ActionBar
    if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB){
        //Show the Up button in the action bar
        getActionBar().setDisplayHomeAsUpEnabled(true);
    }

    mTextField = (EditText) findViewById(R.id.progress_bar);

    mProgressBar = (ProgressBar) findViewById(R.id.edit_message);
    mProgressBar.setVisibility(View.GONE);

    mEnableWriteButton = (Button) findViewById(R.id.enable_write_button);
    mEnableWriteButton.setOnClickListener(new OnClickListener(){

        @Override 
        public void onClick(View v) {

            setTagWriteReady(!isWriteReady);
            mProgressBar.setVisibility(isWriteReady ? View.VISIBLE : View.GONE);

        }


    });

    mNfcAdapter = NfcAdapter.getDefaultAdapter(this);
    if(mNfcAdapter == null){
        Toast.makeText(this, "Sorry, NFC not available on this device", Toast.LENGTH_SHORT).show();
    }

}





@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.tags, menu);
    return true;
}

}

TagsActivity

package com.example.myapp;


import java.util.ArrayList;
import java.util.List;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Intent;
import android.content.IntentFilter;
import android.nfc.NdefMessage;
import android.nfc.NdefRecord;
import android.nfc.NfcAdapter;
import android.nfc.Tag;
import android.os.Build;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ProgressBar;
import android.widget.Toast;

public class TagsActivity extends Activity {

private Button mEnableWriteButton;
private EditText mTextField;
private NfcAdapter mNfcAdapter;
private ProgressBar mProgressBar;
private boolean isWriteReady = false;

private static final String MIME_TYPE = "application/com.myapp.nfc.tag";

public void processWriteIntent(Intent intent){
    if(isWriteReady && NfcAdapter.ACTION_TAG_DISCOVERED.equals(getIntent().getAction())){

        Tag detectedTag = getIntent().getParcelableExtra(NfcAdapter.EXTRA_TAG);

        String tagWriteMessage = mTextField.getText().toString();
        byte[] payload = new String(tagWriteMessage).getBytes();

        if(detectedTag != null && NfcUtils.writeTag(
                NfcUtils.createMessage(MIME_TYPE, payload), detectedTag)) {

            Toast.makeText(this, "Wrote '" + tagWriteMessage + "' to a tag!",
                    Toast.LENGTH_LONG).show();
            setTagWriteReady(false);
        }
        else{
            Toast.makeText(this, "Write failed. Please try again.", Toast.LENGTH_LONG).show();
        }
    }
}

public void processReadIntent(Intent intent){
    List<NdefMessage> intentMessages = NfcUtils.getMessagesFromIntent(intent);
    List<String> payloadStrings = new ArrayList<String>(intentMessages.size());

    for(NdefMessage message : intentMessages){
        for(NdefRecord record : message.getRecords()){
            byte[] payload = record.getPayload();
            String payloadString = new String(payload);

            if(!TextUtils.isEmpty(payloadString)){
                payloadStrings.add(payloadString);
            }
        }
    }

    if(!payloadStrings.isEmpty()){
        Toast.makeText(TagsActivity.this, "Read from tag: " + 
                TextUtils.join(",", payloadStrings), Toast.LENGTH_LONG);
    }
}


/**
 * This method enables this activity to write a tag
 * 
 * @param isWriteReady
 * 
 */
public void setTagWriteReady(boolean isWriteReady){
    this.isWriteReady = isWriteReady;
    if(isWriteReady){
        IntentFilter[] writeTagFilters = new IntentFilter[] {
                new IntentFilter(NfcAdapter.ACTION_TAG_DISCOVERED) };
        mNfcAdapter.enableForegroundDispatch(TagsActivity.this, NfcUtils.getPendingIntent(TagsActivity.this),
                writeTagFilters, null);
    }
    else {
        //Disable dispatch if not writing tags
        mNfcAdapter.disableForegroundDispatch(TagsActivity.this);
    }


}



@Override
public void onNewIntent(Intent intent){
    //onResume gets called after this to handle the intent
    setIntent(intent);
}

@Override 
public void onResume(){
    super.onResume();
    if(isWriteReady && NfcAdapter.ACTION_TAG_DISCOVERED.equals(getIntent().getAction())){
        processWriteIntent(getIntent());
    }
    else if(!isWriteReady &&
            (NfcAdapter.ACTION_TAG_DISCOVERED.equals(
                    getIntent().getAction())
                    || NfcAdapter.ACTION_NDEF_DISCOVERED.equals(
                            getIntent().getAction() ))) {
        processReadIntent(getIntent());
    }

}


@SuppressLint("NewApi")
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_tags);

    /*Intent intent = getIntent();
    String message = intent.getStringExtra(MainActivity.EXTRA_MESSAGE);

    // Create the text view
    TextView textView = new TextView(this);
    textView.setTextSize(40);
    textView.setText(message);

    // Set the text view as the activity layout
    setContentView(textView); */

    //Make sure we're running on Honeycomb or higher to use ActionBar
    if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB){
        //Show the Up button in the action bar
        getActionBar().setDisplayHomeAsUpEnabled(true);
    }

    mTextField = (EditText) findViewById(R.id.progress_bar);

    mProgressBar = (ProgressBar) findViewById(R.id.progress_bar);
    mProgressBar.setVisibility(View.GONE);

    mEnableWriteButton = (Button) findViewById(R.id.enable_write_button);
    mEnableWriteButton.setOnClickListener(new OnClickListener(){

        @Override 
        public void onClick(View v) {

            setTagWriteReady(!isWriteReady);
            mProgressBar.setVisibility(isWriteReady ? View.VISIBLE : View.GONE);

        }


    });

    mNfcAdapter = NfcAdapter.getDefaultAdapter(this);
    if(mNfcAdapter == null){
        Toast.makeText(this, "Sorry, NFC not available on this device", Toast.LENGTH_SHORT).show();
    }

}





@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.tags, menu);
    return true;
}




}

ToTag

package com.example.myapp;

import android.app.Activity;
import android.os.Bundle;


public class ToTag extends Activity {

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);   
    setContentView(R.layout.activity_to_tag);

    // TODO Auto-generated method stub
}

}

MyApp Manifest

<?xml version="1.0" encoding="utf-8"?>
<manifest package="com.example.myapp"
android:versionCode="1"
android:versionName="1.0" xmlns:android="http://schemas.android.com/apk/res/android">

<uses-sdk
    android:minSdkVersion="10"
    android:targetSdkVersion="17" />

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name="com.example.myapp.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>
    <activity
        android:name="com.example.myapp.TagsActivity"
        android:label="@string/title_activity_tags"
        android:launchMode="singleTop"
        android:parentActivityName="com.example.myapp.MainActivity" >
        <intent-filter>
            <action android:name="android.nfc.action.NDEF_DISCOVERED" />

            <category android:name="android.intent.category.DEFAULT" />

            <data android:mimeType="application/com.example.myapp" />

            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value="com.example.myapp.MainActivity" />
        </intent-filter>
        <intent-filter>
            <action android:name="android.nfc.action.TAG_DISCOVERED" />

            <category android:name="android.intent.category.DEFAULT" />

            <data android:mimeType="application/com.example.myapp" />
        </intent-filter>


    </activity>
    <activity
        android:name="com.example.myapp.ToTagActivity"
        android:label="@string/title_activity_to_tag"
        android:parentActivityName="com.example.myapp.MainActivity" >
        <meta-data
            android:name="android.support.PARENT_ACTIVITY"
            android:value="com.example.myapp.MainActivity" />
    </activity>
</application>

</manifest>

activity_main.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="top"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >

<Button
    android:id="@+id/enable_write_button"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/edit_message"
    android:layout_centerHorizontal="true"
    android:text="@string/Write" 
    android:onClick="writeToTag"/>

<EditText
    android:id="@+id/edit_message"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="19dp"
    android:ems="10"
    android:hint="" >

    <requestFocus />
</EditText>

<Button
    android:id="@+id/to_tags"
    style="?android:attr/buttonStyleSmall"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/enable_write_button"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="21dp"
    android:text="@string/to_tag" 
    android:onClick="toTag"/>

</RelativeLayout>

activity_tags.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".TagsActivity" >

<Button
    android:id="@+id/enable_write_button"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="81dp"
    android:text="@string/TagWriting" />

<ProgressBar
    android:id="@+id/progress_bar"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/enable_write_button"
    android:layout_centerHorizontal="true" />

<EditText
    android:id="@+id/edit_message"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignBottom="@+id/enable_write_button"
    android:layout_centerHorizontal="true"
    android:layout_marginBottom="49dp"
    android:ems="10"
    android:hint="@string/edit_message" >

    <requestFocus />
</EditText>

</RelativeLayout>

activity_to_tag.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".ToTagActivity" >

<TextView
    android:id="@+id/here"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:layout_marginLeft="80dp"
    android:layout_marginTop="51dp"
    android:text="@string/Got_Here"
    android:textAppearance="?android:attr/textAppearanceLarge" />

</RelativeLayout>

And finally the logcat errors

04-28 21:32:28.240: D/memalloc(20292): /dev/pmem: Mapped buffer base:0x5178b000                         size:2641920 offset:2027520 fd:50
04-28 21:32:28.320: D/memalloc(20292): /dev/pmem: Mapped buffer base:0x51dce000 size:3256320 offset:2641920 fd:53
04-28 21:32:28.770: D/memalloc(20292): /dev/pmem: Mapped buffer base:0x522a8000 size:614400 offset:0 fd:56
04-28 21:32:30.760: W/dalvikvm(20292): threadid=1: thread exiting with uncaught exception (group=0x40db71f8)
04-28 21:32:30.780: E/AndroidRuntime(20292): FATAL EXCEPTION: main
04-28 21:32:30.780: E/AndroidRuntime(20292): java.lang.IllegalStateException: Could not execute method of the activity
04-28 21:32:30.780: E/AndroidRuntime(20292):    at android.view.View$1.onClick(View.java:3057)
04-28 21:32:30.780: E/AndroidRuntime(20292):    at android.view.View.performClick(View.java:3524)
04-28 21:32:30.780: E/AndroidRuntime(20292):    at android.view.View$PerformClick.run(View.java:14194)
04-28 21:32:30.780: E/AndroidRuntime(20292):    at android.os.Handler.handleCallback(Handler.java:605)
04-28 21:32:30.780: E/AndroidRuntime(20292):    at android.os.Handler.dispatchMessage(Handler.java:92)
04-28 21:32:30.780: E/AndroidRuntime(20292):    at android.os.Looper.loop(Looper.java:137)
04-28 21:32:30.780: E/AndroidRuntime(20292):    at android.app.ActivityThread.main(ActivityThread.java:4476)
04-28 21:32:30.780: E/AndroidRuntime(20292):    at java.lang.reflect.Method.invokeNative(Native Method)
04-28 21:32:30.780: E/AndroidRuntime(20292):    at java.lang.reflect.Method.invoke(Method.java:511)
04-28 21:32:30.780: E/AndroidRuntime(20292):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:816)
04-28 21:32:30.780: E/AndroidRuntime(20292):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:583)
04-28 21:32:30.780: E/AndroidRuntime(20292):    at dalvik.system.NativeStart.main(Native Method)
04-28 21:32:30.780: E/AndroidRuntime(20292): Caused by: java.lang.reflect.InvocationTargetException
04-28 21:32:30.780: E/AndroidRuntime(20292):    at java.lang.reflect.Method.invokeNative(Native Method)
04-28 21:32:30.780: E/AndroidRuntime(20292):    at java.lang.reflect.Method.invoke(Method.java:511)
04-28 21:32:30.780: E/AndroidRuntime(20292):    at android.view.View$1.onClick(View.java:3052)
04-28 21:32:30.780: E/AndroidRuntime(20292):    ... 11 more
04-28 21:32:30.780: E/AndroidRuntime(20292): Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class     {com.example.myapp/com.example.myapp.ToTag}; have you declared this activity in your AndroidManifest.xml?
04-28 21:32:30.780: E/AndroidRuntime(20292):    at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1536)
04-28 21:32:30.780: E/AndroidRuntime(20292):    at android.app.Instrumentation.execStartActivity(Instrumentation.java:1390)
04-28 21:32:30.780: E/AndroidRuntime(20292):    at android.app.Activity.startActivityForResult(Activity.java:3361)
04-28 21:32:30.780: E/AndroidRuntime(20292):    at android.app.Activity.startActivity(Activity.java:3468)
04-28 21:32:30.780: E/AndroidRuntime(20292):    at com.example.myapp.MainActivity.toTag(MainActivity.java:33)
04-28 21:32:30.780: E/AndroidRuntime(20292):    ... 14 more
04-28 21:39:53.060: D/memalloc(20645): /dev/pmem: Mapped buffer base:0x5178b000 size:2641920 offset:2027520 fd:50
04-28 21:39:53.150: D/memalloc(20645): /dev/pmem: Mapped buffer base:0x51b30000 size:3256320 offset:2641920 fd:53
04-28 21:39:53.610: D/memalloc(20645): /dev/pmem: Mapped buffer base:0x5205c000 size:614400 offset:0 fd:56
04-28 21:39:54.170: W/dalvikvm(20645): threadid=1: thread exiting with uncaught exception (group=0x40db71f8)
04-28 21:39:54.180: E/AndroidRuntime(20645): FATAL EXCEPTION: main
04-28 21:39:54.180: E/AndroidRuntime(20645): java.lang.IllegalStateException: Could not execute method of the activity
04-28 21:39:54.180: E/AndroidRuntime(20645):    at android.view.View$1.onClick(View.java:3057)
04-28 21:39:54.180: E/AndroidRuntime(20645):    at android.view.View.performClick(View.java:3524)
04-28 21:39:54.180: E/AndroidRuntime(20645):    at android.view.View$PerformClick.run(View.java:14194)
04-28 21:39:54.180: E/AndroidRuntime(20645):    at android.os.Handler.handleCallback(Handler.java:605)
04-28 21:39:54.180: E/AndroidRuntime(20645):    at android.os.Handler.dispatchMessage(Handler.java:92)
04-28 21:39:54.180: E/AndroidRuntime(20645):    at android.os.Looper.loop(Looper.java:137)
04-28 21:39:54.180: E/AndroidRuntime(20645):    at android.app.ActivityThread.main(ActivityThread.java:4476)
04-28 21:39:54.180: E/AndroidRuntime(20645):    at java.lang.reflect.Method.invokeNative(Native Method)
04-28 21:39:54.180: E/AndroidRuntime(20645):    at java.lang.reflect.Method.invoke(Method.java:511)
04-28 21:39:54.180: E/AndroidRuntime(20645):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:816)
04-28 21:39:54.180: E/AndroidRuntime(20645):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:583)
04-28 21:39:54.180: E/AndroidRuntime(20645):    at dalvik.system.NativeStart.main(Native Method)
04-28 21:39:54.180: E/AndroidRuntime(20645): Caused by: java.lang.reflect.InvocationTargetException
04-28 21:39:54.180: E/AndroidRuntime(20645):    at java.lang.reflect.Method.invokeNative(Native Method)
04-28 21:39:54.180: E/AndroidRuntime(20645):    at java.lang.reflect.Method.invoke(Method.java:511)
04-28 21:39:54.180: E/AndroidRuntime(20645):    at android.view.View$1.onClick(View.java:3052)
04-28 21:39:54.180: E/AndroidRuntime(20645):    ... 11 more
04-28 21:39:54.180: E/AndroidRuntime(20645): Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class     {com.example.myapp/com.example.myapp.ToTag}; have you declared this activity in your AndroidManifest.xml?
04-28 21:39:54.180: E/AndroidRuntime(20645):    at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1536)
04-28 21:39:54.180: E/AndroidRuntime(20645):    at android.app.Instrumentation.execStartActivity(Instrumentation.java:1390)
04-28 21:39:54.180: E/AndroidRuntime(20645):    at android.app.Activity.startActivityForResult(Activity.java:3361)
04-28 21:39:54.180: E/AndroidRuntime(20645):    at android.app.Activity.startActivity(Activity.java:3468)
04-28 21:39:54.180: E/AndroidRuntime(20645):    at com.example.myapp.MainActivity.toTag(MainActivity.java:33)
04-28 21:39:54.180: E/AndroidRuntime(20645):    ... 14 more

Sorry for the wall of code, but I'm not going to be able to update if I forgot anything until the morning, so I wanted to include everything relevant. And obviously this is my first post here and I tried to do the research about formatting, but I'm sure I screwed something up so I apologize in advance.

EDIT1: Fixed the Manifest where it had "ToTagActivity" instead of "ToTag". Now I need to figure out some possibly similar error for the transition to TagsActivity.

EDIT2: Fixed error where I accidentally tried to cast progressbar to EditText.

EDIT3: Got it! After some more sifting through the errors and searching around the site, found out I forgot NFC permission in my manifest!

4

2 回答 2

2

您清单使用名称注册了一个活动,com.example.myapp.ToTagActivity但您的类名为com.example.myapp.ToTag。用正确的类名更新你的主文件。

于 2013-04-28T22:15:13.387 回答
2

错误信息

04-28 21:39:54.180: E/AndroidRuntime(20645): Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class     {com.example.myapp/com.example.myapp.ToTag}; have you declared this activity in your AndroidManifest.xml?

所以我们检查 You Manifest,看起来不错

<activity
    android:name="com.example.myapp.ToTagActivity"

public class ToTag extends Activity
于 2013-04-28T22:15:32.177 回答