This file contains 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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
This file contains 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
import android.app.AlertDialog; | |
import android.app.Dialog; | |
import android.content.DialogInterface; | |
import android.os.Bundle; | |
import android.support.annotation.NonNull; | |
import android.support.v4.app.DialogFragment; | |
/** | |
* Created by yusukehata on 2015/03/01. | |
*/ |
This file contains 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 class AsyncTaskTest extends Activity { | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
final MyAsyncTask asyncTask = new MyAsyncTask(); | |
asyncTask.execute(""); | |
This file contains 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
<application> | |
//略 | |
<receiver | |
android:name=".NotificationReceiver" | |
android:process=":remote"/> | |
//略 | |
</application> |
This file contains 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 class NotificationReceiver extends BroadcastReceiver{ | |
@Override | |
public void onReceive(Context context, Intent intent) { | |
String message = intent.getStringExtra("MESSAGE"); | |
Toast.makeText(context, message, Toast.LENGTH_SHORT).show(); | |
} |
This file contains 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 class NotificationUtil { | |
public static void setLocalNotification(Context context, String message, int requestCode, int interval){ | |
Intent intent = new Intent(context, NotificationReceiver.class); | |
intent.putExtra("MESSAGE", message); | |
PendingIntent sender = PendingIntent.getBroadcast(context, requestCode, intent, PendingIntent.FLAG_UPDATE_CURRENT); | |
Calendar calendar = Calendar.getInstance(); | |
calendar.setTimeInMillis(System.currentTimeMillis()); | |
calendar.add(Calendar.SECOND, interval); |
This file contains 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
//HOGEスレッド開始 | |
HogeThread thread = new HogeThread(); | |
thread.start(); | |
//再利用できないのでインスタンス生成 | |
thread = new HogeThread(); | |
thread.start(); |
This file contains 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
//はじめに起動するActivity内でリソースを読み込んでおく | |
//一度読み込めば以降呼ぶ必要はない | |
StringResource.LoadResrouce(getApplicationContext()); | |
//文字列を取得 | |
String appName = StringResource.getString(R.string.KuwApp); | |
String blogTitle = StringResource.getString(R.string.blog_title); | |
String blogUrl = StringResource.getString(R.string.blog_url); |
This file contains 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 class StringResource { | |
private static HashMap< Integer, String> stringResources = null; | |
public static void LoadResrouce(Context context){ | |
stringResources = new HashMap< Integer, String>(); | |
Field[] fields = R.string.class.getFields(); | |
for(Field field:fields) { | |
try { |
This file contains 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 class MyPagerAdapter extends FragmentPagerAdapter{ | |
//いろいろ略 | |
@Override | |
public Fragment getItem(int position) { | |
Bundle bundle = new Bundle(); | |
bundle.putInt("INDEX", position); |
NewerOlder