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 | |
protected void onResume() { | |
super.onResume(); | |
getPreferenceScreen().getSharedPreferences().registerOnSharedPreferenceChangeListener(this); | |
} | |
@Override | |
protected void onPause() { | |
super.onPause(); | |
getPreferenceScreen().getSharedPreferences().unregisterOnSharedPreferenceChangeListener(this); |
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 | |
protected void onResume() { | |
super.onResume(); | |
getPreferenceScreen().getSharedPreferences().registerOnSharedPreferenceChangeListener(this); | |
} | |
@Override | |
protected void onPause() { | |
super.onPause(); | |
getPreferenceScreen().getSharedPreferences().unregisterOnSharedPreferenceChangeListener(this); |
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
<?php | |
define('API_KEY', 'your-api_key'); | |
define('GOOGLE_URL', 'https://android.googleapis.com/gcm/send'); | |
//$regId = 'your_registration_id'; | |
$regId = trim(file_get_contents('register.txt')); | |
$data = array('registration_id' => $regId, | |
'collapse_key' => 'update', | |
'data.message' => 'Hello, GCM'); |
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
#!/bin/sh -x | |
api_key=your-api_key | |
registration_id=your-registration_id | |
curl -v \ | |
--header "Authorization: key=$api_key" \ | |
--header "Content-Type:application/json" \ | |
-d "{\"registration_ids\": [\"$registration_id\"], \"data\": {\"message\": \"こんにちは GCM!!\"}}" \ | |
https://android.googleapis.com/gcm/send |
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
#!/bin/sh -x | |
api_key=your-api_key | |
registration_id=your-registration_id | |
curl -v \ | |
--header "Authorization: key=$api_key" \ | |
--header 'Content-Type:application/x-www-form-urlencoded;charset=UTF-8' \ | |
-d registration_id=$registration_id \ | |
-d collapse_key=update \ |
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
<?php | |
$regId = isset($_POST['regId']) ? $_POST['regId'] : ''; | |
file_put_contents('register.txt', $regId); |
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
<?php | |
// 書き込み権限とか | |
unlink('register.txt'); |
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
/** | |
* Base URL of the Demo Server (such as http://my_host:8080/gcm-demo) | |
*/ | |
static final String SERVER_URL = "http://your-server-host/gcm"; |
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
static boolean register(final Context context, final String regId) { | |
Log.i(TAG, "registering device (regId = " + regId + ")"); | |
String serverUrl = SERVER_URL + "/register.php"; // 拡張子追加 | |
/* 省略 */ | |
static void unregister(final Context context, final String regId) { | |
Log.i(TAG, "unregistering device (regId = " + regId + ")"); | |
String serverUrl = SERVER_URL + "/unregister.php"; // 拡張子追加 |
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
/** | |
* Google API project id registered to use GCM. | |
*/ | |
// GoogleAPIコンソールのURLバーからもってくる | |
// https://code.google.com/apis/console/#project:123456789012:access | |
static final String SENDER_ID = "123456789012"; |
OlderNewer