日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > Android >内容正文

Android

android.os.binderproxy cannot be cast to,Android服务android.os.BinderProxy错误

發布時間:2023/12/15 Android 28 豆豆
生活随笔 收集整理的這篇文章主要介紹了 android.os.binderproxy cannot be cast to,Android服务android.os.BinderProxy错误 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

我一直在嘗試使此android服務正常工作,但我不知道為什么會收到此錯誤。

05-13 12:13:36.203: ERROR/dalvikvm(7782): could not disable core file generation for pid 7782: Operation not permitted

05-13 12:13:36.469: ERROR/AndroidRuntime(7782): FATAL EXCEPTION: main

05-13 12:13:36.469: ERROR/AndroidRuntime(7782): java.lang.ClassCastException: android.os.BinderProxy

05-13 12:13:36.469: ERROR/AndroidRuntime(7782): at whiskeymedia.com.GiantBombAppActivity$1.onServiceConnected(GiantBombAppActivity.java:69)

05-13 12:13:36.469: ERROR/AndroidRuntime(7782): at android.app.LoadedApk$ServiceDispatcher.doConnected(LoadedApk.java:1064)

05-13 12:13:36.469: ERROR/AndroidRuntime(7782): at android.app.LoadedApk$ServiceDispatcher$RunConnection.run(LoadedApk.java:1081)

05-13 12:13:36.469: ERROR/AndroidRuntime(7782): at android.os.Handler.handleCallback(Handler.java:587)

05-13 12:13:36.469: ERROR/AndroidRuntime(7782): at android.os.Handler.dispatchMessage(Handler.java:92)

05-13 12:13:36.469: ERROR/AndroidRuntime(7782): at android.os.Looper.loop(Looper.java:130)

05-13 12:13:36.469: ERROR/AndroidRuntime(7782): at android.app.ActivityThread.main(ActivityThread.java:3806)

05-13 12:13:36.469: ERROR/AndroidRuntime(7782): at java.lang.reflect.Method.invokeNative(Native Method)

05-13 12:13:36.469: ERROR/AndroidRuntime(7782): at java.lang.reflect.Method.invoke(Method.java:507)

05-13 12:13:36.469: ERROR/AndroidRuntime(7782): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)

05-13 12:13:36.469: ERROR/AndroidRuntime(7782): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)

05-13 12:13:36.469: ERROR/AndroidRuntime(7782): at dalvik.system.NativeStart.main(Native Method)

05-13 12:13:45.234: ERROR/GlobalUnplugService(7116): plugged = true,mBatteryPlugged=true

GiantBombAppActivity:

package whiskeymedia.com;

import java.util.ArrayList;

import java.util.List;

import whiskeymedia.com.vo.Achievement;

import android.app.ListActivity;

import android.content.ComponentName;

import android.content.Context;

import android.content.Intent;

import android.content.ServiceConnection;

import android.graphics.Color;

import android.os.Bundle;

import android.os.IBinder;

import android.view.LayoutInflater;

import android.view.View;

import android.view.ViewGroup;

import android.widget.AdapterView;

import android.widget.AdapterView.OnItemClickListener;

import android.widget.ArrayAdapter;

import android.widget.ListView;

import android.widget.TextView;

import android.widget.Toast;

public class GiantBombAppActivity extends ListActivity {

private ListView mListView;

private AchievementDatabase achievementDatabase;

private AchievementUpdateService s;

/** Called when the activity is first created. */

@Override

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

mListView = getListView();

List achievements = new ArrayList();

achievementDatabase = new AchievementDatabase(this);

achievementDatabase.open();

//achievementDatabase.resetDatabase();

achievements = achievementDatabase.getAllAchievements();

MyAdapter adapter = new MyAdapter(this, achievements);

setListAdapter(adapter);

List achievementNames = new ArrayList();

for(Achievement achievement: achievements) {

achievementNames.add(achievement.getAchievementName());

mListView.setOnItemClickListener(new OnItemClickListener() {

public void onItemClick(AdapterView> parent, View view, int position, long id){

//When clicked show a toast with the textview text

Toast.makeText(getApplicationContext(), ((TextView) view).getText(), Toast.LENGTH_SHORT).show();

}

});

doBindService();

}

}

private ServiceConnection mConnection = new ServiceConnection() {

public void onServiceConnected(ComponentName className, IBinder binder) {

s = ((AchievementUpdateService.MyBinder) binder).getService();

Toast.makeText(GiantBombAppActivity.this, "Connected", Toast.LENGTH_SHORT).show();

}

public void onServiceDisconnected(ComponentName className) {

s = null;

}

};

void doBindService() {

bindService(new Intent(this, AchievementUpdateService.class), mConnection, Context.BIND_AUTO_CREATE);

}

/**

* Adapter class to use for the list

*/

private static class MyAdapter extends ArrayAdapter {

/**

* Constructor

*

* @param context The context

* @param contacts The list of contacts

*/

public MyAdapter(final Context context, final List achievements) {

super(context, 0, achievements);

}

@Override

public View getView(final int position, final View convertView, final ViewGroup parent) {

View view = convertView;

if (view == null) {

view = LayoutInflater.from(getContext()).inflate(R.layout.list_item, null);

}

final TextView achiev = (TextView)view.findViewById(R.id.achievement);

if (getItem(position).getAchievmentRarity().compareTo("common") == 0) {

achiev.setTextColor(Color.GREEN);

}

else if (getItem(position).getAchievmentRarity().compareTo("uncommon") == 0) {

achiev.setTextColor(Color.BLUE);

}

else if (getItem(position).getAchievmentRarity().compareTo("rare") == 0) {

achiev.setTextColor(Color.MAGENTA);

}

achiev.setText(getItem(position).getAchievementName());

final TextView game = (TextView)view.findViewById(R.id.game);

game.setText(getItem(position).getGameName());

return view;

}

}

}

}

成就更新服務:

package whiskeymedia.com;

import java.io.IOException;

import java.util.ArrayList;

import java.util.List;

import whiskeymedia.com.vo.Achievement;

import android.app.Service;

import android.content.Intent;

import android.os.Binder;

import android.os.IBinder;

public class AchievementUpdateService extends Service{

private AchievementDatabase achievementDatabase;

private final IBinder mBinder = new MyBinder();

@Override

public int onStartCommand(Intent intent, int flags, int startId) {

HtmlParser htmlParser = new HtmlParser();

try {

List achievements= htmlParser.parseDocument();

achievementDatabase.loadAchievements(achievements);

} catch (IOException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

return Service.START_NOT_STICKY;

}

@Override

public IBinder onBind(Intent arg0) {

return mBinder;

}

public class MyBinder extends Binder {

AchievementUpdateService getService() {

return AchievementUpdateService.this;

}

}

}

知道我在做什么錯嗎?

總結

以上是生活随笔為你收集整理的android.os.binderproxy cannot be cast to,Android服务android.os.BinderProxy错误的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。