這裏是logcat的錯誤我得到:錯誤在谷歌Play服務:讀取失敗:EPERM(不允許的操作)
android java.io.IOException: read failed: EPERM (Operation not permitted)
at libcore.io.IoBridge.read(IoBridge.java:435)
的錯誤是在下面的代碼,在這裏我想註冊一個給定的設備使用AsyncTask:
private void registerInBackground(){
mRegisterIdTask = new AsyncTask<Void, Void, Void>() {
@Override
protected Void doInBackground(Void... params) {
String msg = "";
try {
if (gcm == null) {
gcm = GoogleCloudMessaging.getInstance(context);
}
regId = gcm.register(SENDER_ID);
msg = "Device registered, registration ID=" + regId;
/* TODO : Send regId to backend to store in database so backend can send...
TODO : ...push notification request to GooglePlayMessaging
*/
sendRegistrationIdToBackend();
storeRegistrationId(context, regId);
} catch (IOException e) {
msg = "Error : " + e.getMessage();
}
return null;
}
@Override
protected void onPostExecute(Void result) {
Log.i("Google Play", "Status : Finished ");
mRegisterIdTask = null;
}
}.execute(null, null, null);
}
現在好了,我得到這個,我沒有改變任何東西。
05-15 17:33:35.253 16020-16271/? E/AndroidRuntime﹕ FATAL EXCEPTION: AsyncTask #1
Process: com.panicsystems.kyuubi.legalpanicpartner, PID: 16020
java.lang.RuntimeException: An error occured while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:300)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:841)
Caused by: java.lang.SecurityException: Not allowed to start service Intent { act=com.google.android.c2dm.intent.REGISTER pkg=com.google.android.gms (has extras) } without permission com.google.android.c2dm.permission.RECEIVE
at android.app.ContextImpl.startServiceCommon(ContextImpl.java:1603)
at android.app.ContextImpl.startService(ContextImpl.java:1580)
at android.content.ContextWrapper.startService(ContextWrapper.java:494)
at com.google.android.gms.gcm.GoogleCloudMessaging.zzs(Unknown Source)
at com.google.android.gms.gcm.GoogleCloudMessaging.register(Unknown Source)
at com.kyuubi.MainActivity$2.doInBackground(MainActivity.java:171)
at com.kyuubi.MainActivity$2.doInBackground(MainActivity.java:161)
at android.os.AsyncTask$2.call(AsyncTask.java:288)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:841)
您使用氰? –
分享使用Google Play服務的代碼。 – pelya
不使用Cyanogen mod – reemul