小编jnr*_*ing的帖子

如何在通知上显示计时器?

如何在通知上显示我的计时器?我有一个应用程序启动用户指定的计时器,我想在通知上显示计时器。即使我的应用程序已关闭,我也使用服务来运行计时器,并且我使用 SharedPreference 来传递用户设置给服务的持续时间。

这是我的代码:page2(片段)

public class page2 extends Fragment {
    private static final String TAG =   "page2";

    private Button btntest;
    private TextView timer,tv;
    private Spinner spinner, spinner2;
    public int hours, mins, duration;
    private Vibrator v;

    private static int myVariable;
    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.page2_fragment,container,false);

        btntest = (Button) view.findViewById(R.id.button2);
        timer = (TextView) view.findViewById(R.id.Timer);
        tv = (TextView) view.findViewById(R.id.textView3);

        //setting up 2 spinners
        spinner = (Spinner) view.findViewById(R.id.spinner1);
        String [] values = …
Run Code Online (Sandbox Code Playgroud)

notifications android timer android-notifications

7
推荐指数
1
解决办法
2万
查看次数