小编wil*_*iff的帖子

如何使用adjustResize设置隐藏键盘下方的BottomNavigationView

根据材料设计规范,当键盘出现时,BottomNavigationView应该隐藏在它下面.但是,如果我android:windowSoftInputMode="adjustResize"在Activity的清单中设置BottomNavigationView了键盘上方的移动.

我需要设置adjustResize为在键盘打开时滚动到屏幕底部.但是,我不希望它BottomNavigationView是可见的.可以这样做吗?

它目前的样子:

在此输入图像描述

布局XML(实际上会有一个FrameLayout在哪里,EditText并且EditText将在其中):

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="Input"
        android:layout_gravity="center"
        android:layout_centerVertical="true"/>

    <android.support.design.widget.BottomNavigationView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        app:itemBackground="@color/colorPrimary"
        app:menu="@menu/menu_bottom_navigation"
        app:itemIconTint="@android:color/white"
        app:itemTextColor="@android:color/white"/>

</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

android android-softkeyboard bottomnavigationview

29
推荐指数
3
解决办法
9806
查看次数

我能否检测到Android是否已从Notification Intent/PendingIntent中杀死了应用程序(任务进程)?

Android操作系统在内存不足时会终止进程.场景:Android杀死应用程序进程,我通过Android启动器或最近任务列表(长按主页按钮)重新打开它.我可以使用以下方法检查Android是否在最近查看的活动的onCreate()方法中杀死了我的应用程序进程:

@Override
protected void onCreate(Bundle savedInstanceState){
    super.onCreate(savedInstanceState);

    if (savedInstanceState != null) {
        // Re-initialise things that killing the app would have destroyed
    }
}
Run Code Online (Sandbox Code Playgroud)

但是,如果Android杀死应用程序进程并使用打包在PendingIntent中的Intent通过Notification重新打开它,我不知道如何确定应用程序进程是否被Android杀死.随后我不会重新初始化杀死应用程序进程会破坏的内容.

有没有办法确定Android是否在从通知中打开新活动时杀死了应用程序进程?

我找到了一个解决这个问题的hacky解决方案.使用:Android:在点击通知时始终启动顶级活动我可以在堆栈顶部打开活动,如果Android杀死应用程序进程并处理重新初始化,则会传递savedInstanceState.然后,每个活动负责使用原始通知意图中的额外内容将用户重定向到相应的活动.此方案的意图设置如下:

Intent notificationIntent = new Intent(this, MainActivity.class);
notificationIntent.setAction(Intent.ACTION_MAIN);
notificationIntent.addCategory(Intent.CATEGORY_LAUNCHER);
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
Run Code Online (Sandbox Code Playgroud)

我是否可以在Intent上设置一个Action,Category或Flag,它将模拟重新打开应用程序进程,就好像是由用户完成但是在新的Intent/Activity上?

编辑:澄清最后一个问题(虽然看起来我的婴儿对Android的理解让我失望所以它可能没有意义):我是否可以在Intent上设置Action,Category或Flag,就像上面的代码段一样,这将允许我确定应用程序进程是否已被操作系统杀死?

android android-intent android-notifications android-pendingintent android-os-handler

3
推荐指数
2
解决办法
7791
查看次数

我可以调用一个调用非同步方法的同步方法来调用同步方法吗?

在Java中使用synchronized关键字全部在单个对象和线程中.

我可以调用一个调用非同步方法的同步方法来调用同步方法,而不会阻止第一个同步方法完成的最终同步方法吗?

java multithreading synchronization java-threads

0
推荐指数
1
解决办法
905
查看次数