代码
this.getApplicationContext().getContentResolver().registerContentObserver(
android.provider.Settings.System.CONTENT_URI,
true, new ContentObserver(new Handler()) {
public void onChange(boolean selfChange) {
Toast.makeText(audioServices.this, "Working..", Toast.LENGTH_SHORT).show();
//dispVC();
dialog = new Dialog(audioServices.this);
dialog.setContentView(R.layout.vc);
// set the custom dialog components - text, image and button
Button dialogButton = (Button) dialog.findViewById(R.id.dialogButtonOK);
// if button is clicked, close the custom dialog
dialogButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
dialog.dismiss();
}
});
dialog.show();
//System.out.println("Works!");
}
});
这是logcat。笔记 -01-09 17:54:43.137: E/AndroidRuntime(7210): at com.torcellite.popupvc.audioServices$1.onChange(audioServices.java:59)
第 59 行是dialog.show();
- -编辑 - -
所以,我把代码改成了这个。
Intent dialogIntent = new Intent(audioServices.this, vcDialog.class);
dialogIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
audioServices.this.startActivity(dialogIntent);
我的应用程序仍然崩溃。这是logcat。