ExampleApp/src/com/altinn/apps/fisher/ui/screen/BaseActivity.java
/**
	 * Android framework method which will take care of creation of dialogs.
	 */
Android framework method which will take care of creation of dialogs.
Android framework method which will take care of creation of dialogs .
@Override
	protected Dialog onCreateDialog(int id) {
		switch (id) {
		case NO_NETWORK_DIALOG_ID:
			return new AlertDialog.Builder(this)
					.setMessage(R.string.dialog_no_network)
					.setPositiveButton(R.string.dialog_ok,
							new DialogInterface.OnClickListener() {
								public void onClick(DialogInterface dialog,
										int id) {
									dialog.dismiss();
									if(!PreferenceUtils.getInstance().isUserRegistered()){
										finish();
									}
								}
							}).create();
		case SHOW_LOADING:
			ProgressDialog dialog = new ProgressDialog(BaseActivity.this);
			dialog.setMessage(getString(R.string.dialog_progress));
			dialog.setIndeterminate(true);
			dialog.setCancelable(false);
			return dialog;
		case EXIT_APP:
			return new AlertDialog.Builder(this)
					.setMessage((R.string.dialog_exit))
					.setPositiveButton(R.string.dialog_yes,
							new DialogInterface.OnClickListener() {
								public void onClick(DialogInterface dialog,
										int id) {
									dialog.dismiss();
									finish();
									System.exit(0);
								}
							})
					.setNegativeButton(R.string.dialog_no,
							new DialogInterface.OnClickListener() {
								public void onClick(DialogInterface dialog,
										int id) {
									dialog.dismiss();
								}
							}).create();
			case LOGIN_FIALIED:
			return new AlertDialog.Builder(this)
			.setMessage(R.string.dialog_login_failed)
			.setPositiveButton(R.string.dialog_ok,
					new DialogInterface.OnClickListener() {
						public void onClick(DialogInterface dialog,
								int id) {
							dialog.dismiss();
						}
					}).create();
			case LOGIN_EXPIRED:
				return new AlertDialog.Builder(this)
				.setMessage(R.string.dialog_login_expired)
				.setCancelable(true)
				.setPositiveButton(R.string.dialog_ok,
						new DialogInterface.OnClickListener() {
							public void onClick(DialogInterface dialog,
									int id) {
								dialog.dismiss();
								Intent intentWeb = new Intent(BaseActivity.this,BrowserActivity.class);
								startActivityForResult(intentWeb,REQUEST_CODE);
							}
						}).create();
			case UPDATE_GPS_SETTING:
				return new AlertDialog.Builder(this)
				.setMessage(R.string.dialog_gps_setting_disabled)
				.setPositiveButton(R.string.dialog_ok,
						new DialogInterface.OnClickListener() {
							public void onClick(DialogInterface dialog,
									int id) {
								dialog.dismiss();
								Intent settingsIntent = new Intent(
										Settings.ACTION_LOCATION_SOURCE_SETTINGS);
								startActivity(settingsIntent);
							}
						}).create();
			case SHOW_LOADING_USER_PROFILE:
				dialog = new ProgressDialog(BaseActivity.this);
				dialog.setMessage(getString(R.string.dialog_progress_user_profile));
				dialog.setIndeterminate(true);
				dialog.setCancelable(false);
				return dialog;
			case SHOW_REPORT_SENDING:
				dialog = new ProgressDialog(BaseActivity.this);
				dialog.setMessage(getString(R.string.dialog_progress_report_sending));
				dialog.setIndeterminate(true);
				dialog.setCancelable(false);
				return dialog;
		}
		return null;
	}
