android gcm service_not_available,GCM注册SERVICE_NOT_AVAILABLE

这真让我讨厌.我有一个使用GCM的应用程序.我有人抱怨他们因错误而无法登录.让我告诉你我是如何进行登录的:

// Login Activity

//....

public void onClickLoginButton (View v) {

// Do some stuff...

new GCMRegister().execute(); //AsyncTask

}

private class GCMRegister extends AsyncTask {

@Override

protected Integer doInBackground (Void... params) {

ConnectivityManager connMgr = (ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE);

NetworkInfo networkInfo = connMgr.getActiveNetworkInfo();

if (networkInfo != null && networkInfo.isConnected()) {

try {

//Get GCM Registration key

registrationId = googleCloud.register(Settings.PROJECT_NUMBER);

} catch (Exception e) {

Log.e("GCMRegister", e.toString());

return -1;

}

return 1;

} else {

return -3;

}

}

@Override

protected void onPostExecute(Integer result) {

if (result == 1) {

new LoginAsync().execute(); // Another AsyncTask to check in my database if user is valid and save its key

} else {

user.setEnabled(true);

password.setEnabled(true);

login.setEnabled(true);

if (result == -1) {

Toast.makeText(Login.this, "A problem occured login in", Toast.LENGTH_LONG).show();

} else if (result == -3) {

Toast.makeText(Login.this, "I need an internet connection", Toast.LENGTH_LONG).show();

}

}

}

所以很多人抱怨他们因为"登陆时出现问题"错误而无法登录,这表明GCM登记失败.即使我自己使用我的设备Android 4.4.2,也不能一开始就做到这一点.我需要尝试登录2到3次,直到它工作(并且我的连接很好).我的LogCat上的错误是:

08-04 21:29:10.922: E/GCMRegister(18182): java.io.IOException: SERVICE_NOT_AVAILABLE

那我的代码有什么问题?这让我疯了.

OpenSSL is a popular open-source library that provides cryptographic functions, including AES (Advanced Encryption Standard). AES-GCM (Galois/Counter Mode) is a mode of operation for AES that combines encryption and authentication. It provides both confidentiality and integrity. To use AES-GCM with OpenSSL, you can follow these steps: 1. Install OpenSSL: If you don't have OpenSSL installed on your system, you can download and install it from the official OpenSSL website. 2. Generate a key and IV: AES-GCM requires a key and an initialization vector (IV). You can generate them using OpenSSL's command-line tool or programmatically using OpenSSL's library functions. 3. Encrypt data: Use the EVP (Envelope) interface provided by OpenSSL to perform AES-GCM encryption. Here's an example command-line invocation: ``` openssl enc -aes-256-gcm -in plaintext.txt -out ciphertext.bin -K <key> -iv <iv> ``` Replace `<key>` with your AES-GCM key (in hexadecimal or base64 format) and `<iv>` with your IV. Replace `plaintext.txt` with the path to your plaintext file and `ciphertext.bin` with the desired output ciphertext file. 4. Decrypt data: To decrypt the ciphertext, use a similar command-line invocation: ``` openssl enc -d -aes-256-gcm -in ciphertext.bin -out plaintext.txt -K <key> -iv <iv> ``` Make sure to use the same key and IV that were used for encryption. Note that this is just a basic example, and there are more advanced options and features available in OpenSSL for AES-GCM encryption. You can refer to the OpenSSL documentation or seek further resources for more information.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值