0

デバイスでアプリケーションをテストしようとしましたが、エラーが表示され続けます

残念ながら、私のアプリは閉じなければなりませんでした

検索を行ったところ、Stackoverflow でこの回答が見つかりました。関連する手順に従い、ソース ルックアップ パスを編集したところ、次のようになりました。

ここに画像の説明を入力

ただし、私のプログラムはまだ終了する必要があると言っています。他に何かしなければならないことはありますか?

09-05 15:31:56.695: D/OpenGLRenderer(3941): Enabling debug mode 0
09-05 15:39:30.157: E/InputEventReceiver(3941): Exception dispatching input event.
09-05 15:39:30.157: E/MessageQueue-JNI(3941): Exception in MessageQueue callback: handleReceiveCallback
09-05 15:39:30.217: E/MessageQueue-JNI(3941): android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.bletest/com.example.bletest.DeviceScanActivity}; have you declared this activity in your AndroidManifest.xml?
09-05 15:39:30.217: E/MessageQueue-JNI(3941):   at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1628)
09-05 15:39:30.217: E/MessageQueue-JNI(3941):   at android.app.Instrumentation.execStartActivity(Instrumentation.java:1424)
09-05 15:39:30.217: E/MessageQueue-JNI(3941):   at android.app.Activity.startActivityForResult(Activity.java:3390)
09-05 15:39:30.217: E/MessageQueue-JNI(3941):   at android.app.Activity.startActivityForResult(Activity.java:3351)
09-05 15:39:30.217: E/MessageQueue-JNI(3941):   at android.app.Activity.startActivity(Activity.java:3587)
09-05 15:39:30.217: E/MessageQueue-JNI(3941):   at android.app.Activity.startActivity(Activity.java:3555)
09-05 15:39:30.217: E/MessageQueue-JNI(3941):   at com.example.bletest.MainActivity$1.onTouch(MainActivity.java:43)
09-05 15:39:30.217: E/MessageQueue-JNI(3941):   at android.view.View.dispatchTouchEvent(View.java:7379)
09-05 15:39:30.217: E/MessageQueue-JNI(3941):   at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2211)
09-05 15:39:30.217: E/MessageQueue-JNI(3941):   at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1954)
09-05 15:39:30.217: E/MessageQueue-JNI(3941):   at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2211)
09-05 15:39:30.217: E/MessageQueue-JNI(3941):   at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1954)
09-05 15:39:30.217: E/MessageQueue-JNI(3941):   at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2211)
09-05 15:39:30.217: E/MessageQueue-JNI(3941):   at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1954)
09-05 15:39:30.217: E/MessageQueue-JNI(3941):   at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2211)
09-05 15:39:30.217: E/MessageQueue-JNI(3941):   at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1954)
09-05 15:39:30.217: E/MessageQueue-JNI(3941):   at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1966)
09-05 15:39:30.217: E/MessageQueue-JNI(3941):   at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1418)
09-05 15:39:30.217: E/MessageQueue-JNI(3941):   at android.app.Activity.dispatchTouchEvent(Activity.java:2424)
09-05 15:39:30.217: E/MessageQueue-JNI(3941):   at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1914)
09-05 15:39:30.217: E/MessageQueue-JNI(3941):   at android.view.View.dispatchPointerEvent(View.java:7564)
09-05 15:39:30.217: E/MessageQueue-JNI(3941):   at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:3883)
09-05 15:39:30.217: E/MessageQueue-JNI(3941):   at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:3778)
09-05 15:39:30.217: E/MessageQueue-JNI(3941):   at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3379)
09-05 15:39:30.217: E/MessageQueue-JNI(3941):   at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3429)
09-05 15:39:30.217: E/MessageQueue-JNI(3941):   at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3398)
09-05 15:39:30.217: E/MessageQueue-JNI(3941):   at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3483)
09-05 15:39:30.217: E/MessageQueue-JNI(3941):   at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3406)
09-05 15:39:30.217: E/MessageQueue-JNI(3941):   at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:3540)
09-05 15:39:30.217: E/MessageQueue-JNI(3941):   at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3379)
09-05 15:39:30.217: E/MessageQueue-JNI(3941):   at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3429)
09-05 15:39:30.217: E/MessageQueue-JNI(3941):   at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3398)
09-05 15:39:30.217: E/MessageQueue-JNI(3941):   at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3406)
09-05 15:39:30.217: E/MessageQueue-JNI(3941):   at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3379)
09-05 15:39:30.217: E/MessageQueue-JNI(3941):   at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:5419)
09-05 15:39:30.217: E/MessageQueue-JNI(3941):   at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:5399)
09-05 15:39:30.217: E/MessageQueue-JNI(3941):   at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:5370)
09-05 15:39:30.217: E/MessageQueue-JNI(3941):   at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:5493)
09-05 15:39:30.217: E/MessageQueue-JNI(3941):   at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:182)
09-05 15:39:30.217: E/MessageQueue-JNI(3941):   at android.os.MessageQueue.nativePollOnce(Native Method)
09-05 15:39:30.217: E/MessageQueue-JNI(3941):   at android.os.MessageQueue.next(MessageQueue.java:132)
09-05 15:39:30.217: E/MessageQueue-JNI(3941):   at android.os.Looper.loop(Looper.java:124)
09-05 15:39:30.217: E/MessageQueue-JNI(3941):   at android.app.ActivityThread.main(ActivityThread.java:5103)
09-05 15:39:30.217: E/MessageQueue-JNI(3941):   at java.lang.reflect.Method.invokeNative(Native Method)
09-05 15:39:30.217: E/MessageQueue-JNI(3941):   at java.lang.reflect.Method.invoke(Method.java:525)
09-05 15:39:30.217: E/MessageQueue-JNI(3941):   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
09-05 15:39:30.217: E/MessageQueue-JNI(3941):   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
09-05 15:39:30.217: E/MessageQueue-JNI(3941):   at dalvik.system.NativeStart.main(Native Method)
09-05 15:42:49.682: D/AndroidRuntime(3941): Shutting down VM
09-05 15:42:49.682: W/dalvikvm(3941): threadid=1: thread exiting with uncaught exception (group=0x41573700)
09-05 15:42:49.752: E/AndroidRuntime(3941): FATAL EXCEPTION: main
09-05 15:42:49.752: E/AndroidRuntime(3941): android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.bletest/com.example.bletest.DeviceScanActivity}; have you declared this activity in your AndroidManifest.xml?
09-05 15:42:49.752: E/AndroidRuntime(3941):     at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1628)
09-05 15:42:49.752: E/AndroidRuntime(3941):     at android.app.Instrumentation.execStartActivity(Instrumentation.java:1424)
09-05 15:42:49.752: E/AndroidRuntime(3941):     at android.app.Activity.startActivityForResult(Activity.java:3390)
09-05 15:42:49.752: E/AndroidRuntime(3941):     at android.app.Activity.startActivityForResult(Activity.java:3351)
09-05 15:42:49.752: E/AndroidRuntime(3941):     at android.app.Activity.startActivity(Activity.java:3587)
09-05 15:42:49.752: E/AndroidRuntime(3941):     at android.app.Activity.startActivity(Activity.java:3555)
09-05 15:42:49.752: E/AndroidRuntime(3941):     at com.example.bletest.MainActivity$1.onTouch(MainActivity.java:43)
09-05 15:42:49.752: E/AndroidRuntime(3941):     at android.view.View.dispatchTouchEvent(View.java:7379)
09-05 15:42:49.752: E/AndroidRuntime(3941):     at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2211)
09-05 15:42:49.752: E/AndroidRuntime(3941):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1954)
09-05 15:42:49.752: E/AndroidRuntime(3941):     at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2211)
09-05 15:42:49.752: E/AndroidRuntime(3941):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1954)
09-05 15:42:49.752: E/AndroidRuntime(3941):     at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2211)
09-05 15:42:49.752: E/AndroidRuntime(3941):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1954)
09-05 15:42:49.752: E/AndroidRuntime(3941):     at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2211)
09-05 15:42:49.752: E/AndroidRuntime(3941):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1954)
09-05 15:42:49.752: E/AndroidRuntime(3941):     at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1966)
09-05 15:42:49.752: E/AndroidRuntime(3941):     at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1418)
09-05 15:42:49.752: E/AndroidRuntime(3941):     at android.app.Activity.dispatchTouchEvent(Activity.java:2424)
09-05 15:42:49.752: E/AndroidRuntime(3941):     at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1914)
09-05 15:42:49.752: E/AndroidRuntime(3941):     at android.view.View.dispatchPointerEvent(View.java:7564)
09-05 15:42:49.752: E/AndroidRuntime(3941):     at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:3883)
09-05 15:42:49.752: E/AndroidRuntime(3941):     at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:3778)
09-05 15:42:49.752: E/AndroidRuntime(3941):     at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3379)
09-05 15:42:49.752: E/AndroidRuntime(3941):     at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3429)
09-05 15:42:49.752: E/AndroidRuntime(3941):     at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3398)
09-05 15:42:49.752: E/AndroidRuntime(3941):     at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3483)
09-05 15:42:49.752: E/AndroidRuntime(3941):     at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3406)
09-05 15:42:49.752: E/AndroidRuntime(3941):     at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:3540)
09-05 15:42:49.752: E/AndroidRuntime(3941):     at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3379)
09-05 15:42:49.752: E/AndroidRuntime(3941):     at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3429)
09-05 15:42:49.752: E/AndroidRuntime(3941):     at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3398)
09-05 15:42:49.752: E/AndroidRuntime(3941):     at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3406)
09-05 15:42:49.752: E/AndroidRuntime(3941):     at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3379)
09-05 15:42:49.752: E/AndroidRuntime(3941):     at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:5419)
09-05 15:42:49.752: E/AndroidRuntime(3941):     at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:5399)
09-05 15:42:49.752: E/AndroidRuntime(3941):     at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:5370)
09-05 15:42:49.752: E/AndroidRuntime(3941):     at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:5493)
09-05 15:42:49.752: E/AndroidRuntime(3941):     at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:182)
09-05 15:42:49.752: E/AndroidRuntime(3941):     at android.os.MessageQueue.nativePollOnce(Native Method)
09-05 15:42:49.752: E/AndroidRuntime(3941):     at android.os.MessageQueue.next(MessageQueue.java:132)
09-05 15:42:49.752: E/AndroidRuntime(3941):     at android.os.Looper.loop(Looper.java:124)
09-05 15:42:49.752: E/AndroidRuntime(3941):     at android.app.ActivityThread.main(ActivityThread.java:5103)
09-05 15:42:49.752: E/AndroidRuntime(3941):     at java.lang.reflect.Method.invokeNative(Native Method)
09-05 15:42:49.752: E/AndroidRuntime(3941):     at java.lang.reflect.Method.invoke(Method.java:525)
09-05 15:42:49.752: E/AndroidRuntime(3941):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
09-05 15:42:49.752: E/AndroidRuntime(3941):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
09-05 15:42:49.752: E/AndroidRuntime(3941):     at dalvik.system.NativeStart.main(Native Method)
09-05 15:43:21.983: I/System.out(4215): Sending WAIT chunk
09-05 15:43:21.983: W/ActivityThread(4215): Application com.example.bletest is waiting for the debugger on port 8100...
09-05 15:43:21.993: I/dalvikvm(4215): Debugger is active
09-05 15:43:22.183: I/System.out(4215): Debugger has connected
09-05 15:43:22.183: I/System.out(4215): waiting for debugger to settle...
09-05 15:43:22.384: I/System.out(4215): waiting for debugger to settle...
09-05 15:43:22.584: I/System.out(4215): waiting for debugger to settle...
09-05 15:43:22.784: I/System.out(4215): waiting for debugger to settle...
09-05 15:43:22.994: I/System.out(4215): waiting for debugger to settle...
09-05 15:43:23.194: I/System.out(4215): waiting for debugger to settle...
09-05 15:43:23.395: I/System.out(4215): waiting for debugger to settle...
09-05 15:43:23.595: I/System.out(4215): debugger has settled (1477)
09-05 15:43:24.946: D/dalvikvm(4215): threadid=1: still suspended after undo (sc=1 dc=1)
09-05 15:44:00.411: D/libEGL(4215): loaded /system/lib/egl/libEGL_adreno200.so
09-05 15:44:00.411: D/libEGL(4215): loaded /system/lib/egl/libGLESv1_CM_adreno200.so
09-05 15:44:00.421: D/libEGL(4215): loaded /system/lib/egl/libGLESv2_adreno200.so
09-05 15:44:00.431: I/Adreno200-EGL(4215): <qeglDrvAPI_eglInitialize:265>: EGL 1.4 QUALCOMM Build: Iabe52cfaeae4c5fab1acacfe6f056ba15fa93274
09-05 15:44:00.461: D/OpenGLRenderer(4215): Enabling debug mode 0

