本文介绍了如何添加小吃店在一个BroadcastReceiver?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
小吃店通过显示在屏幕的底部的一个简短的消息提供有关一个操作的轻量级反馈。小吃店可以包含一个动作。
Snackbars provide lightweight feedback about an operation by showing a brief message at the bottom of the screen. Snackbars can contain an action.
Android版还提供了一个敬酒,主要用于系统的消息。吐司类似于小吃店但不包含动作和不能刷卡关闭屏幕。
Android also provides a toast, primarily used for system messaging. Toasts are similar to snackbars but do not contain actions and cannot be swiped off screen.
我的问题
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.widget.Toast;
public class TestReceiver extends BroadcastReceiver {
@Override
public void onReceive(final Context context, final Intent intent) {
Toast.makeText(context, "status", Toast.LENGTH_LONG).show();
}
}
它是更多钞票来显示小吃吧
在广播接收器
如吐司
推荐答案
我的工作code ....
my working code....
public abstract class TestReceiver extends BroadcastReceiver {
@Override
public void onReceive(final Context context, final Intent intent) {
onNetworkChange();
}
protected abstract void onNetworkChange();
}
在mainactivity
in mainactivity
public class MainActivity extends Activity {
public void onCreate() {
... mReceiver = new TestReceiver () {
@Override
protected void onNetworkChange() {
snackbar = Snackbar.make(Clayout, "Please check your internet connection and try again", Snackbar.LENGTH_SHORT);
snackbar.setAction("X", snackbarClickListener);snackbar.setActionTextColor(Color.GREEN);
ColoredSnackbar coloredsnakbar=new ColoredSnackbar();
coloredsnakbar.confirm(snackbar).show();
}
};
}
}
这篇关于如何添加小吃店在一个BroadcastReceiver?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!