Android c2dm在取消注册时从mysql中删除记录
有人知道一旦设备从c2dm注销,我如何从mysql数据库中删除吗? 我的主要活动包括:Android c2dm在取消注册时从mysql中删除记录,android,mysql,push-notification,android-c2dm,Android,Mysql,Push Notification,Android C2dm,有人知道一旦设备从c2dm注销,我如何从mysql数据库中删除吗? 我的主要活动包括: public void unregister (View view){ Log.w("C2DM", "start unregister process"); Intent unregIntent = new Intent("com.google.android.c2dm.intent.UNREGISTER"); unregIntent.putExtra("app
public void unregister (View view){
Log.w("C2DM", "start unregister process");
Intent unregIntent = new Intent("com.google.android.c2dm.intent.UNREGISTER");
unregIntent.putExtra("app", PendingIntent.getBroadcast(this, 0, new Intent(), 0));
Toast.makeText(getApplicationContext(), "unregistered", Toast.LENGTH_LONG).show();
startService(unregIntent);
if ("com.google.android.c2dm.intent.REGISTRATION".equals(action)) {
现在我的问题来了。当我注册时,我将设备id和注册id输入到我的mysql数据库中(这是有效的),我想在单击“取消注册”后删除它
if ("com.google.android.c2dm.intent.REGISTRATION".equals(action)) {
在我的注册接收者范围内
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
Log.w("C2DM", "Registration Receiver called");
if ("com.google.android.c2dm.intent.REGISTRATION".equals(action)) {
Log.w("C2DM", "Received registration ID");
final String registrationId = intent
.getStringExtra("registration_id");
String error = intent.getStringExtra("error");
Log.d("C2DM", "dmControl: registrationId = " + registrationId
+ ", error = " + error);
String deviceId = Secure.getString(context.getContentResolver(),
Secure.ANDROID_ID);
createNotification(context, registrationId);
sendRegistrationIdToServer(deviceId, registrationId);
// Also save it in the preference to be able to show it later
saveRegistrationId(context, registrationId);}
if ("com.google.android.c2dm.intent.REGISTRATION".equals(action)) {
sendRegistrationIdToServer是:
public void sendRegistrationIdToServer(String deviceId, String registrationId) {
Log.d("C2DM", "Sending registration ID to my application server");
HttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost("http://myserver.com/Sandbox/androidDevice.php");
try {
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(1);
// Get the deviceID
nameValuePairs.add(new BasicNameValuePair("Email", deviceId));
nameValuePairs.add(new BasicNameValuePair("DeviceID", registrationId));
post.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse response = client.execute(post);
BufferedReader rd = new BufferedReader(new InputStreamReader(
response.getEntity().getContent()));
String line = "";
while ((line = rd.readLine()) != null) {
Log.e("HttpResponse", line);
}
} catch (IOException e) {
e.printStackTrace();
}
if ("com.google.android.c2dm.intent.REGISTRATION".equals(action)) {
(我有什么意义吗?)
如能一如既往地提供帮助,我们将不胜感激。是的,您可以执行
取消注册
意图操作。有关更多信息,请参阅
if ("com.google.android.c2dm.intent.REGISTRATION".equals(action)) {