0

1つのアクティビティを実行していて、ボタンをクリックすると、次のアクティビティがポップアップ表示されます。簡単なはずですが、ここで何が起こっているのかわかりません。このエラーが発生する理由がわかりません。私は他の人のエラーを調べて修正しようとしましたが、何も機能していません。アクション名を一致させ、Javaで呼び出すと、このエラーが発生します。何が間違っているのかわかりません。

これは私がマニフェストのために得たものです:

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

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

<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>
    <activity android:name=".Recorder" 
        android:theme="@style/AppBaseTheme"
        android:label="@string/app_name" >
        <action android:name="com.jordan.dictation.RECORDER" />
        <category android:name="android.intent.category.DEFAULT" />
    </activity>
</application>

これは、ボタンがクリックされたときに他のアクティビティ「Recorder.java」を呼び出すと想定される最初のアクティビティのJavaコードです。

    public class MainActivity extends Activity {

Button bn_Add;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    bn_Add = (Button) findViewById(R.id.button_nav_add_recording);
    bn_Add.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO start other activity
            try
            {
                // this is the code that I am surrounding in the try/catch block
                Intent openRecorder = new Intent("com.jordan.dictation.RECORDER");
                startActivity(openRecorder);
            }
            catch (Exception e)
            {
                // this is the line of code that sends a real error message to the log
                Log.e("ERROR", "ERROR IN CODE: " + e.toString());

                // this is the line that prints out the location in
                // the code where the error occurred.
                e.printStackTrace();
            }


        }
    });
4

2 に答える 2

1

これを試して

<activity android:name=".Recorder" 
    android:theme="@style/AppBaseTheme"
    android:label="@string/app_name" >
  <intent-filter>
    <action android:name="com.jordan.dication.RECORDER" />
    <category android:name="android.intent.category.DEFAULT" />
  </intent-filter>
</activity>

メインフェスト ファイルでインテント フィルタを使用していない

于 2013-02-14T07:55:09.500 に答える
0

それを試してください:

Intent intent = new Intent(MainActivity.this, Recorder.class);
startActivity(intent);

それ以外の

Intent openRecorder = new Intent("com.jordan.dictation.RECORDER");
startActivity(openRecorder);

確認するために、コードをクリーンアップしてビルドしてください。

于 2013-02-14T08:31:20.487 に答える