我遇到问题,当我点击previuos活动上的按钮进入此活动时
public class Bluetooth extends AppCompatActivity{
private ListView listView;
private ArrayList<String> mDeviceList = new ArrayList<String>();
private BluetoothAdapter mBluetoothAdapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.bluetooth);
listView = (ListView) findViewById(R.id.listView);
Button b1 =(Button)findViewById(R.id.button5);
ImageButton ib1=(ImageButton)findViewById(R.id.imageButton);
mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
mBluetoothAdapter.startDiscovery();
IntentFilter filter = new IntentFilter(BluetoothDevice.ACTION_FOUND);
registerReceiver(mReceiver, filter);}
@Override
protected void onDestroy() {
unregisterReceiver(mReceiver);
super.onDestroy();
}
private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (BluetoothDevice.ACTION_FOUND.equals(action)) {
BluetoothDevice device = intent
.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
mDeviceList.add(device.getName() + "\n" + device.getAddress());
listView.setAdapter(new ArrayAdapter<String>(context,
android.R.layout.simple_list_item_1, mDeviceList));
}
}
};
}
应用程序返回上一个活动,为什么? 我已经定义了android清单中的所有活动。
logcat是
02-28 19:01:08.672 8872-8872/? I/art: Late-enabling -Xcheck:jni
02-28 19:01:08.694 8872-8878/? I/art: Debugger is no longer active
02-28 19:01:08.714 8872-8872/? W/System: ClassLoader referenced unknown path: /data/app/com.dl.domo-1/lib/arm64
02-28 19:01:08.725 8872-8872/? I/InstantRun: Instant Run Runtime started. Android package is com.dl.domo, real application class is null.
02-28 19:01:08.802 8872-8872/? W/System: ClassLoader referenced unknown path: /data/app/com.dl.domo-1/lib/arm64
02-28 19:01:08.894 8872-8872/? I/HwCust: Constructor found for class android.app.HwCustHwWallpaperManagerImpl
02-28 19:01:08.937 8872-8872/? W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable
02-28 19:01:09.048 8872-8872/? I/BitmapFactory: set decoder allocator to gralloc
02-28 19:01:09.048 8872-8872/? I/gralloc: Alloc req: dev=0x7f9f9cc140, w=1280, h=871, format=0x1, usage=0x2000003
02-28 19:01:09.051 8872-8872/? I/gralloc: Alloc handle(0x7f9966f100): interfmt=0x1, stride=1280, size=4464640
02-28 19:01:09.060 8872-8872/? I/gralloc: Alloc req: dev=0x7f9f9cc140, w=3840, h=2613, format=0x1, usage=0x2000003
02-28 19:01:09.072 8872-8872/? I/gralloc: Alloc handle(0x7f9966f200): interfmt=0x1, stride=3840, size=40181760
02-28 19:01:09.136 8872-8872/? I/gralloc: Free handle(0x7f9966f200)
02-28 19:01:09.136 8872-8872/? I/gralloc: Free handle(0x7f9966f100)
02-28 19:01:09.150 8872-8872/? I/HwSecImmHelper: mSecurityInputMethodService is null
02-28 19:01:09.191 8872-8897/? I/OpenGLRenderer: Initialized EGL, version 1.4