android 异常

Peng.Lei 2016-09-13 11:51:43
Process: com.hg.yunjingmatou,
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2424)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2484)
at android.app.ActivityThread.access$900(ActivityThread.java:158)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1352)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:171)
at android.app.ActivityThread.main(ActivityThread.java:5456)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

Caused by: java.lang.ClassCastException: com.hg.yunjingmatou.act.StartActivity cannot be cast to android.app.Application

at com.matt.kat.Bridge.onBeforeAttach(Bridge.java:121)
at com.matt.kat.ApplicationInit_hook.attachBaseContext(ApplicationInit_hook.java:27)
at android.view.ContextThemeWrapper.attachBaseContext(ContextThemeWrapper.java:71)
at android.app.Activity.attach(Activity.java:6231)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2358)
...全文
260 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
Rampage_SS 2016-09-13
  • 打赏
  • 举报
回复
估计6.0系统的手机都有这个问题。自己测试下。
Peng.Lei 2016-09-13
  • 打赏
  • 举报
回复
我是使用腾讯优测 测试apk ,其他型号手机不报异常,就是Huawei Nexus 6P 6.0时会出现这样的异常
Peng.Lei 2016-09-13
  • 打赏
  • 举报
回复
package com.hg.yunjingmatou.act; /** * 开启动画页面(当用户第一次使用软件时,start开启程序页面-welcome欢迎页面-login登陆页面 * ,反之由start开启程序页面-login登陆页面) */ import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.os.Bundle; import android.os.Handler; import android.util.Log; import android.view.Window; import android.view.WindowManager; import cn.jpush.android.api.InstrumentedActivity; import cn.jpush.android.api.JPushInterface; import com.hg.yunjingmatou.R; import com.hg.yunjingmatou.help.JgtxUtil; import com.hg.yunjingmatou.help.SPFHelp; public class StartActivity extends InstrumentedActivity { /** v v **/ //极光推送 public static boolean isForeground = false; private BroadcastReceiver mMessageReceiver; public static final String MESSAGE_RECEIVED_ACTION = "com.hg.yunjingmatou.MESSAGE_RECEIVED_ACTION"; public static final String KEY_TITLE = "title"; public static final String KEY_MESSAGE = "message"; public static final String KEY_EXTRAS = "extras"; /** v v **/ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.act_start); /** v v **/ //极光推送 registerMessageReceiver(); /** v v **/ new Handler().postDelayed(new Runnable() { @Override public void run() { boolean b = SPFHelp.getConfig(StartActivity.this).getBoolean("isFirst", true); if(b){ startActivity(new Intent(StartActivity.this, WellcomeActivity.class)); SPFHelp.getConfig(getApplicationContext()).edit().putBoolean("isFirst", false).commit(); finish(); }else{ startActivity(new Intent(StartActivity.this, LoginActivity.class)); finish(); } } }, 3000); } /** v v **/ public void registerMessageReceiver() { mMessageReceiver = new MessageReceiver(); IntentFilter filter = new IntentFilter(); filter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY); filter.addAction(MESSAGE_RECEIVED_ACTION); registerReceiver(mMessageReceiver, filter); } public class MessageReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { if (MESSAGE_RECEIVED_ACTION.equals(intent.getAction())) { String messge = intent.getStringExtra(KEY_MESSAGE); String extras = intent.getStringExtra(KEY_EXTRAS); StringBuilder showMsg = new StringBuilder(); showMsg.append(KEY_MESSAGE + " : " + messge + "\n"); if (!JgtxUtil.isEmpty(extras)) { showMsg.append(KEY_EXTRAS + " : " + extras + "\n"); } } } } @Override protected void onResume() { isForeground = true; // JPushInterface.onResume(this); super.onResume(); } @Override protected void onPause() { isForeground = false; // JPushInterface.onPause(this); super.onPause(); } @Override protected void onDestroy() { unregisterReceiver(mMessageReceiver); super.onDestroy(); } /** v v **/ } 是我的源码 是activity中使用的application异常,如何修改呢!
baixidamowang 2016-09-13
  • 打赏
  • 举报
回复
楼上说的对应该是上下文用错了,可以看异常里的那个文件
MR__P 2016-09-13
  • 打赏
  • 举报
回复
上下文用错了,你现在用的是getApplicationgContext()吧

80,490

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