fun solution(N: Int): Int {
// 2進数に変換
val s = N.toString(2)
// sが0を含まないなら0を返す
if (!s.contains('0')) return 0
var max = 0
var count = 0
deprecated
public static boolean isApplicationInForeground(final Context context) {
final ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
final List<RunningTaskInfo> tasks = activityManager.getRunningTasks(1);
if (!tasks.isEmpty()) {
final ComponentName topActivity = tasks.get(0).topActivity;
// 新
ContextCompat.getColor(mContext, R.color.sample)
// 旧
mContext.getResources().getColor(R.color.sample)
// ContextCompat
if (!notificationManager.areNotificationsEnabled()) {
openNotificationSettings();
return;
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O &&
isChannelBlocked(CHANNEL_1_ID)) {
Android Oreoから通知を送るにはまずチャンネルを登録するようになった。
https://feel-log.net/android/developer/o-notification-no-sound-vibration/
int importance = NotificationManager.IMPORTANCE_;
NotificationChannel channel = new NotificationChannel(CHANNEL_ID, name, importance);
NotificationManager manager =
(NotificationManager) getSystemService(Service.NOTIFICATION_SERVICE);
manager.createNotificationChannel(channel);
Android Icon Size guide for Android 6 Marshmallow
Android Icon Size guide for App Interface Icons
- | MDPI (160dpi) Baseline | HDPI (240dpi) 1.5x | XHDPI (320dpi) 2x | XXHDPI (480dpi) 3x | XXXHDPI (640dpi) 4x |
---|---|---|---|---|---|
Launcher Icon | 48px | 72px | 96px | 166px | 192px |
Small Contextual icons | 16px | 24px | 32px | 48px | 64px |
Notification icons | 22px icon in 24px area | 33px icon in 36px area | 44px icon in 48px area | 66px icon in 72px area | 88px icon in 96px area |
[java] String.getBytes => [kotlin] String.toByteArray
fun String.toByteArray(
charset: Charset = Charsets.UTF_8
): ByteArray
Encodes the contents of this string using the specified character set and returns the resulting byte array.
import java.util.*;
// ハノイの塔の実装
class Main {
/*
piles:3本の杭をlistに格納
名前なし:杭はLinkedList。円盤を格納
名前なし:円盤の大きさを整数で表す。
How to programmatically set the width of the LinearLayout?
Display display = getActivity.getWindowManager().getDefaultDisplay();
Point size = new Point();
try {
display.getRealSize(size);
} catch (NoSuchMethodError err) {
display.getSize(size);
}