This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Intent intent = new Intent(Intent.ACTION_EDIT); | |
| intent.setType("vnd.android.cursor.item/event"); | |
| intent.putExtra("title", "!タイトル!"); // タイトル | |
| intent.putExtra("description", "!内容!"); // 内容 | |
| intent.putExtra("eventLocation", "!場所!"); // 場所 | |
| Calendar cal = Calendar.getInstance(); | |
| // cal.set(2011, 4, 29, 20, 0); | |
| intent.putExtra("beginTime", cal.getTimeInMillis()); // 開始日時 | |
| // cal.set(2011, 4, 29, 23, 0); | |
| intent.putExtra("endTime", cal.getTimeInMillis()); // 終了日時 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public void onClick1(View view) { | |
| // logcatにメールアドレスが表示される呼び出し方。セキュリティ上好ましくない | |
| Uri uri = Uri.parse("mailto:" + mail); | |
| Intent intent = new Intent(Intent.ACTION_SENDTO, uri); | |
| startActivity(intent); | |
| } | |
| public void onClick2(View view) { | |
| // logcatにメールアドレスが表示されない呼び出し方。セキュリティ上好ましい | |
| Uri uri = Uri.parse("mailto:"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private void showDateDialog() { | |
| final Calendar calendar = Calendar.getInstance(); | |
| final int year = calendar.get(Calendar.YEAR); | |
| final int month = calendar.get(Calendar.MONTH); | |
| final int day = calendar.get(Calendar.DAY_OF_MONTH); | |
| final DatePickerDialog datePickerDialog = new DatePickerDialog( | |
| this, | |
| new DatePickerDialog.OnDateSetListener() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| protected void showTimeDialog() { | |
| final Calendar calendar = Calendar.getInstance(); | |
| final int hour = calendar.get(Calendar.HOUR_OF_DAY); | |
| final int minute = calendar.get(Calendar.MINUTE); | |
| final TimePickerDialog timePickerDialog = new TimePickerDialog(this, | |
| new TimePickerDialog.OnTimeSetListener() { | |
| @Override | |
| public void onTimeSet(TimePicker view, int hourOfDay, int minute) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| mWebView.setDownloadListener(new DownloadListener() { | |
| @Override | |
| public void onDownloadStart(String url, String userAgent, | |
| String contentDisposition, String mimetype, long contentLength) { | |
| Intent intent = new Intent(Intent.ACTION_VIEW); | |
| intent.setType(mimetype); | |
| intent.setData(Uri.parse(url)); | |
| startActivity(intent); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 認証リクエストがあった場合の挙動 | |
| @Override | |
| public void onReceivedHttpAuthRequest(WebView view, | |
| HttpAuthHandler handler, String host, String realm) { | |
| // Android4.0の場合、hostにポート番号が付加されてしまうので、splitでポート番号を排除 | |
| String[] up = view.getHttpAuthUsernamePassword( | |
| host.split(":")[0], realm); | |
| if (up != null && up.length == 2) { | |
| handler.proceed(up[0], up[1]); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| int screenSize = getResources().getConfiguration().screenLayout & | |
| Configuration.SCREENLAYOUT_SIZE_MASK; | |
| switch (screenSize) { | |
| case Configuration.SCREENLAYOUT_SIZE_LARGE: | |
| Utils.showToast("Large screen"); | |
| break; | |
| case Configuration.SCREENLAYOUT_SIZE_NORMAL: | |
| Utils.showToast("Normal screen"); | |
| break; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Copyright 2015-present Yukari Sakurai | |
| * <p/> | |
| * 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 | |
| * <p/> | |
| * http://www.apache.org/licenses/LICENSE-2.0 | |
| * <p/> | |
| * Unless required by applicable law or agreed to in writing, software |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * 環境が日本語ならtrue | |
| */ | |
| public static boolean isJapan() { | |
| String locale = MyApplication.getContext().getResources().getConfiguration().locale.getLanguage(); | |
| Utils.logDebug("locale:" + locale); | |
| return locale.equals("ja"); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Copyright 2015-present Yukari Sakurai | |
| * <p/> | |
| * 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 | |
| * <p/> | |
| * http://www.apache.org/licenses/LICENSE-2.0 | |
| * <p/> | |
| * Unless required by applicable law or agreed to in writing, software |