@ Override protected Dialog onCreateDialog ( int id ) { switch ( id ) { case NO_NETWORK_DIALOG_ID : return new AlertDialog . Builder ( this ) . setMessage ( R . string . dialog_no_network ) . setPositiveButton ( R . string . dialog_ok , new DialogInterface . OnClickListener ( ) { public void onClick ( DialogInterface dialog , int id ) { dialog . dismiss ( ) ; if ( ! PreferenceUtils . getInstance ( ) . isUserRegistered ( ) ) { finish ( ) ; } } } ) . create ( ) ; case SHOW_LOADING : ProgressDialog dialog = new ProgressDialog ( BaseActivity . this ) ; dialog . setMessage ( getString ( R . string . dialog_progress ) ) ; dialog . setIndeterminate ( true ) ; dialog . setCancelable ( false ) ; return dialog ; case EXIT_APP : return new AlertDialog . Builder ( this ) . setMessage ( ( R . string . dialog_exit ) ) . setPositiveButton ( R . string . dialog_yes , new DialogInterface . OnClickListener ( ) { public void onClick ( DialogInterface dialog , int id ) { dialog . dismiss ( ) ; finish ( ) ; System . exit ( 0 ) ; } } ) . setNegativeButton ( R . string . dialog_no , new DialogInterface . OnClickListener ( ) { public void onClick ( DialogInterface dialog , int id ) { dialog . dismiss ( ) ; } } ) . create ( ) ; case LOGIN_FIALIED : return new AlertDialog . Builder ( this ) . setMessage ( R . string . dialog_login_failed ) . setPositiveButton ( R . string . dialog_ok , new DialogInterface . OnClickListener ( ) { public void onClick ( DialogInterface dialog , int id ) { dialog . dismiss ( ) ; } } ) . create ( ) ; case LOGIN_EXPIRED : return new AlertDialog . Builder ( this ) . setMessage ( R . string . dialog_login_expired ) . setCancelable ( true ) . setPositiveButton ( R . string . dialog_ok , new DialogInterface . OnClickListener ( ) { public void onClick ( DialogInterface dialog , int id ) { dialog . dismiss ( ) ; Intent intentWeb = new Intent ( BaseActivity . this , BrowserActivity . class ) ; startActivityForResult ( intentWeb , REQUEST_CODE ) ; } } ) . create ( ) ; case UPDATE_GPS_SETTING : return new AlertDialog . Builder ( this ) . setMessage ( R . string . dialog_gps_setting_disabled ) . setPositiveButton ( R . string . dialog_ok , new DialogInterface . OnClickListener ( ) { public void onClick ( DialogInterface dialog , int id ) { dialog . dismiss ( ) ; Intent settingsIntent = new Intent ( Settings . ACTION_LOCATION_SOURCE_SETTINGS ) ; startActivity ( settingsIntent ) ; } } ) . create ( ) ; case SHOW_LOADING_USER_PROFILE : dialog = new ProgressDialog ( BaseActivity . this ) ; dialog . setMessage ( getString ( R . string . dialog_progress_user_profile ) ) ; dialog . setIndeterminate ( true ) ; dialog . setCancelable ( false ) ; return dialog ; case SHOW_REPORT_SENDING : dialog = new ProgressDialog ( BaseActivity . this ) ; dialog . setMessage ( getString ( R . string . dialog_progress_report_sending ) ) ; dialog . setIndeterminate ( true ) ; dialog . setCancelable ( false ) ; return dialog ; } return null ; }
Android framework method which will take care of creation of dialogs.
Android framework method which will take care of creation of dialogs .
// logout, ONLY if login was successful // if(null != // MyAppContext.getInstance().getAuthId()){ // new // LogoutTask(ctx).execute(MyAppContext.getInstance().getAuthId()); // } // MyAppContext.getInstance().stopDataRefreshTimer(); // Below step is done to exit the app... // End exit.... //								Intent intent = new Intent(Intent.ACTION_VIEW); //								intent.setData(Uri.parse(AppConstants.LOGIN_WEBSERVICE_URL)); //								startActivity(intent); //intentWeb.setData(Uri.parse(AppConstants.LOGIN_WEBSERVICE_URL));