美文网首页
finish 导致重新create 需要再次finish的bug

finish 导致重新create 需要再次finish的bug

作者: 吉凶以情迁 | 来源:发表于2022-04-24 16:40 被阅读0次

经过测试是隐式意图才会,https://developer.android.google.cn/guide/components/intents-filters#java

而且是特定的手机,另外隐式意图必须指定 export=true,隐式意图本来用来做多渠道,看来这个东西不好使。。
可以通过读取class反射或者设置包名解决这个bug

 Intent intent = new Intent("xx.print.template.setting");
        intent.setPackage(activity.getPackageName());
        ResolveInfo resolveInfo = activity.getPackageManager().resolveActivity(intent, PackageManager.MATCH_ALL);
        Log.w("resolveInfo",resolveInfo.activityInfo.name+"");
        activity.startActivity(intent);

其中

 intent.setPackage(activity.getPackageName());
        ResolveInfo resolveInfo = activity.getPackageManager().resolveActivity(intent, PackageManager.MATCH_ALL);
        Log.w("resolveInfo",resolveInfo.activityInfo.name+"");

是我加上去解决的。

设置包名就能解决,但是我之前写的一篇文章中,返回箭头的默认实现也会在某手机出现两次才能关闭。
而我当时的做法是:



    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case android.R.id.home:// 点击返回图标事件
                clickHome();
                return true;
            default:
                return super.onOptionsItemSelected(item);
        }
    }

我认为appcompat类不会又错的,有错的是这个手机系统,idata pda。。。 这个问题依旧重复出现了。

相关文章

网友评论

      本文标题:finish 导致重新create 需要再次finish的bug

      本文链接:https://www.haomeiwen.com/subject/ejwtyrtx.html