Skip to content

Instantly share code, notes, and snippets.

View SampleActivity.java
File file = ...
// (1)
// intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));
// (2)
Uri uri = FileProvider.getUriForFile(
【アクティビティ名】.this
,getApplicationContext().getPackageName() + ".provider"
, file);
View provider_paths.xml
<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<external-path name="external_files" path="."/>
</paths>
View AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest ...>
<application ...>
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="${applicationId}.provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
@Sankame
Sankame / HttpPostSuccess.java
Last active May 9, 2018
サーバーからのレスポンスが多くてもOK
View HttpPostSuccess.java
public JSONObject post(String urlString) throws Exception{
URL url = new URL(urlString);
HttpsURLConnection con = (HttpsURLConnection) url.openConnection();
con.setConnectTimeout(Const.HTTP_CONNECT_TIMEOUT);
con.setReadTimeout(Const.HTTP_READ_TIMEOUT);
con.setUseCaches(false);
con.setDoInput(true);
con.setDoOutput(true);
con.setChunkedStreamingMode(0);
@Sankame
Sankame / HttpPostFailure.java
Last active May 9, 2018
サーバーからのレスポンスデータが多いとエラーになる
View HttpPostFailure.java
public JSONObject post(String urlString) throws Exception{
URL url = new URL(urlString);
HttpsURLConnection con = (HttpsURLConnection) url.openConnection();
con.setConnectTimeout(Const.HTTP_CONNECT_TIMEOUT);
con.setReadTimeout(Const.HTTP_READ_TIMEOUT);
con.setUseCaches(false);
con.setDoInput(true);
con.setDoOutput(true);
con.setChunkedStreamingMode(0);
@Sankame
Sankame / enable_vbs.reg
Created Jan 19, 2018
グループポリシーのvbscript設定を有効にする
View enable_vbs.reg
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\3]
"140C"=dword:00000000
View ShowMessage.java
/**
* メッセージ表示
*/
private void showMessage(){
final String KEY_OF_PREFERENCES = "KEY_OF_PREFERENCES";
final SharedPreferences preferences = getPreferences(MODE_PRIVATE);
boolean showMessage = preferences.getBoolean(KEY_OF_PREFERENCES, true);
if(showMessage) {
new AlertDialog.Builder(MainActivity.this)
@Sankame
Sankame / Main.java
Last active Aug 14, 2017
List to String array
View Main.java
import java.util.List;
import java.util.ArrayList;
public class Main{
public static void main(String[] args) {
List<String> list = new ArrayList();
list.add("one");
@Sankame
Sankame / gulpfile.js
Created Apr 19, 2017
js/cssファイルの圧縮・結合、ファイル名のユニーク化
View gulpfile.js
// gulpとgulpプラグインを読み込む。
var gulp = require('gulp');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var minifyCss = require('gulp-minify-css');
var rev = require('gulp-rev');
var revReplace = require('gulp-rev-replace');
var clean = require('gulp-clean');
// ファイルパス
@Sankame
Sankame / gulpfile.js
Created Mar 4, 2017
アスタリスクで指定するパターン
View gulpfile.js
var gulp = require('gulp');
// gulpプラグイン
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var minifyCss = require('gulp-minify-css');
// タスクを定義
gulp.task('js', function () {
gulp.src([
'./path-to/js/*.js'
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.