`

マニフェスト xml

<?xml version="1.0" encoding="utf-8"?>

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >

    <activity android:name="com.example.example.DeviceScanActivity" />
    <activity
        android:name="com.example.bletest.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>

MainActivity.java

package com.example.bletest;

android.app.Activity をインポートします。android.content.Intent をインポートします。android.os.Bundle をインポートします。android.view.Menu をインポートします。android.view.MotionEvent をインポートします。android.view.View をインポートします。android.view.View.OnTouchListener をインポートします。android.widget.Button をインポートします。

public class MainActivity extends Activity { Button aButton;

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

    addListeners();



}

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

private void addListeners() {
      Button btnCallMethod = (Button) this.findViewById(R.id.btnCallMethod);

      // CALL METHOD BUTTON
      btnCallMethod.setOnTouchListener(new OnTouchListener() {

         @Override
         public boolean onTouch(View v, MotionEvent event) {
         if (event.getAction() == MotionEvent.ACTION_UP) {
           Intent intent = new Intent(getApplicationContext(), DeviceScanActivity.class);
           startActivity(intent); // start the DeciveScanActivity

         }
         return false;
       }
     });
    }

}

DeviceScanAcitivity.java 私が実装しようとしているクラスとコード:

package com.example.bletest;

android.annotation.TargetApi をインポートします。android.app.ListActivity をインポートします。android.bluetooth.BluetoothAdapter をインポートします。android.bluetooth.BluetoothDevice をインポートします。android.bluetooth.BluetoothManager をインポートします。android.content.Context をインポートします。android.os.Bundle をインポートします。android.os.Handler をインポートします。android.widget.ArrayAdapter をインポートします。

@TargetApi(18) public class DeviceScanActivity extends ListActivity {

private Handler mHandler;

// Stops scanning after 10 seconds.
private static final long SCAN_PERIOD = 10000;

private ArrayAdapter<Object> list;
protected void OnCreate(Bundle savedInstanceState){
    super.onCreate(savedInstanceState);


    Bundle b = getIntent().getExtras();
    int key = b.getInt("yourKey");

    switch(key)
    {
       case 1: // call method here

        list = new ArrayAdapter<Object>(getApplicationContext(), 
                android.R.layout.simple_list_item_1);
        setListAdapter(list);
        scanLeDevice(true);
    }

}

@TargetApi(18)
public void scanLeDevice(final boolean enable) {
    list.add("Scanning...");
    final BluetoothAdapter adapter = getBluetoothAdapter();
    if (enable) {
        // Stops scanning after a pre-defined scan period.
        mHandler.postDelayed(new Runnable() {
            @Override
            public void run() {
                // mBluetoothAdapter.stopLeScan(mLeScanCallback);
                adapter.stopLeScan(callback);
                list.clear();
            }
        }, SCAN_PERIOD);

        adapter.startLeScan(callback);
    } else {
        adapter.stopLeScan(callback);
    }

}
@TargetApi(18)
private BluetoothAdapter getBluetoothAdapter()
{
    BluetoothManager manager = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE);
    return manager.getAdapter();
}
private final BluetoothAdapter.LeScanCallback callback = new BluetoothAdapter.LeScanCallback() 
{

    @Override
    public void onLeScan(final BluetoothDevice device, int rssi, byte[] scanRecord) {
        // TODO Auto-generated method stub

        {
            list.add("found: " + device);
            runOnUiThread(new Runnable(){
                @Override
                public void run()
                {
                    list.add(device);
                    list.notifyDataSetChanged();
                }
            });
    }
}
};

}

4

1 に答える 1

0

マニフェストの行の下を変更

<activity android:name="com.example.example.DeviceScanActivity" />

これとともに

<activity android:name="com.example.bletest.DeviceScanActivity" />

そしてそれは魅力のように機能します:)

PS:- エラーは名前のアクティビティ パス/場所にあります。

于 2013-09-05T14:55:13.290 に答える