# Legal information
## Weather Information
**Weather Information** is licensed under the Apache License, Version 2.0. The full text
of the license can be found in:
- LICENSE
This license applies...
If you think the Android project AndroidWeatherInformation 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
/**
* Copyright 2014 Gustavo Martin Morcuende
*//www.java2s.com
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/package name.gumartinm.weather.information.fragment;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.v4.app.DialogFragment;
import name.gumartinm.weather.information.R;
publicclass APIKeyNoticeDialogFragment extends DialogFragment {
publicstatic APIKeyNoticeDialogFragment newInstance(finalint title) {
final APIKeyNoticeDialogFragment frag = new APIKeyNoticeDialogFragment();
final Bundle args = new Bundle();
args.putInt("title", title);
frag.setArguments(args);
return frag;
}
@Override
public Dialog onCreateDialog(final Bundle savedInstanceState) {
finalint title = this.getArguments().getInt("title");
returnnew AlertDialog.Builder(this.getActivity())
.setIcon(android.R.drawable.ic_dialog_alert)
.setTitle(title)
.setMessage(this.getString(R.string.api_id_key_notice_message))
.setNegativeButton(this.getString(R.string.api_id_key_notice_cancel_button), null)
.setPositiveButton(this.getString(R.string.api_id_key_notice_ok_button),
new DialogInterface.OnClickListener() {
@Override
publicvoid onClick(final DialogInterface dialog, finalint whichButton) {
// Save response to permanent storage
final SharedPreferences.Editor prefs = PreferenceManager
.getDefaultSharedPreferences(getActivity().getApplicationContext()).edit();
prefs.putBoolean(getActivity().getString(R.string.api_id_key_notice_preference_key), false);
prefs.commit();
}
})
.create();
}
@Override
publicvoid onDestroyView() {
if (getDialog() != null && getRetainInstance()) {
getDialog().setDismissMessage(null);
}
super.onDestroyView();
}
}