【问题标题】:Make whole screen white(or any color)使整个屏幕变白(或任何颜色)
【发布时间】:2016-08-20 09:17:02
【问题描述】:

我有一个警报接收器,它在用户在活动中设置的时间做一些工作。当班级收到警报时,我想让所有屏幕变白! .可能吗?我怎样才能做到这一点?我在谷歌搜索并找到了一些使应用程序全屏显示的答案!我不知道我应该寻找什么目标。

public class AlarmReceiver extends WakefulBroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
    // make whole screen white(or any color)
    }
}

【问题讨论】:

标签: android


【解决方案1】:
@Override
    public void onReceive(Context context, Intent intent) {
        if (intent != null) {
            if(MainActivity.getInstace()!=null)
                MainActivity.getInstace().updateUI();
}

并在 YourActivity 中创建一个您想要全彩色屏幕的公共函数

public void updateUI() {
    MainActivity.this.runOnUiThread(new Runnable() {
        public void run() {
          //DO YOUR CHANGE
         //put background color in main layout
        }
    });
}

制作一个带有receiver和UI的activity,所以需要制作一个单独的receiver。

希望这个提示对你有所帮助..

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-07-28
    • 1970-01-01
    • 2022-06-24
    • 1970-01-01
    • 2018-03-18
    • 1970-01-01
    相关资源
    最近更新 更多