Copyright (c) 2013, Leocadio Tin?
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
...
If you think the Android project Dumbledroid listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
package io.leocad.dumbledoreexample.activities;
/*fromwww.java2s.com*/import io.leocad.dumbledoreexample.R;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.support.v4.app.NavUtils;
import android.view.Menu;
import android.view.MenuItem;
publicabstractclass BaseActivity extends Activity {
protectedvoid onConnectionError() {
runOnUiThread( new Runnable() {
@Override
publicvoid run() {
new AlertDialog.Builder(BaseActivity.this)
.setTitle("Error")
.setMessage("Data connection unavailable!")
.setNeutralButton("OK", new DialogInterface.OnClickListener() {
@Override
publicvoid onClick(DialogInterface dialog, int which) {
finish();
}
})
.create()
.show();
}
});
}
@Override
publicboolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu, menu);
return true;
}
@Override
publicboolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
// This ID represents the Home or Up button. In the case of this
// activity, the Up button is shown. Use NavUtils to allow users
// to navigate up one level in the application structure. For
// more details, see the Navigation pattern on Android Design:
//
// http://developer.android.com/design/patterns/navigation.html#up-vs-back
//
NavUtils.navigateUpFromSameTask(this);
return true;
case R.id.menu_about:
startActivity( new Intent(this, AboutActivity.class) );
return true;
}
return super.onOptionsItemSelected(item);
}
}