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错误相关推荐
- android.os.BinderProxy cannot be cast to
Android在绑定service的时候出现java.lang.ClassCastException:android.os.BinderProxy cannot be cast to ...异常时:修 ...
- java.lang.ClassCastException:android.widget.Button cannot be cast to android.widget.ImageView
今天遇到一个错误也不知道怎么回事,上网搜了一下: 出现的问题是:java.lang.ClassCastException:android.widget.Button cannot be cast to ...
- 新建Application 报错android.app.Application cannot be cast
我在开发APP的时候重新使用了一个类,继承了android.app.Application.但是在运行的时候提示java.lang.ClassCastException: android.app.Ap ...
- android.view.ContextThemeWrapper cannot be cast to android.app.Activity
java.lang.ClassCastException: android.view.ContextThemeWrapper cannot be cast to android.app.Activit ...
- 氢os android 7.0,氢OS 3.0正式推送!基于Android 7.0,简洁纯净
原标题:氢OS 3.0正式推送!基于Android 7.0,简洁纯净 一加手机自推出伊始就坚持"不将就"的品牌理念,用顶级硬件和较低的价格以及众多定制ROM俘获了众多"加 ...
- 【异常】android.app.Application cannot be cast to****
出这个异常的原因是在项目中添加了新application类(public class Application extends android.app.Application)之后,没有在manifes ...
- findViewById寻找SearchView控件导致程序崩溃 android.widget.SearchView cannot be cast to android.support.v7.widg
searchView = (SearchView)findViewById(R.id.searchView); 程序莫名其妙崩溃 logcat查看程序日志 android.widget.SearchV ...
- android java服务,Android进阶学习必会:Java Binder中的系统服务
前言 这个知识点是Android进阶学习必须掌握的知识点之一,也是高阶Android架构师经常问到的点.在这里分想给大家,希望对大家的工作和学习有所帮助.喜欢本文的记得点赞关注哦~ 在前面的Andro ...
- Android 10.0 PackageManagerService(二)权限扫描-[Android取经之路]
摘要:PackageManagerService在systemReady()后,进行了/system/etc/permissions中的各种xml进行扫描,进行相应的权限存储,供以后使用 阅读本文大约 ...
- android ffmpeg 简书,偶遇FFmpeg(三)——Android集成
熟悉命令之后,自然是对其根据自己的需求进行应用了.所以久等的第三编文章就来放放水.记录一下在Android端的集成. 文章组织架构 接下来几遍文章将会按照以下结构来进行组织. 编译FFmpeg For ...
最新文章
- java oracle数据库高效分页查询_oracle高效分页查询总结
- spring入门(12)-spring与hibernate整合完成增删改查的操作(继承HibernateDaoSupport调用hibernateTemplate类)
- 第九天2017/04/18(1、友元函数、运算符重载)
- jar包的生成和使用简单例子
- 后端技术:Java 泛型 T,E,K,V的含义,看完本文你就明白了?
- [转]浅析Tomcat、JBOSS、WebSphere、WebLogic、Apache
- 向MFC应用程序添加控制台窗口
- 启动rrt什么意思_面试官:你来说一下springboot启动时的一个自动装配过程吧!...
- 区块链技术:颠覆性革命浪潮的开始
- maps-api-v3_Android Google Maps API集成
- 活动目录集成区域DNS服务
- 百度地图坐标系统应用
- 关于C#从一个List复制到另一个List的简便写法。
- c语言 库仑计_android电池(四):电池 电量计(MAX17040)驱动分析篇
- 【LabView小剧场】用LabView做个计算器
- WIZ ConfigTool-批量配置WIZnet S2E模块
- 获取iOS设备的UDID
- 预应力内力计算时作用机理(纠结好久的问题orz)
- CSS在线字体库,外部字体的引用方法@font-face
- VMware安装centos7
热门文章
- 删除重复数据sql语句
- 一本flash和搜索引擎交互的新书
- centos 对已有卷扩容_centos7下对原有磁盘分区进行在线扩容
- .net 怎么使用github_如何正确的使用ncnn的Extractor
- led内部结构_科普PCB,DPC,陶瓷PCB对于LED封装有哪些差异? - led显示屏_高清led显示屏价格_led显示屏生产厂家...
- ospf实验及原理(ensp)
- python27.dll引起的appcrash_python27.dll错误代码126怎么解决
- 选择时间日历控件DatePickerDialog实现(从外包项目中挖出来整理的)
- 使用apache配置基于IP地址的虚拟主机
- python创建和控制的实体称为_Python语法基础