android点击应用没有反应,Android安装应用后点击“打开”遇到的问题及解决

一、问题描述

当安装新应用时,安装完成后会出现一个“打开”和“完成”界面,点击完成没有问题,但是点击“打开”就出现了问题。

具体操作如下:

step1:打开应用收到更新提示(启动页检查更新),点击“立刻更新”

setp2:下载成功后点击“安装”,

setp3:安装成功后出现“打开”和“完成”界面,点击“打开”,应用先显示启动页面然后进入到主界面,

setp4:按下HOME键,回到桌面,然后点击桌面应用图标,会先显示启动页面然后再显示主界面。

二、问题原因

刚开始还以为是应用崩溃了,才重新打开了启动界面,后面经过测试和日志发现并没有任何的异常。What?遇见鬼了!经过搜索终于发现了问题的原因:

This is due to the intents being used to start the app being different. Eclipse starts an app using an intent with no action and no category. The Launcher starts an app using an intent with android.intent.action.MAIN action and android.intent.category.LAUNCHER category. The installer starts an app with the android.intent.action.MAIN action and no category.

原来这三种打开方式是有区别的,通过idea安装打开应用的intent是没有action和category的,桌面点击图标打开应用的intent是带有action(android.intent.action.MAIN) 和category(android.intent.category.LAUNCHER)的,而按照器打开应用只带有action(android.intent.action.MAIN)而没有category。

二、解决方式

再启动界面的onCreate添加方法添加如下代码

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

if ((getIntent().getFlags() & Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT) != 0) {

// Activity was brought to front and not created,

// Thus finishing this will get us to the last viewed activity

finish();

return;

}

......

}

三、参考

https://stackoverflow.com/questions/6337217/how-to-return-to-the-latest-launched-activity-when-re-launching-application-afte

https://www.jianshu.com/p/eea14ca0b164

https://developer.android.google.cn/guide/components/tasks-and-back-stack

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值