Google Playでapkの公開に時間がかかった
Google Playでアプリの公開に時間がかかりました。
36時間経っても公開されず、さすがにおかしいと思い、バージョンコードを一つ上げて、apkをアップデートしました。
そうすると、何事も無かったかのように、2時間後くらいに新バージョンコードのapkが公開されました。
端末起動時の時間のかかる処理
端末起動時に処理を動かすには、
android.intent.action.BOOT_COMPLETED
をキャッチしてやります。
public class BootBroadcastReceiver extends BroadcastReceiver {
Context context;
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)) {
DataCenter dataCenter = new DataCenter();
dataCenter.setContextNotificationScheduleOnBoot(context);
Intent notificationScheduleOnBoot = new Intent(context, NotificationScheduleOnBoot.class);
context.startService(notificationScheduleOnBoot);
}
}
}
ただ、BroadcastReceiverの処理は、短い処理でないといけないので、処理が長くなる時は、IntentServiceを使用します。
public class NotificationScheduleOnBoot extends IntentService {
public NotificationScheduleOnBoot() {
super("NotificationScheduleOnBoot");
}
@Override
protected void onHandleIntent(Intent intent) {
if (intent != null) {
// 長くかかる処理
}
}
}
AsyncTaskのdoInBackgroundが途中終了する
AsyncTaskのdoInBackgroundが途中終了する現象に遭遇して四苦八苦しました。
AsyncTaskの呼び出し元のスレッドかActivityが終了すると、doInBackgroundも途中終了するような感じです。。
正確な記載でなくてすいません。
DatePickerDialogのonDateSetが2回よばれる。
機種依存かもしれないですが、DatePickerDialogのonDateSetが2回よばれる現象が発生しました。
その場合の対処法:
DatePickerDialog.OnDateSetListener DateSetListener = new DatePickerDialog.OnDateSetListener() {
public void onDateSet(android.widget.DatePicker datePicker, int year, int monthOfYear, int dayOfMonth) {
if (!datePicker.isShown()) {
return;
}
displayCalendarView(year, monthOfYear);
mCallBack.monthChangedCallBack(prevYear, prevMonth, year, monthOfYear);
}
};
下記の部分で、2回目のonDateSetの対処しています。
if (!datePicker.isShown()) {
return;
}
こんな対応で良いのか?
Dialogが閉じたことを検出する
Dialogが閉じたことを検出する。
dialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialogInterface) {
}
});
setTextの文字が途中で切れてしまうとき
textView.setText()で設定した文字が途中で切れてしまうことがありました。
そんな時、
textView.setInputType(InputType.TYPE_CLASS_TEXT);
というように、textViewですが、InputTypeをTEXTにしてやったら解決することがあります。
理由は不明ですが・・・。